Documentation
¶
Index ¶
- func ParseModelName(modelString string) (provider, model string)
- func StreamWithCallback(ctx context.Context, reader *schema.StreamReader[*schema.Message], ...) (*schema.Message, error)
- type Agent
- func (a *Agent) Close() error
- func (a *Agent) GenerateWithLoop(ctx context.Context, messages []*schema.Message, onToolCall ToolCallHandler, ...) (*GenerateWithLoopResult, error)
- func (a *Agent) GenerateWithLoopAndStreaming(ctx context.Context, messages []*schema.Message, onToolCall ToolCallHandler, ...) (*GenerateWithLoopResult, error)
- func (a *Agent) GetLoadedServerNames() []string
- func (a *Agent) GetLoadingMessage() string
- func (a *Agent) GetTools() []tool.BaseTool
- type AgentConfig
- type AgentCreationOptions
- type GenerateWithLoopResult
- type ResponseHandler
- type SpinnerFunc
- type StreamingResponseHandler
- type ToolCallContentHandler
- type ToolCallHandler
- type ToolExecutionHandler
- type ToolResultHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseModelName ¶ added in v0.19.0
ParseModelName extracts provider and model name from model string
func StreamWithCallback ¶ added in v0.18.0
func StreamWithCallback(ctx context.Context, reader *schema.StreamReader[*schema.Message], callback func(string)) (*schema.Message, error)
StreamWithCallback streams content with real-time callbacks and returns complete response IMPORTANT: Tool calls are only processed after EOF is reached to ensure we have the complete and final tool call information. This prevents premature tool execution on partial data. Handles different provider streaming patterns: - Anthropic: Text content first, then tool calls streamed incrementally - OpenAI/Others: Tool calls first or alone - Mixed: Tool calls and content interleaved
Types ¶
type Agent ¶ added in v0.10.0
type Agent struct {
// contains filtered or unexported fields
}
Agent is the agent with real-time tool call display.
func CreateAgent ¶ added in v0.19.0
func CreateAgent(ctx context.Context, opts *AgentCreationOptions) (*Agent, error)
CreateAgent creates an agent with optional spinner for Ollama models
func NewAgent ¶ added in v0.10.0
func NewAgent(ctx context.Context, config *AgentConfig) (*Agent, error)
NewAgent creates an agent with MCP tool integration and real-time tool call display
func (*Agent) GenerateWithLoop ¶ added in v0.10.0
func (a *Agent) GenerateWithLoop(ctx context.Context, messages []*schema.Message, onToolCall ToolCallHandler, onToolExecution ToolExecutionHandler, onToolResult ToolResultHandler, onResponse ResponseHandler, onToolCallContent ToolCallContentHandler) (*GenerateWithLoopResult, error)
GenerateWithLoop processes messages with a custom loop that displays tool calls in real-time
func (*Agent) GenerateWithLoopAndStreaming ¶ added in v0.18.0
func (a *Agent) GenerateWithLoopAndStreaming(ctx context.Context, messages []*schema.Message, onToolCall ToolCallHandler, onToolExecution ToolExecutionHandler, onToolResult ToolResultHandler, onResponse ResponseHandler, onToolCallContent ToolCallContentHandler, onStreamingResponse StreamingResponseHandler) (*GenerateWithLoopResult, error)
GenerateWithLoopAndStreaming processes messages with a custom loop that displays tool calls in real-time and supports streaming callbacks
func (*Agent) GetLoadedServerNames ¶ added in v0.19.0
GetLoadedServerNames returns the names of successfully loaded MCP servers
func (*Agent) GetLoadingMessage ¶ added in v0.18.0
GetLoadingMessage returns the loading message from provider creation (e.g., GPU fallback info)
type AgentConfig ¶ added in v0.10.0
type AgentConfig struct { ModelConfig *models.ProviderConfig MCPConfig *config.Config SystemPrompt string MaxSteps int StreamingEnabled bool DebugLogger tools.DebugLogger // Optional debug logger }
AgentConfig is the config for agent.
type AgentCreationOptions ¶ added in v0.19.0
type AgentCreationOptions struct { ModelConfig *models.ProviderConfig MCPConfig *config.Config SystemPrompt string MaxSteps int StreamingEnabled bool ShowSpinner bool // For Ollama models Quiet bool // Skip spinner if quiet SpinnerFunc SpinnerFunc // Function to show spinner (provided by caller) DebugLogger tools.DebugLogger // Optional debug logger }
AgentCreationOptions contains options for creating an agent
type GenerateWithLoopResult ¶ added in v0.17.0
type GenerateWithLoopResult struct { FinalResponse *schema.Message ConversationMessages []*schema.Message // All messages in the conversation (including tool calls and results) }
GenerateWithLoopResult contains the result and conversation history
type ResponseHandler ¶ added in v0.10.0
type ResponseHandler func(content string)
ResponseHandler is a function type for handling LLM responses
type SpinnerFunc ¶ added in v0.19.0
SpinnerFunc is a function type for showing spinners during agent creation
type StreamingResponseHandler ¶ added in v0.18.0
type StreamingResponseHandler func(content string)
StreamingResponseHandler is a function type for handling streaming LLM responses
type ToolCallContentHandler ¶ added in v0.10.0
type ToolCallContentHandler func(content string)
ToolCallContentHandler is a function type for handling content that accompanies tool calls
type ToolCallHandler ¶ added in v0.10.0
type ToolCallHandler func(toolName, toolArgs string)
ToolCallHandler is a function type for handling tool calls as they happen
type ToolExecutionHandler ¶ added in v0.11.0
ToolExecutionHandler is a function type for handling tool execution start/end
type ToolResultHandler ¶ added in v0.10.0
ToolResultHandler is a function type for handling tool results