haive.core.common.mixins.structured_output_mixinΒΆ

Mixin for handling structured output in LLM configurations.

This mixin provides functionality to configure and manage structured output models with support for both v1 (parser-based) and v2 (tool-based) approaches.

ClassesΒΆ

StructuredOutputMixin

Mixin to provide structured output functionality for LLM configurations.

Module ContentsΒΆ

class haive.core.common.mixins.structured_output_mixin.StructuredOutputMixin[source]ΒΆ

Mixin to provide structured output functionality for LLM configurations.

This mixin adds support for: - Configuring structured output models with v1 (parser) or v2 (tool) approaches - Automatic format instruction generation - Tool-based structured output forcing

with_structured_output(model, include_instructions=True, version='v2')[source]ΒΆ

Configure with Pydantic structured output.

Parameters:
  • model (type[pydantic.BaseModel]) – The Pydantic model to use for structured output

  • include_instructions (bool) – Whether to include format instructions

  • version (str) – Version of structured output (β€œv1” for parser-based, β€œv2” for tool-based)

Returns:

Self for method chaining

Return type:

StructuredOutputMixin