tools

command
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 5 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL