答案与响应
答案与响应
读取 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。