回答与响应
机器翻译译自英文(docs.typesafe.ai)本页 328 段已全部译完
文档索引
在以下地址获取完整的文档索引:https://docs.typesafe.ai/llms.txt 使用此文件可以在进一步探索之前发现所有可用页面。
回答与响应
读取 TypeSafe API 返回的回答、置信度评分、token 使用情况和可用模型。
Response
typesafe_sdk.SystemOneResponse
pydantic-model
基类:Response
按问题类型分组的回答,包含模型和使用元数据。
请参阅 System One 了解详情。
Note
显示 JSON 架构:
配置:
extra:ignorefrozen:Truestrict:True
字段:
request_id
cached property
request_id: strx-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: 使用情况请求的 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
API 报告时,请求的 token 计数。
Note
显示 JSON 架构:
配置:
extra:ignorefrozen:Truestrict:True
字段:
input_tokens(int | None)output_tokens(int | None)
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 原语。
Note
显示 JSON 架构:
配置:
extra:ignorefrozen:Truestrict:True
字段:
<a href="/sdk/python/api/types/responses#typesafe_sdk.NoulAnswer.noul">noul</a>(<a href="https://docs.python.org/3/builtins/functions.html#float">float</a>)type(<a href="https://docs.python.org/3/library/typing.html#typing.Literal">Literal</a>['noul'])
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 原语。
Note
显示 JSON 架构:
配置:
extra:ignorefrozen:Truestrict:True
字段:
choice(str)confidence(float)probabilities(dict[str, float])type(Literal['choice'])
choice
pydantic-field
choice: str问题标准中概率最高的选项名称。
confidence
pydantic-field
confidence: float所选选项的置信度,范围从 0 到 1。值越高表示确定性越强;使用较低值将不确定的选择标记为待审核。
probabilities
pydantic-field
probabilities: dict[str, float]标准中每个选择的选择概率,以选择名称为键,范围从 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 原语。
Note
显示 JSON 架构:
配置:
extra:ignorefrozen:Truestrict:True
字段:
score(float)confidence(float)type(Literal['score'])legend(dict[int, str | dict[str, Any] | list[Any]])probabilities(dict[int, float])
score
pydantic-field
score: float预期分数:评分标准级别的概率加权平均值。可能介于整数级别之间。
confidence
pydantic-field
confidence: float对分数的置信度,范围为 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]
]以整数分数为键的评分标准描述。
probabilities
pydantic-field
probabilities: dict[int, float]以整数分数为键的概率。
typesafe_sdk.Answer
module-attribute
回答: 类型别名 = 已注解[
是否回答 | 选择回答 | 评分回答,
字段(鉴别器="类型"),
]对单个问题的回答,通过其 type 标识。
可用模型
typesafe_sdk.ListModelsResponse
pydantic-model
基类:Response
账户可用的模型。
Note
显示 JSON 架构:
字段:
models(tuple[ModelMetadata, ...])
request_id
cached property
request_id: strx-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
描述单个可用模型的元数据。
Note
显示 JSON 架构:
字段:
name(str)description(str)release_date(str)
name
pydantic-field
name: str请求的 model 字段接受的模型名称或别名。
description
pydantic-field
description: str
模型及其功能的人类可读描述。
release_date
pydantic-field
release_date: str
模型的发布日期,格式为 YYYY-MM-DD。