yera.models.data_classes

Class representing structured LLM conversation messages.

Symbols

class Message — A single turn in an LLM conversation, optionally including thinking traces and tool metadata.
class ToolData — Metadata associated with a tool call or its result.

Message

Inherits: BaseModel

A single turn in an LLM conversation, optionally including thinking traces and tool metadata.

Attributes

role
type: Literal['user', 'system', 'assistant', 'tool_call', 'tool_result']

The speaker role.

content
type: str

The text content of the message.

thinking
type: str | None

The thinking trace leading up to the content (if any)

tool_data
type: ToolData | None

data required for tool calls and results

on_wire
type: bool

whether a message is to be included back into the model context.

Methods

user — Create a user-role message.
system — Create a system-role message.
assistant — Create an assistant-role message.
tool_call — Create a tool call message with metadata.
tool_result — Create a tool result message with metadata.

Message.user

user(
    content: str,
) → Message

Create a user-role message.

Parameters

content
type: str

The text content of the user message.

Returns

type: Message

A Message instance with role set to 'user'.

Message.system

system(
    content: str,
) → Message

Create a system-role message.

Parameters

content
type: str

The text content of the system prompt.

Returns

type: Message

A Message instance with role set to 'system'.

Message.assistant

assistant(
    content: str,
    thinking: str | None = None,
    on_wire: bool = True,
    provider_data: list[dict[str, object]] | None = None,
) → Message

Create an assistant-role message.

Parameters

content
type: str

The text generated by the assistant.

thinking
type: str | None = None

Optional “thinking” trace produced while the assistant was formulating its response. Stored for later inspection if provided.

on_wire
type: bool = True

whether this line should be kept in the LLM context.

provider_data
type: list[dict[str, object]] | None = None

Opaque provider state required for later requests.

Returns

type: Message

A Message instance with role set to "assistant", containing the supplied content and optional thinking data.

Message.tool_call

tool_call(
    content: str,
    tool_id: str,
    call_id: str,
    tool_schema: dict,
    provider_data: list[dict[str, object]] | None = None,
) → Message

Create a tool call message with metadata.

Parameters

content
type: str

JSON-formatted tool invocation payload.

tool_id
type: str

Name of the invoked tool.

call_id
type: str

Unique identifier for this invocation.

tool_schema
type: dict

JSON schema describing the tool input.

provider_data
type: list[dict[str, object]] | None = None

Opaque provider state required for later requests.

Returns

type: Message

A tool-call message containing its invocation metadata.

Message.tool_result

tool_result(
    content: str,
    tool_id: str,
    call_id: str,
    tool_schema: dict,
) → Message

Create a tool result message with metadata.

Parameters

content
type: str

JSON-formatted tool execution result.

tool_id
type: str

Name of the tool invoked (must match original call).

call_id
type: str

Unique ID matching the original tool call.

tool_schema
type: dict

Same schema as used in tool_call.

Returns

type: Message

A Message instance with role set to "tool_result", containing the result content and tool metadata.

ToolData

Inherits: BaseModel

Metadata associated with a tool call or its result.

Attributes

tool_id
type: str

Name of the invoked tool (usually the class name).

call_id
type: str

Unique identifier for this specific tool invocation.

tool_schema
type: dict

JSON schema describing expected input/output structure.