TS TypeSafe 文档中文版 原文 ↗

问题

使用对象或字典提供状态,并提出是/否问题、选择问题和评分问题。

状态

state 是你想针对其提问的文本或 JSON 对象。它不能是 None,但对象内部的值可以是 None。

问题对象

使用 Noul、Choice 和 Score 通过具名参数来定义问题。

typesafe_sdk.NoulCriteria

基类:TypedDict

对「是」和「否」两种结果的可选描述。

详见 noul 原语。

true

instance-attribute

对「是」这一结果的描述,以文本、JSON 对象或数组给出;None 表示不加描述。

false

instance-attribute

对「否」这一结果的描述,以文本、JSON 对象或数组给出;None 表示不加描述。

typesafe_sdk.Noul

pydantic-model

基类:_Question、wire.NoulQuestion

一个是/否问题,两种结果都可附可选描述。

详见 noul 原语。

注意

显示 JSON schema:

详情
json
{
  "$defs": {
    "JSONContent": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "array"
        }
      ]
    },
    "JSONValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        }
      ]
    },
    "NoulCriteria": {
      "additionalProperties": false,
      "description": "Optional descriptions of the yes and no outcomes.\n\nSee the [noul primitive](https://docs.typesafe.ai/primitives/noul) for details.",
      "properties": {
        "true": {
          "anyOf": [
            {
              "$ref": "#/$defs/JSONContent"
            },
            {
              "type": "null"
            }
          ]
        },
        "false": {
          "anyOf": [
            {
              "$ref": "#/$defs/JSONContent"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "title": "NoulCriteria",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "A yes/no question with optional descriptions for either outcome.\n\nSee the [noul primitive](https://docs.typesafe.ai/primitives/noul) for details.",
  "properties": {
    "type": {
      "const": "noul",
      "default": "noul",
      "title": "Type",
      "type": "string"
    },
    "instructions": {
      "anyOf": [
        {
          "$ref": "#/$defs/JSONContent"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "criteria": {
      "anyOf": [
        {
          "$ref": "#/$defs/NoulCriteria"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    }
  },
  "title": "Noul",
  "type": "object"
}
 

字段:

instructions

pydantic-field

要提出的问题,以文本、JSON 对象或数组表示;可选。

criteria

pydantic-field

对「是」和「否」两种结果的可选描述。

typesafe_sdk.Choice

pydantic-model

基类:_Question、wire.ChoiceQuestion

一个在具名备选项之间做出选择的问题。

详见 choice 原语。

注意

显示 JSON schema:

详情
json
{
  "$defs": {
    "JSONContent": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "array"
        }
      ]
    },
    "JSONValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        }
      ]
    }
  },
  "additionalProperties": false,
  "description": "A question that selects between named alternatives.\n\nSee the [choice primitive](https://docs.typesafe.ai/primitives/choice) for details.",
  "properties": {
    "type": {
      "const": "choice",
      "default": "choice",
      "title": "Type",
      "type": "string"
    },
    "instructions": {
      "anyOf": [
        {
          "$ref": "#/$defs/JSONContent"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "criteria": {
      "additionalProperties": {
        "anyOf": [
          {
            "$ref": "#/$defs/JSONContent"
          },
          {
            "type": "null"
          }
        ]
      },
      "title": "Criteria",
      "type": "object"
    }
  },
  "required": [
    "criteria"
  ],
  "title": "Choice",
  "type": "object"
}
 

字段:

criteria

pydantic-field

标签映射到文本、对象或数组描述,None 表示该标签不加描述。

instructions

pydantic-field

要提出的问题,以文本、JSON 对象或数组表示;可选。

typesafe_sdk.Score

pydantic-model

基类:_Question、wire.ScoreQuestion

一个使用有序评分标准给出分数的问题。

详见 score 原语。

注意

显示 JSON schema:

详情
json
{
  "$defs": {
    "JSONContent": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "array"
        }
      ]
    },
    "JSONValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/$defs/JSONValue"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        }
      ]
    }
  },
  "additionalProperties": false,
  "description": "A question that assigns a score using an ordered rubric.\n\nSee the [score primitive](https://docs.typesafe.ai/primitives/score) for details.",
  "properties": {
    "type": {
      "const": "score",
      "default": "score",
      "title": "Type",
      "type": "string"
    },
    "instructions": {
      "anyOf": [
        {
          "$ref": "#/$defs/JSONContent"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "criteria": {
      "items": {
        "$ref": "#/$defs/JSONContent"
      },
      "title": "Criteria",
      "type": "array"
    }
  },
  "required": [
    "criteria"
  ],
  "title": "Score",
  "type": "object"
}
 

字段:

criteria

pydantic-field

由文本、对象或数组描述构成的非空有序列表,从零分开始每个分数对应一项。

instructions

pydantic-field

要提出的问题,以文本、JSON 对象或数组表示;可选。

typesafe_sdk.Question

module-attribute

一个问题对象或问题字典。

typesafe_sdk.Questions

module-attribute

以用于标识其答案的名称作为键的问题输入。

问题字典

问题字典包含一个 type 键:"noul"、"choice" 或 "score"。你可以在同一次请求中混用字典和问题对象。

typesafe_sdk.NoulModel

基类:TypedDict

一个 type="noul" 的是/否问题字典。

详见 noul 原语。

type

instance-attribute

instructions

instance-attribute

要提出的问题,以文本、JSON 对象或数组表示;可选。

criteria

instance-attribute

对「是」和「否」两种结果的可选描述。

typesafe_sdk.ChoiceModel

基类:TypedDict

一个 type="choice" 的选择问题字典。

详见 choice 原语。

type

instance-attribute

instructions

instance-attribute

要提出的问题,以文本、JSON 对象或数组表示;可选。

criteria

instance-attribute

标签映射到文本、对象或数组描述,None 表示该标签不加描述。

typesafe_sdk.ScoreModel

基类:TypedDict

一个 type="score" 的评分问题字典。

详见 score 原语。

type

instance-attribute

instructions

instance-attribute

要提出的问题,以文本、JSON 对象或数组表示;可选。

criteria

instance-attribute

由文本、对象或数组描述构成的非空有序列表,从零分开始每个分数对应一项。

typesafe_sdk.QuestionModel

module-attribute

一个由其 type 键标识的问题字典。