cuery.tools.schema#

Attributes#

Classes#

SchemaResponse

Response from the AI that includes both conversation and schema update.

ConversationalSchemaResponse

Response from the AI that includes both conversation and schema update.

SchemaGenerator

Create or modify a JSON schema given a prompt and optionally an existing schema.

Module Contents#

cuery.tools.schema.SYSTEM_PROMPT = ''#
cuery.tools.schema.CONVERSATIONAL_SYSTEM_PROMPT = ''#
cuery.tools.schema.SCHEMA_CONTEXT = Multiline-String#
Show Value
"""
Please modify, extend, or replace the schema in the following section based on the user's request.
If the user wants to add fields, merge them with the existing schema.
If they want to remove fields, remove them from the existing schema.
If they want to modify field types or descriptions, update the existing schema accordingly.

## Current Schema
{schema}

"""
class cuery.tools.schema.SchemaResponse(/, **data)#

Bases: cuery.Response

Response from the AI that includes both conversation and schema update.

Parameters:

data (Any)

reasoning: str#

Brief explanation of schema design choices

json_schema: dict[str, Any]#

Valid JSON schema as a dictionary defining a structured output

classmethod validate_json_schema(json_schema)#

Validate that the schema is a proper JSON schema.

Parameters:

json_schema (dict[str, Any])

Return type:

dict[str, Any]

class cuery.tools.schema.ConversationalSchemaResponse(/, **data)#

Bases: SchemaResponse

Response from the AI that includes both conversation and schema update.

Parameters:

data (Any)

answer: str#

Conversational response to the user

examples: list[dict[str, Any]] = None#

Some example records that conform to the schema

classmethod validate_examples(examples, info)#

Validate that example data conforms to the schema.

Parameters:

examples (list[dict[str, Any]])

Return type:

list[dict[str, Any]]

class cuery.tools.schema.SchemaGenerator(/, **data)#

Bases: cuery.Tool

Create or modify a JSON schema given a prompt and optionally an existing schema.

Parameters:

data (Any)

instructions: str#

Prompt instructions with details of the schema to generate.

current_schema: dict | None = None#

Optional existing schema to modify or extend.

response_model: ClassVar[cuery.ResponseClass]#

All instances of this tool will use the SchemaResponse model.

property prompt: cuery.Prompt#

Add system and assistant messages to user’s prompt.

Return type:

cuery.Prompt

async __call__(**kwds)#

Extracts a two-level topic hierarchy from a list of texts.

Return type:

SchemaResponse