Documentation
¶
Overview ¶
Command tools runs a streaming tool loop with reasoning: the model thinks, optionally calls a typed tool, sees the result, and continues until it gives a final answer.
It combines the pieces the agent package automates into one loop:
- MustTool derives a JSON Schema from a Go struct.
- Stream with Reasoning surfaces the model's thinking (EventThinking*) and answer (EventText*) live, turn by turn.
- EventDone carries the final assistant message; DecodeToolCall validates and decodes any tool calls, and ToolResult feeds each outcome back.
Wrap this loop with state, steering, and persistence and you have an agent.
The API key is read from the provider's environment variable when StreamOptions.APIKey is empty:
DEEPSEEK_API_KEY=sk-... go run ./example/llm/tools
Click to show internal directories.
Click to hide internal directories.