Documentation
¶
Index ¶
Constants ¶
const ( // OutputToolName is the well-known name for the structured output tool. OutputToolName = "submit_output" // OutputToolInstruction is appended to the system prompt when the // output tool is active, directing the model to call it with the final answer. OutputToolInstruction = "Use available tools to gather information. When ready, only call " + OutputToolName + " with your final answer, do not output any other text." )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶
type Base struct{}
Base provides default no-op implementations of the optional llm.Tool methods. Embed Base in your tool struct to avoid boilerplate; then only override the methods you need.
func (Base) OutputSchema ¶
func (Base) OutputSchema() (*jsonschema.Schema, error)
OutputSchema returns nil, indicating no structured output schema.
type OutputTool ¶
type OutputTool struct {
Base
// contains filtered or unexported fields
}
OutputTool wraps a JSON schema as a tool, allowing the model to produce structured output by "calling" this tool with the desired data. This avoids the conflict in providers like Gemini that don't support function calling combined with a response JSON schema.
func NewOutputTool ¶
func NewOutputTool(s *jsonschema.Schema) *OutputTool
NewOutputTool creates a tool whose parameter schema is the given JSON schema. When the model calls this tool, its arguments ARE the structured output.
func (*OutputTool) Description ¶
func (t *OutputTool) Description() string
func (*OutputTool) InputSchema ¶
func (t *OutputTool) InputSchema() (*jsonschema.Schema, error)
func (*OutputTool) Name ¶
func (t *OutputTool) Name() string
func (*OutputTool) Run ¶
func (t *OutputTool) Run(_ context.Context, input json.RawMessage) (any, error)
func (*OutputTool) Validate ¶
func (t *OutputTool) Validate(data json.RawMessage) error
Validate checks that the given JSON conforms to the output schema. Returns nil if the data is valid or no schema was provided.