Agent output
AgentOutputSchemaBase
Bases:ABC
An object that captures the JSON schema of the output, as well as validating/parsing JSONproduced by the LLM into the output type.
Source code insrc/agents/agent_output.py
is_plain_textabstractmethod
nameabstractmethod
json_schemaabstractmethod
Returns the JSON schema of the output. Will only be called if the output type is notplain text.
is_strict_json_schemaabstractmethod
Whether the JSON schema is in strict mode. Strict mode constrains the JSON schemafeatures, but guarantees valid JSON. See here for details:https://platform.openai.com/docs/guides/structured-outputs#supported-schemas
Source code insrc/agents/agent_output.py
validate_jsonabstractmethod
Validate a JSON string against the output type. You must return the validated object,or raise aModelBehaviorError if the JSON is invalid.
AgentOutputSchemadataclass
Bases:AgentOutputSchemaBase
An object that captures the JSON schema of the output, as well as validating/parsing JSONproduced by the LLM into the output type.
Source code insrc/agents/agent_output.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 | |
__init__
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_type | type[Any] | The type of the output. | required |
strict_json_schema | bool | Whether the JSON schema is in strict mode. Westrongly recommendsetting this to True, as it increases the likelihood of correct JSON input. | True |
Source code insrc/agents/agent_output.py
is_plain_text
is_strict_json_schema
json_schema
validate_json
Validate a JSON string against the output type. Returns the validated object, or raisesaModelBehaviorError if the JSON is invalid.