Documentation
¶
Index ¶
- Constants
- type Agent
- type AgentEngine
- func (ae *AgentEngine) AddTool(tool types.Tool)
- func (ae *AgentEngine) AddTools(tools []types.Tool)
- func (ae *AgentEngine) Execute(input string, previousRequests []types.ToolCallData) (*AgentResult, error)
- func (ae *AgentEngine) ExecuteStream(input string, previousRequests []types.ToolCallData) (<-chan StreamResult, error)
- func (ae *AgentEngine) SetConfig(config *types.AgentConfig)
- func (ae *AgentEngine) SetEnableToolRetry(enable bool)
- func (ae *AgentEngine) SetFrequencyPenalty(penalty float32)
- func (ae *AgentEngine) SetMaxTokens(maxTokens int)
- func (ae *AgentEngine) SetMemory(memory types.MemoryProvider)
- func (ae *AgentEngine) SetOutputParser(parser types.OutputParser)
- func (ae *AgentEngine) SetPresencePenalty(penalty float32)
- func (ae *AgentEngine) SetRateLimiter(limiter ratelimit.RateLimiter)
- func (ae *AgentEngine) SetRetryAttempts(attempts int)
- func (ae *AgentEngine) SetRetryDelay(delay time.Duration)
- func (ae *AgentEngine) SetStopSequences(sequences []string)
- func (ae *AgentEngine) SetTemperature(temperature float32)
- func (ae *AgentEngine) SetTimeout(timeout time.Duration)
- func (ae *AgentEngine) SetTopP(topP float32)
- func (ae *AgentEngine) Stop()
- type AgentResult
- type LangChainAgentEngine
- func (e *LangChainAgentEngine) AddTool(tool types.Tool)
- func (e *LangChainAgentEngine) AddTools(tools []types.Tool)
- func (e *LangChainAgentEngine) BuildAgent() error
- func (e *LangChainAgentEngine) ClearMemory()
- func (e *LangChainAgentEngine) Execute(input string, previousRequests []types.ToolCallData) (*AgentResult, error)
- func (e *LangChainAgentEngine) ExecuteSimple(input string) (string, error)
- func (e *LangChainAgentEngine) ExecuteStream(input string, previousRequests []types.ToolCallData) (<-chan StreamResult, error)
- func (e *LangChainAgentEngine) ExecuteStreamSimple(input string) (<-chan string, error)
- func (e *LangChainAgentEngine) GetMemory() []types.Message
- func (e *LangChainAgentEngine) SetConfig(config *types.AgentConfig)
- func (e *LangChainAgentEngine) SetEnableToolRetry(enable bool)
- func (e *LangChainAgentEngine) SetFrequencyPenalty(penalty float32)
- func (e *LangChainAgentEngine) SetMaxTokens(maxTokens int)
- func (e *LangChainAgentEngine) SetMemory(memory types.MemoryProvider)
- func (e *LangChainAgentEngine) SetOutputParser(parser types.OutputParser)
- func (e *LangChainAgentEngine) SetPresencePenalty(penalty float32)
- func (e *LangChainAgentEngine) SetRateLimiter(limiter ratelimit.RateLimiter)
- func (e *LangChainAgentEngine) SetRetryAttempts(attempts int)
- func (e *LangChainAgentEngine) SetRetryDelay(delay time.Duration)
- func (e *LangChainAgentEngine) SetStopSequences(sequences []string)
- func (e *LangChainAgentEngine) SetTemperature(temperature float32)
- func (e *LangChainAgentEngine) SetTimeout(timeout time.Duration)
- func (e *LangChainAgentEngine) SetTools(tools []types.Tool)
- func (e *LangChainAgentEngine) SetTopP(topP float32)
- func (e *LangChainAgentEngine) Stop()
- type StreamResult
Constants ¶
const ( // Cache-related constants DefaultCacheSize = 100 // default tool cache size CacheExpirationTime = 5 * time.Minute // cache expiration time // Execution-related constants DefaultChannelBuffer = 50 // default channel buffer size MaxTruncationLength = 2048 // maximum truncation length MinChannelBuffer = 10 // minimum channel buffer size // Performance-related constants DefaultBufferPoolSize = 1024 // default buffer pool size (1KB) IterationDelay = 100 * time.Millisecond // inter-iteration delay )
Constant definitions
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
// Configuration setting methods
SetMemory(memory types.MemoryProvider)
SetOutputParser(parser types.OutputParser)
SetTemperature(temperature float32)
SetMaxTokens(maxTokens int)
SetTopP(topP float32)
SetFrequencyPenalty(penalty float32)
SetPresencePenalty(penalty float32)
SetStopSequences(sequences []string)
SetTimeout(timeout time.Duration)
SetRetryAttempts(attempts int)
SetRetryDelay(delay time.Duration)
SetEnableToolRetry(enable bool)
SetConfig(config *types.AgentConfig)
SetRateLimiter(limiter ratelimit.RateLimiter)
// Tool management methods
AddTool(tool types.Tool)
AddTools(tools []types.Tool)
// Execution methods
Execute(input string, previousRequests []types.ToolCallData) (*AgentResult, error)
ExecuteStream(input string, previousRequests []types.ToolCallData) (<-chan StreamResult, error)
// Lifecycle management
Stop()
}
Agent agent engine interface
func NewAgent ¶
func NewAgent(model types.LLMProvider, config *types.AgentConfig) Agent
NewAgent creates a new agent instance (via interface)
func NewLangChainAgent ¶
func NewLangChainAgent(llm types.LLMProvider, systemPrompt string) Agent
NewLangChainAgent creates a new LangChain agent instance (via interface)
type AgentEngine ¶
type AgentEngine struct {
// contains filtered or unexported fields
}
AgentEngine agent engine Provides intelligent agent functionality with tool calling, streaming, caching, and memory systems
func NewAgentEngine ¶
func NewAgentEngine(model types.LLMProvider, config *types.AgentConfig) *AgentEngine
NewAgentEngine creates a new agent engine Parameters:
- model: LLM model provider
- config: agent configuration (if nil, uses default configuration)
Returns:
- initialized AgentEngine instance
func (*AgentEngine) AddTools ¶
func (ae *AgentEngine) AddTools(tools []types.Tool)
AddTools adds multiple tools
func (*AgentEngine) Execute ¶
func (ae *AgentEngine) Execute(input string, previousRequests []types.ToolCallData) (*AgentResult, error)
Execute executes the agent task (supports multi-round iteration) Processes user input with tool calling and multi-round iteration, returning the complete execution result Parameters:
- input: user input text
- previousRequests: previous tool call request history
Returns:
- execution result containing output, tool calls, and intermediate steps
- error information
func (*AgentEngine) ExecuteStream ¶
func (ae *AgentEngine) ExecuteStream(input string, previousRequests []types.ToolCallData) (<-chan StreamResult, error)
ExecuteStream executes the agent task with streaming (supports multi-round iteration) Processes user input with real-time streaming output and multi-round tool calling Parameters:
- input: user input text
- previousRequests: previous tool call request history
Returns:
- streaming result channel for real-time content delivery during execution
- error information (only during initialization)
func (*AgentEngine) SetConfig ¶
func (ae *AgentEngine) SetConfig(config *types.AgentConfig)
SetConfig sets the complete configuration
func (*AgentEngine) SetEnableToolRetry ¶
func (ae *AgentEngine) SetEnableToolRetry(enable bool)
SetEnableToolRetry sets whether to enable tool retry
func (*AgentEngine) SetFrequencyPenalty ¶
func (ae *AgentEngine) SetFrequencyPenalty(penalty float32)
SetFrequencyPenalty sets frequency penalty
func (*AgentEngine) SetMaxTokens ¶
func (ae *AgentEngine) SetMaxTokens(maxTokens int)
SetMaxTokens sets the maximum tokens
func (*AgentEngine) SetMemory ¶
func (ae *AgentEngine) SetMemory(memory types.MemoryProvider)
SetMemory sets the memory system
func (*AgentEngine) SetOutputParser ¶
func (ae *AgentEngine) SetOutputParser(parser types.OutputParser)
SetOutputParser sets the output parser
func (*AgentEngine) SetPresencePenalty ¶
func (ae *AgentEngine) SetPresencePenalty(penalty float32)
SetPresencePenalty sets presence penalty
func (*AgentEngine) SetRateLimiter ¶ added in v1.4.7
func (ae *AgentEngine) SetRateLimiter(limiter ratelimit.RateLimiter)
SetRateLimiter sets the rate limiter
func (*AgentEngine) SetRetryAttempts ¶
func (ae *AgentEngine) SetRetryAttempts(attempts int)
SetRetryAttempts sets retry attempts
func (*AgentEngine) SetRetryDelay ¶
func (ae *AgentEngine) SetRetryDelay(delay time.Duration)
SetRetryDelay sets retry delay
func (*AgentEngine) SetStopSequences ¶
func (ae *AgentEngine) SetStopSequences(sequences []string)
SetStopSequences sets stop sequences
func (*AgentEngine) SetTemperature ¶
func (ae *AgentEngine) SetTemperature(temperature float32)
SetTemperature sets the temperature parameter
func (*AgentEngine) SetTimeout ¶
func (ae *AgentEngine) SetTimeout(timeout time.Duration)
SetTimeout sets timeout duration
func (*AgentEngine) SetTopP ¶
func (ae *AgentEngine) SetTopP(topP float32)
SetTopP sets Top P sampling
func (*AgentEngine) Stop ¶
func (ae *AgentEngine) Stop()
Stop stops the agent engine Safely stops the agent engine and releases resources
type AgentResult ¶
type AgentResult struct {
Output string `json:"output"`
ToolCalls []types.ToolCallRequest `json:"tool_calls"`
IntermediateSteps []types.ToolCallData `json:"intermediate_steps"`
}
AgentResult agent execution result
type LangChainAgentEngine ¶
type LangChainAgentEngine struct {
// contains filtered or unexported fields
}
LangChainAgentEngine LangChain agent engine
func NewLangChainAgentEngine ¶
func NewLangChainAgentEngine(llm types.LLMProvider, systemPrompt string) *LangChainAgentEngine
NewLangChainAgentEngine creates a new LangChain agent engine
func (*LangChainAgentEngine) AddTool ¶
func (e *LangChainAgentEngine) AddTool(tool types.Tool)
AddTool adds a tool
func (*LangChainAgentEngine) AddTools ¶
func (e *LangChainAgentEngine) AddTools(tools []types.Tool)
AddTools adds tools in batch
func (*LangChainAgentEngine) BuildAgent ¶
func (e *LangChainAgentEngine) BuildAgent() error
BuildAgent builds the agent (simplified version)
func (*LangChainAgentEngine) ClearMemory ¶
func (e *LangChainAgentEngine) ClearMemory()
ClearMemory clears memory
func (*LangChainAgentEngine) Execute ¶
func (e *LangChainAgentEngine) Execute(input string, previousRequests []types.ToolCallData) (*AgentResult, error)
Execute executes the agent (implements Agent interface)
func (*LangChainAgentEngine) ExecuteSimple ¶
func (e *LangChainAgentEngine) ExecuteSimple(input string) (string, error)
ExecuteSimple simple execution method (for backward compatibility)
func (*LangChainAgentEngine) ExecuteStream ¶
func (e *LangChainAgentEngine) ExecuteStream(input string, previousRequests []types.ToolCallData) (<-chan StreamResult, error)
ExecuteStream streams agent execution (implements Agent interface)
func (*LangChainAgentEngine) ExecuteStreamSimple ¶
func (e *LangChainAgentEngine) ExecuteStreamSimple(input string) (<-chan string, error)
ExecuteStreamSimple simple streaming execution (for backward compatibility)
func (*LangChainAgentEngine) GetMemory ¶
func (e *LangChainAgentEngine) GetMemory() []types.Message
GetMemory gets memory
func (*LangChainAgentEngine) SetConfig ¶
func (e *LangChainAgentEngine) SetConfig(config *types.AgentConfig)
SetConfig sets complete configuration
func (*LangChainAgentEngine) SetEnableToolRetry ¶
func (e *LangChainAgentEngine) SetEnableToolRetry(enable bool)
SetEnableToolRetry sets whether to enable tool retry
func (*LangChainAgentEngine) SetFrequencyPenalty ¶
func (e *LangChainAgentEngine) SetFrequencyPenalty(penalty float32)
SetFrequencyPenalty sets frequency penalty
func (*LangChainAgentEngine) SetMaxTokens ¶
func (e *LangChainAgentEngine) SetMaxTokens(maxTokens int)
SetMaxTokens sets maximum tokens
func (*LangChainAgentEngine) SetMemory ¶
func (e *LangChainAgentEngine) SetMemory(memory types.MemoryProvider)
SetMemory sets memory system (LangChain engine uses internal memory management)
func (*LangChainAgentEngine) SetOutputParser ¶
func (e *LangChainAgentEngine) SetOutputParser(parser types.OutputParser)
SetOutputParser sets output parser
func (*LangChainAgentEngine) SetPresencePenalty ¶
func (e *LangChainAgentEngine) SetPresencePenalty(penalty float32)
SetPresencePenalty sets presence penalty
func (*LangChainAgentEngine) SetRateLimiter ¶ added in v1.4.7
func (e *LangChainAgentEngine) SetRateLimiter(limiter ratelimit.RateLimiter)
SetRateLimiter sets the rate limiter (not implemented for LangChain engine)
func (*LangChainAgentEngine) SetRetryAttempts ¶
func (e *LangChainAgentEngine) SetRetryAttempts(attempts int)
SetRetryAttempts sets retry attempts
func (*LangChainAgentEngine) SetRetryDelay ¶
func (e *LangChainAgentEngine) SetRetryDelay(delay time.Duration)
SetRetryDelay sets retry delay
func (*LangChainAgentEngine) SetStopSequences ¶
func (e *LangChainAgentEngine) SetStopSequences(sequences []string)
SetStopSequences sets stop sequences
func (*LangChainAgentEngine) SetTemperature ¶
func (e *LangChainAgentEngine) SetTemperature(temperature float32)
SetTemperature sets temperature parameter
func (*LangChainAgentEngine) SetTimeout ¶
func (e *LangChainAgentEngine) SetTimeout(timeout time.Duration)
SetTimeout sets timeout duration
func (*LangChainAgentEngine) SetTools ¶
func (e *LangChainAgentEngine) SetTools(tools []types.Tool)
SetTools sets tools
func (*LangChainAgentEngine) SetTopP ¶
func (e *LangChainAgentEngine) SetTopP(topP float32)
SetTopP sets Top P sampling
func (*LangChainAgentEngine) Stop ¶
func (e *LangChainAgentEngine) Stop()
Stop stops the agent engine (LangChain engine requires no special stop operation)
type StreamResult ¶
type StreamResult struct {
Type string
Content string
Result *AgentResult
Error error
}
StreamResult streaming result