Documentation
¶
Index ¶
- func NewAnswerChunk(answerChunk *schema.AnswerChunk) *schema.AgentStreamChunk
- func NewDateTimeToolResult(operation string, result string, timezone string) *schema.ToolExecutionResultChunk
- func NewMathToolResult(expression string, result string, steps []string) *schema.ToolExecutionResultChunk
- func NewProgressUpdate(stage schema.Stage, message string, current int32) *schema.AgentStreamChunk
- func NewStreamComplete(status string) *schema.AgentStreamChunk
- func NewStreamError(message, code string) *schema.AgentStreamChunk
- func NewToolExecutionResult(toolName string, result *schema.ToolExecutionResultChunk) *schema.AgentStreamChunk
- func NewToolResult(title string, sentences []string) *schema.ToolExecutionResultChunk
- func NewToolSelectionResult(selectedTool *schema.SelectedTool) *schema.AgentStreamChunk
- type Agent
- func (a *Agent) AddTool(tool MCPTool)
- func (a *Agent) Execute(ctx context.Context, reporter ProgressReporter, ...) (*schema.AnswerChunk, error)
- func (a *Agent) ExecuteTool(ctx context.Context, selection *schema.SelectedTool) <-chan *schema.ToolExecutionResultChunk
- func (a *Agent) GenerateAnswer(ctx context.Context, client llm.LLMClient, modelName, prompt string) (string, error)
- func (a *Agent) GetAvailableTools() []MCPTool
- func (a *Agent) GetToolByName(name string) *MCPTool
- func (a *Agent) SelectTools(ctx context.Context, req ToolSelectionRequest) ([]*schema.SelectedTool, error)
- type AgentConfig
- type GrpcProgressReporter
- type MCPTool
- type NoOpProgressReporter
- type ProgressReporter
- type PromptTemplate
- type ToolSelectionRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAnswerChunk ¶
func NewAnswerChunk(answerChunk *schema.AnswerChunk) *schema.AgentStreamChunk
NewAnswerChunk creates an AnswerChunk
func NewDateTimeToolResult ¶
func NewDateTimeToolResult(operation string, result string, timezone string) *schema.ToolExecutionResultChunk
NewDateTimeToolResult creates a ToolResult for date/time operations
func NewMathToolResult ¶
func NewMathToolResult(expression string, result string, steps []string) *schema.ToolExecutionResultChunk
func NewProgressUpdate ¶
Helper functions for creating progress events
func NewStreamComplete ¶
func NewStreamComplete(status string) *schema.AgentStreamChunk
NewStreamComplete creates a StreamComplete chunk
func NewStreamError ¶
func NewStreamError(message, code string) *schema.AgentStreamChunk
NewStreamError creates a StreamError chunk
func NewToolExecutionResult ¶
func NewToolExecutionResult(toolName string, result *schema.ToolExecutionResultChunk) *schema.AgentStreamChunk
NewToolExecutionResult creates a ToolExecutionResultChunk chunk
func NewToolResult ¶
func NewToolResult(title string, sentences []string) *schema.ToolExecutionResultChunk
NewMathToolResult creates a ToolResult specifically for mathematical calculations
func NewToolSelectionResult ¶
func NewToolSelectionResult(selectedTool *schema.SelectedTool) *schema.AgentStreamChunk
NewToolSelectionResult creates a ToolSelectionResult chunk
Types ¶
type Agent ¶
type Agent struct {
schema.UnimplementedAgentServer
// contains filtered or unexported fields
}
Agent represents the main agent system
func (*Agent) Execute ¶
func (a *Agent) Execute(ctx context.Context, reporter ProgressReporter, req *schema.GenerateAnswerRequest) (*schema.AnswerChunk, error)
GenerateAnswer is the main API to generate answers using tool selection and prompts
func (*Agent) ExecuteTool ¶
func (a *Agent) ExecuteTool(ctx context.Context, selection *schema.SelectedTool) <-chan *schema.ToolExecutionResultChunk
func (*Agent) GenerateAnswer ¶
func (*Agent) GetAvailableTools ¶
GetAvailableTools returns a list of all available tools
func (*Agent) GetToolByName ¶
func (*Agent) SelectTools ¶
func (a *Agent) SelectTools(ctx context.Context, req ToolSelectionRequest) ([]*schema.SelectedTool, error)
SelectTools uses the mini model to intelligently select appropriate tools for a given query
type AgentConfig ¶
type AgentConfig struct {
MiniModel struct {
Client llm.LLMClient
Model string
}
BigModel struct {
Client llm.LLMClient
Model string
}
Tools []MCPTool
Prompt PromptTemplate
MaxTokens int
}
AgentConfig holds configuration for the agent
type GrpcProgressReporter ¶
type GrpcProgressReporter struct {
// contains filtered or unexported fields
}
GrpcProgressReporter implements ProgressReporter for gRPC streaming
func (*GrpcProgressReporter) Send ¶
func (r *GrpcProgressReporter) Send(event *schema.AgentStreamChunk) error
type MCPTool ¶
type MCPTool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]string `json:"parameters"`
// SummarizeContext enables automatic summarization of tool results using the mini model.
// When enabled, each ToolResult's Sentences will be summarized with respect to the user's query.
// Irrelevant content will be filtered out, making this ideal for RAG search and web search tools.
SummarizeContext bool `json:"summarize_context"`
Handler func(ctx context.Context, params map[string]string) <-chan *schema.ToolExecutionResultChunk
}
MCPTool represents a Model Context Protocol tool
type NoOpProgressReporter ¶
type NoOpProgressReporter struct{}
NoOpProgressReporter implements ProgressReporter with no-op operations
func (*NoOpProgressReporter) Send ¶
func (r *NoOpProgressReporter) Send(event *schema.AgentStreamChunk) error
Send does nothing
type ProgressReporter ¶
type ProgressReporter interface {
// Send sends a progress update
Send(event *schema.AgentStreamChunk) error
}
ProgressReporter is an interface for reporting agent execution progress