答案與響應
讀取 TypeSafe API 返回的答案、置信度、token 用量和可用模型。
響應
typesafe_sdk.SystemOneResponse
pydantic-model
基類:Response
按問題型別分組的答案,附模型和用量後設資料。
詳見 System One。
配置:
extra: ignore
frozen: True
strict: True
欄位:
request_id
cached property
request_id: str
響應頭 x-typesafe-request-id。
raw_http_response
property
raw_http_response: httpx2.Response
底層的 httpx2.Response,暴露狀態碼、響應頭和響應體。
model_config
class-attribute instance-attribute
model_config = ConfigDict(
extra="ignore", frozen=True, strict=True
)
model
pydantic-field
model: str
用於回答該請求的模型。
usage
pydantic-field
usage: Usage
該請求的 token 用量。
answers
pydantic-field
answers: dict[str, Answer]
按問題名索引的全部答案物件。
nouls
cached property
nouls: dict[str, NoulAnswer]
按問題名索引的是非答案。
choices
cached property
choices: dict[str, ChoiceAnswer]
按問題名索引的 Choice 答案。
scores
cached property
scores: dict[str, ScoreAnswer]
按問題名索引的 Score 答案。
typesafe_sdk.Usage
pydantic-model
基類:wire.Usage
一次請求的 token 計數,在 API 上報時才有。
配置:
extra: ignore
frozen: True
strict: True
欄位:
model_config
class-attribute instance-attribute
model_config = ConfigDict(
extra="ignore", frozen=True, strict=True
)
input_tokens
pydantic-field
input_tokens: int | None = None
使用的輸入 token 數;API 未上報時為 None。
output_tokens
pydantic-field
output_tokens: int | None = None
使用的輸出 token 數;API 未上報時為 None。
答案
typesafe_sdk.NoulAnswer
pydantic-model
基類:wire.NoulAnswer
一個是非答案。
詳見 noul 原語。
配置:
extra: ignore
frozen: True
strict: True
欄位:
noul
pydantic-field
noul: float
答「是」或命題為真的機率,取值 0 到 1。接近 1 偏向「是」或真,接近 0 偏向「否」或假,接近 0.5 表示不確定。
model_config
class-attribute instance-attribute
model_config = ConfigDict(
extra="ignore", frozen=True, strict=True
)
typesafe_sdk.ChoiceAnswer
pydantic-model
基類:wire.ChoiceAnswer
一個選中的標籤及其機率。
詳見 choice 原語。
配置:
extra: ignore
frozen: True
strict: True
欄位:
choice
pydantic-field
choice: str
在該問題的判定標準(criteria)中機率最高的那個 choice 的名字。
confidence
pydantic-field
confidence: float
對所選 choice 的置信度,取值 0 到 1。值越高表示越確定;值低時把這些不確定的選擇標出來轉人工複核。
probabilities
pydantic-field
probabilities: dict[str, float]
判定標準(criteria)中每個 choice 的機率,按 choice 名索引,取值 0 到 1。它顯示各備選有多可能;各值之和約為 1。
model_config
class-attribute instance-attribute
model_config = ConfigDict(
extra="ignore", frozen=True, strict=True
)
typesafe_sdk.ScoreAnswer
pydantic-model
基類:wire.ScoreAnswer
一個帶量規和機率分佈的期望 score。
詳見 score 原語。
配置:
extra: ignore
frozen: True
strict: True
欄位:
score
pydantic-field
score: float
期望 score:各量規檔位的機率加權平均。可以落在兩個整數檔位之間。
confidence
pydantic-field
confidence: float
對該 score 的置信度,取值 0 到 1。值越高表示越確定;值低時把這些不確定的評分標出來轉人工複核。
model_config
class-attribute instance-attribute
model_config = ConfigDict(
extra="ignore", frozen=True, strict=True
)
legend
pydantic-field
legend: dict[
int, str | dict[str, Any] | list[Any]
]
按整數 score 索引的量規描述。
probabilities
pydantic-field
probabilities: dict[int, float]
按整數 score 索引的機率分佈。
typesafe_sdk.Answer
module-attribute
Answer: TypeAlias = Annotated[
NoulAnswer | ChoiceAnswer | ScoreAnswer,
Field(discriminator="type"),
]
對單個問題的回答,由其 type 區分。
可用模型
typesafe_sdk.ListModelsResponse
pydantic-model
基類:Response
該賬號可用的模型。
欄位:
request_id
cached property
request_id: str
響應頭 x-typesafe-request-id。
raw_http_response
property
raw_http_response: httpx2.Response
底層的 httpx2.Response,暴露狀態碼、響應頭和響應體。
model_config
class-attribute instance-attribute
model_config = ConfigDict(
extra="ignore", frozen=True, strict=True
)
models
pydantic-field
models: tuple[ModelMetadata, ...]
可用的模型。
typesafe_sdk.ModelMetadata
pydantic-model
基類:Schema
描述單個可用模型的後設資料。
欄位:
name
pydantic-field
name: str
請求的 model 欄位所接受的模型名或別名。
description
pydantic-field
description: str
模型及其能力的可讀描述。
release_date
pydantic-field
release_date: str
模型釋出日期,格式為 YYYY-MM-DD。