ДокументацияTypeSafe Python SDKТипы вопросов (Questions)

Типы вопросов (Questions)

Provide state and ask yes/no, choice, and score questions using objects or dictionaries.

Передавайте состояние и задавайте бинарные (yes/no), категориальные (choice) и балльные (score) вопросы с помощью объектов или словарей.

export function SdkSignature({children}) {
async function copy(event) {
const button = event.currentTarget;
const code = button.parentElement.querySelector("pre code");
try {
await navigator.clipboard.writeText(code.textContent);
button.setAttribute("aria-label", "Signature copied");
button.dataset.copied = "true";
} catch {
button.setAttribute("aria-label", "Copy failed; select the signature to copy");
}
setTimeout(() => {
button.setAttribute("aria-label", "Copy signature");
delete button.dataset.copied;
}, 2000);
}
return



{children}

;
}

Состояние (State)

state — это текст или объект JSON, относительно которого вы хотите задать вопросы. Значение не может быть None, но значения внутри объекта могут быть None.

Объекты вопросов (Question objects)

Используйте Noul, Choice и Score для определения вопросов с именованными аргументами.

typesafe\_sdk.NoulCriteria

Базовые классы: TypedDict

Необязательные описания исходов «да» (yes) и «нет» (no).

Подробнее см. примитив Noul.

true

instance-attribute

{"true"} {":"}

{" "}

{"JSONContent"}

{" "}

{"|"}

{" "}

{"None"}

{"\n"}

Описание исхода «да» в виде текста, JSON-объекта или массива; None оставляет его без описания.

false

instance-attribute

{"false"} {":"}

{" "}

{"JSONContent"}

{" "}

{"|"}

{" "}

{"None"}

{"\n"}

Описание исхода «нет» в виде текста, JSON-объекта или массива; None оставляет его без описания.

typesafe\_sdk.Noul

pydantic-model

Базовые классы: _Question, wire.NoulQuestion

Вопрос типа «да/нет» с необязательными описаниями для каждого исхода.

Подробнее см. примитив Noul.

**Показать JSON-схему:** ```json theme={null} { "$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": "Необязательные описания исходов «да» и «нет».\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

{"instructions"} {":"}

{" "}

{"JSONContent"}

{" "}

{"|"}

{" "}

{"None"}

{" "}

{"="}

{" "}

{"None"}

{"\n"}

Формулировка вопроса в виде текста, JSON-объекта или массива; необязательно.

criteria

pydantic-field

{"criteria"} {":"}

{" "}

{"NoulCriteria"}

{" "}

{"|"}

{" "}

{"None"}

{" "}

{"="}

{" "}

{"None"}

{"\n"}

Необязательные описания исходов «да» и «нет».

typesafe\_sdk.Choice

pydantic-model

Базовые классы: _Question, wire.ChoiceQuestion

Вопрос с выбором между именованными вариантами.

Подробнее см. примитив Choice.

**Показать JSON-схему:** ```json theme={null} { "$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

{"criteria"} {":"}

{" "}

{"Mapping"} {"["} {"str"} {","}

{" "}

{"JSONContent"}

{" "}

{"|"}

{" "}

{"None"} {"]"}

{"\n"}

Метки вариантов, сопоставленные с текстовыми, объектными или массивными описаниями, либо None для меток без описания.

instructions

pydantic-field

{"instructions"} {":"}

{" "}

{"JSONContent"}

{" "}

{"|"}

{" "}

{"None"}

{" "}

{"="}

{" "}

{"None"}

{"\n"}

Формулировка вопроса в виде текста, JSON-объекта или массива; необязательно.

typesafe\_sdk.Score

pydantic-model

Базовые классы: _Question, wire.ScoreQuestion

Вопрос, выставляющий оценку по упорядоченной шкале (рубрике).

Подробнее см. примитив Score.

**Показать JSON-схему:** ```json theme={null} { "$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

{"criteria"} {":"}

{" "}

{"Sequence"} {"["} {"JSONContent"} {"]"}

{"\n"}

Непустой упорядоченный список описаний в виде текста, объекта или массива — по одному на каждый балл, начиная с нуля.

instructions

pydantic-field

{"instructions"} {":"}

{" "}

{"JSONContent"}

{" "}

{"|"}

{" "}

{"None"}

{" "}

{"="}

{" "}

{"None"}

{"\n"}

Формулировка вопроса в виде текста, JSON-объекта или массива; необязательно.

typesafe\_sdk.Question

module-attribute

{"Question"}{":"}{" "}{"TypeAlias"}{" "}{"="}{" "}{"("}{"\n"}{" "}{"Noul"}{" "}{"|"}{" "}{"Choice"}{" "}{"|"}{" "}{"Score"}{" "}{"|"}{" "}{"QuestionModel"}{"\n"}{")"}{"\n"}

Объект вопроса или словарь вопроса.

typesafe\_sdk.Questions

module-attribute

{"Questions"} {":"}

{" "}

{"TypeAlias"}

{" "}

{"="}

{" "}

{"Mapping"} {"["} {"str"} {","}

{" "}

{"Question"} {"]"}

{"\n"}

Входные данные вопросов, сгруппированные по именам, используемым для идентификации их ответов.

Словари вопросов (Question dictionaries)

Словари вопросов содержат ключ type: "noul", "choice" или "score". В одном запросе можно комбинировать словари и объекты вопросов.

typesafe\_sdk.NoulModel

Базовые классы: TypedDict

Словарь вопроса типа «да/нет» с type="noul".

Подробнее см. примитив Noul.

type

instance-attribute

{"type"} {":"}

{" "}

{"Literal"} {"["} {"'noul'"} {"]"}

{"\n"}

instructions

instance-attribute

{"instructions"} {":"}

{" "}

{"NotRequired"} {"["} {"JSONContent"}

{" "}

{"|"}

{" "}

{"None"} {"]"}

{"\n"}

Формулировка вопроса в виде текста, JSON-объекта или массива; необязательно.

criteria

instance-attribute

{"criteria"} {":"}

{" "}

{"NotRequired"} {"["} {"NoulCriteria"}

{" "}

{"|"}

{" "}

{"None"} {"]"}

{"\n"}

Необязательные описания исходов «да» и «нет».

typesafe\_sdk.ChoiceModel

Базовые классы: TypedDict

Словарь вопроса с выбором вариантов с type="choice".

Подробнее см. примитив Choice.

type

instance-attribute

{"type"} {":"}

{" "}

{"Literal"} {"["} {"'choice'"} {"]"}

{"\n"}

instructions

instance-attribute

{"instructions"} {":"}

{" "}

{"NotRequired"} {"["} {"JSONContent"}

{" "}

{"|"}

{" "}

{"None"} {"]"}

{"\n"}

Формулировка вопроса в виде текста, JSON-объекта или массива; необязательно.

criteria

instance-attribute

{"criteria"} {":"}

{" "}

{"Mapping"} {"["} {"str"} {","}

{" "}

{"JSONContent"}

{" "}

{"|"}

{" "}

{"None"} {"]"}

{"\n"}

Метки вариантов, сопоставленные с текстовыми, объектными или массивными описаниями, либо None для меток без описания.

typesafe\_sdk.ScoreModel

Базовые классы: TypedDict

Словарь вопроса с оценкой по шкале с type="score".

Подробнее см. примитив Score.

type

instance-attribute

{"type"} {":"}

{" "}

{"Literal"} {"["} {"'score'"} {"]"}

{"\n"}

instructions

instance-attribute

{"instructions"} {":"}

{" "}

{"NotRequired"} {"["} {"JSONContent"}

{" "}

{"|"}

{" "}

{"None"} {"]"}

{"\n"}

Формулировка вопроса в виде текста, JSON-объекта или массива; необязательно.

criteria

instance-attribute

{"criteria"} {":"}

{" "}

{"Sequence"} {"["} {"JSONContent"} {"]"}

{"\n"}

Непустой упорядоченный список описаний в виде текста, объекта или массива — по одному на каждый балл, начиная с нуля.

typesafe\_sdk.QuestionModel

module-attribute

{"QuestionModel"}{":"}{" "}{"TypeAlias"}{" "}{"="}{" "}{"("}{"\n"}{" "}{"NoulModel"}{" "}{"|"}{" "}{"ChoiceModel"}{" "}{"|"}{" "}{"ScoreModel"}{"\n"}{")"}{"\n"}

Словарь вопроса, идентифицируемый по ключу type.