Documentation
¶
Overview ¶
Package structuredoutput implements the internal tool behind tool-mode structured output (structured_output.mode: tool). Instead of asking the provider for native structured output, the runtime exposes a single tool whose Parameters are exactly the configured JSON schema; the model delivers its final answer by calling it, and the runtime validates the arguments against the same schema before accepting the result.
Index ¶
Constants ¶
const ToolName = "__structured_output__"
ToolName is the reserved name of the internal structured-output tool. The dunder form is provider-compatible ([a-zA-Z0-9_-]) and unlikely to collide with real tools; the runtime fails loudly when a real tool claims it rather than masking either one.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OutputTool ¶
type OutputTool struct {
// contains filtered or unexported fields
}
OutputTool bundles the structured-output configuration with its compiled JSON schema so validation and the tool definition stay in sync.
func New ¶
func New(cfg *latest.StructuredOutput) (*OutputTool, error)
New compiles cfg.Schema and returns the ready-to-expose tool. It fails when the configured schema is not a valid JSON Schema or references anything outside the document, so callers can surface the problem at load time instead of on the first model turn.
func (*OutputTool) Definition ¶
func (t *OutputTool) Definition() tools.Tool
Definition returns the tool definition offered to the model. Parameters are exactly the configured JSON schema.
func (*OutputTool) Validate ¶
func (t *OutputTool) Validate(rawJSON string) (string, error)
Validate checks rawJSON against the configured schema and returns its compacted, canonical form. The returned error is model-facing: it details what failed so the model can correct itself on the next attempt.