答案与响应
阅读 TypeSafe API 返回的答案、置信度分数、token 用量以及可用模型。
响应
typesafe_sdk.SystemOneResponse
pydantic-model
基类:Response
按问题类型分组的答案,附带模型与用量元数据。
详见 System One。
显示 JSON schema:
Details▾
{
"$defs": {
"ChoiceAnswer": {
"description": "A selected label and its probabilities.\n\nSee the [choice primitive](https://docs.typesafe.ai/primitives/choice) for details.",
"properties": {
"type": {
"const": "choice",
"default": "choice",
"title": "Type",
"type": "string"
},
"choice": {
"description": "The name of the choice with the highest probability among the question's criteria.",
"examples": [
"angry"
],
"title": "Choice",
"type": "string"
},
"confidence": {
"description": "Confidence in the selected choice, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain selections for review.",
"examples": [
0.9
],
"title": "Confidence",
"type": "number"
},
"probabilities": {
"additionalProperties": {
"type": "number"
},
"description": "Probability of each choice in criteria, keyed by choice name, from 0 to 1. Shows how likely the alternatives are; values sum to approximately 1.",
"examples": [
{
"angry": 0.8,
"calm": 0.1,
"excited": 0.1
}
],
"title": "Probabilities",
"type": "object"
}
},
"required": [
"choice",
"confidence",
"probabilities"
],
"title": "ChoiceAnswer",
"type": "object"
},
"NoulAnswer": {
"description": "A yes/no answer.\n\nSee the [noul primitive](https://docs.typesafe.ai/primitives/noul) for details.",
"properties": {
"type": {
"const": "noul",
"default": "noul",
"title": "Type",
"type": "string"
},
"noul": {
"description": "Probability of a yes answer or a true statement, from 0 to 1. Values near 1 favor yes or true, values near 0 favor no or false, and values near 0.5 indicate uncertainty.",
"examples": [
0.98
],
"title": "Noul",
"type": "number"
}
},
"required": [
"noul"
],
"title": "NoulAnswer",
"type": "object"
},
"ScoreAnswer": {
"description": "An expected score with its rubric and probabilities.\n\nSee the [score primitive](https://docs.typesafe.ai/primitives/score) for details.",
"properties": {
"type": {
"const": "score",
"default": "score",
"title": "Type",
"type": "string"
},
"score": {
"description": "Expected score: the probability-weighted average of the rubric levels. May fall between integer levels.",
"examples": [
1.7
],
"title": "Score",
"type": "number"
},
"confidence": {
"description": "Confidence in the score, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain ratings for review.",
"examples": [
0.9
],
"title": "Confidence",
"type": "number"
},
"legend": {
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": true,
"type": "object"
},
{
"items": {},
"type": "array"
}
]
},
"title": "Legend",
"type": "object"
},
"probabilities": {
"additionalProperties": {
"type": "number"
},
"title": "Probabilities",
"type": "object"
}
},
"required": [
"score",
"confidence",
"legend",
"probabilities"
],
"title": "ScoreAnswer",
"type": "object"
},
"Usage": {
"description": "Token counts for a request, when reported by the API.",
"properties": {
"input_tokens": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Input Tokens"
},
"output_tokens": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Output Tokens"
}
},
"title": "Usage",
"type": "object"
}
},
"description": "Answers grouped by question type with model and usage metadata.\n\nSee [System One](https://docs.typesafe.ai/concepts/system-one) for details.",
"properties": {
"model": {
"title": "Model",
"type": "string"
},
"usage": {
"$ref": "#/$defs/Usage"
},
"answers": {
"additionalProperties": {
"discriminator": {
"mapping": {
"choice": "#/$defs/ChoiceAnswer",
"noul": "#/$defs/NoulAnswer",
"score": "#/$defs/ScoreAnswer"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/NoulAnswer"
},
{
"$ref": "#/$defs/ChoiceAnswer"
},
{
"$ref": "#/$defs/ScoreAnswer"
}
]
},
"title": "Answers",
"type": "object"
}
},
"required": [
"model",
"usage"
],
"title": "SystemOneResponse",
"type": "object"
}配置:
extra:ignorefrozen:Truestrict: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
以问题名称为键的所有答案对象。
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 有报告时)。
显示 JSON schema:
Details▾
{
"description": "Token counts for a request, when reported by the API.",
"properties": {
"input_tokens": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Input Tokens"
},
"output_tokens": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Output Tokens"
}
},
"title": "Usage",
"type": "object"
}配置:
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 原语。
显示 JSON schema:
Details▾
{
"description": "A yes/no answer.\n\nSee the [noul primitive](https://docs.typesafe.ai/primitives/noul) for details.",
"properties": {
"type": {
"const": "noul",
"default": "noul",
"title": "Type",
"type": "string"
},
"noul": {
"description": "Probability of a yes answer or a true statement, from 0 to 1. Values near 1 favor yes or true, values near 0 favor no or false, and values near 0.5 indicate uncertainty.",
"examples": [
0.98
],
"title": "Noul",
"type": "number"
}
},
"required": [
"noul"
],
"title": "NoulAnswer",
"type": "object"
}配置:
extra:ignorefrozen:Truestrict: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 原语。
显示 JSON schema:
Details▾
{
"description": "A selected label and its probabilities.\n\nSee the [choice primitive](https://docs.typesafe.ai/primitives/choice) for details.",
"properties": {
"type": {
"const": "choice",
"default": "choice",
"title": "Type",
"type": "string"
},
"choice": {
"description": "The name of the choice with the highest probability among the question's criteria.",
"examples": [
"angry"
],
"title": "Choice",
"type": "string"
},
"confidence": {
"description": "Confidence in the selected choice, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain selections for review.",
"examples": [
0.9
],
"title": "Confidence",
"type": "number"
},
"probabilities": {
"additionalProperties": {
"type": "number"
},
"description": "Probability of each choice in criteria, keyed by choice name, from 0 to 1. Shows how likely the alternatives are; values sum to approximately 1.",
"examples": [
{
"angry": 0.8,
"calm": 0.1,
"excited": 0.1
}
],
"title": "Probabilities",
"type": "object"
}
},
"required": [
"choice",
"confidence",
"probabilities"
],
"title": "ChoiceAnswer",
"type": "object"
}配置:
extra:ignorefrozen:Truestrict:True
字段:
probabilities(dict[str, float])type(Literal['choice'])
choice
pydantic-field
choice
:
str
在问题的评判标准中概率最高的选项名称。
confidence
pydantic-field
confidence
:
float
所选选项的置信度,取值范围 0 到 1。值越高表示确定性越大;可用较低的值标记不确定的选择以便复核。
probabilities
pydantic-field
标准中每个选项的概率,以选项名称为键,取值范围 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 原语。
显示 JSON schema:
Details▾
{
"description": "An expected score with its rubric and probabilities.\n\nSee the [score primitive](https://docs.typesafe.ai/primitives/score) for details.",
"properties": {
"type": {
"const": "score",
"default": "score",
"title": "Type",
"type": "string"
},
"score": {
"description": "Expected score: the probability-weighted average of the rubric levels. May fall between integer levels.",
"examples": [
1.7
],
"title": "Score",
"type": "number"
},
"confidence": {
"description": "Confidence in the score, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain ratings for review.",
"examples": [
0.9
],
"title": "Confidence",
"type": "number"
},
"legend": {
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": true,
"type": "object"
},
{
"items": {},
"type": "array"
}
]
},
"title": "Legend",
"type": "object"
},
"probabilities": {
"additionalProperties": {
"type": "number"
},
"title": "Probabilities",
"type": "object"
}
},
"required": [
"score",
"confidence",
"legend",
"probabilities"
],
"title": "ScoreAnswer",
"type": "object"
}配置:
extra:ignorefrozen:Truestrict:True
字段:
type(Literal['score'])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
以整数分数为键的评分标准描述。
probabilities
pydantic-field
以整数分数为键的概率。
typesafe_sdk.Answer
module-attribute
Answer: TypeAlias = Annotated[
NoulAnswer | ChoiceAnswer | ScoreAnswer,
Field(discriminator="type"),
]
对单个问题的答案,由其 type 标识。
可用模型
typesafe_sdk.ListModelsResponse
pydantic-model
基类:Response
该账户可用的模型。
显示 JSON schema:
Details▾
{
"$defs": {
"ModelMetadata": {
"description": "Metadata describing a single available model.",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"description": {
"title": "Description",
"type": "string"
},
"release_date": {
"title": "Release Date",
"type": "string"
}
},
"required": [
"name",
"description",
"release_date"
],
"title": "ModelMetadata",
"type": "object"
}
},
"description": "The models available to the account.",
"properties": {
"models": {
"items": {
"$ref": "#/$defs/ModelMetadata"
},
"title": "Models",
"type": "array"
}
},
"required": [
"models"
],
"title": "ListModelsResponse",
"type": "object"
}字段:
models(tuple[ModelMetadata, ...])
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
描述单个可用模型的元数据。
显示 JSON schema:
Details▾
{
"description": "Metadata describing a single available model.",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"description": {
"title": "Description",
"type": "string"
},
"release_date": {
"title": "Release Date",
"type": "string"
}
},
"required": [
"name",
"description",
"release_date"
],
"title": "ModelMetadata",
"type": "object"
}字段:
name
pydantic-field
name
:
str
请求的 model 字段所接受的模型名称或别名。
description
pydantic-field
description
:
str
关于该模型及其能力的人类可读描述。
release_date
pydantic-field
release_date
:
str
模型发布日期,格式为 YYYY-MM-DD。