Documentation
¶
Index ¶
- type ActionMetadata
- type ActionResponse
- type AgentConfig
- type EngineRequest
- type EngineResponse
- type ImageDataPart
- type ImageURLPart
- type LLMProvider
- type LangChainToolWrapper
- type MemoryProvider
- type Message
- type MessagePart
- type ModelMetadata
- type OutputParser
- type RequestResponseMetadata
- type StreamEvent
- type StreamMessage
- type TextPart
- type Tool
- type ToolAction
- type ToolActionStep
- type ToolCall
- type ToolCallData
- type ToolCallRequest
- type ToolFunction
- type ToolMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionMetadata ¶
type ActionMetadata struct {
ItemIndex int `json:"itemIndex"`
}
ActionMetadata action metadata
type ActionResponse ¶
type ActionResponse struct {
Action *ToolAction `json:"action"`
Data interface{} `json:"data"`
Error string `json:"error,omitempty"`
}
ActionResponse action response
type AgentConfig ¶
type AgentConfig struct {
MaxIterations int `json:"maxIterations"`
SystemMessage string `json:"systemMessage"`
Temperature float32 `json:"temperature"` // 温度参数 (0.0-1.0)
MaxTokens int `json:"maxTokens"` // 最大token数
TopP float32 `json:"topP"` // Top P采样
FrequencyPenalty float32 `json:"frequencyPenalty"` // 频率惩罚
PresencePenalty float32 `json:"presencePenalty"` // 存在惩罚
StopSequences []string `json:"stopSequences"` // 停止序列
Timeout time.Duration `json:"timeout"` // 超时时间
ToolExecutionTimeout time.Duration `json:"toolExecutionTimeout"` // 工具执行超时时间
RetryAttempts int `json:"retryAttempts"` // 重试次数
RetryDelay time.Duration `json:"retryDelay"` // 重试延迟
EnableToolRetry bool `json:"enableToolRetry"` // 启用工具重试
MaxHistoryMessages int `json:"maxHistoryMessages"` // 最大历史消息数
EnableMemoryCompress bool `json:"enableMemoryCompress"` // 启用记忆压缩
MemoryCompressThreshold int `json:"memoryCompressThreshold"` // 记忆压缩阈值(消息数量)
MemoryCompressRatio float32 `json:"memoryCompressRatio"` // 记忆压缩比例(0.0-1.0)
}
AgentConfig agent configuration
func NewAgentConfig ¶
func NewAgentConfig() *AgentConfig
NewAgentConfig creates a new agent configuration with reasonable defaults
type EngineRequest ¶
type EngineRequest struct {
Actions []ToolAction `json:"actions"`
Metadata RequestResponseMetadata `json:"metadata"`
}
EngineRequest engine request
type EngineResponse ¶
type EngineResponse struct {
ActionResponses []ActionResponse `json:"actionResponses"`
Metadata RequestResponseMetadata `json:"metadata"`
}
EngineResponse engine response
type ImageDataPart ¶
ImageDataPart image data part
type ImageURLPart ¶
type ImageURLPart struct {
URL string `json:"url"`
Detail string `json:"detail,omitempty"` // "low", "high", "auto"
}
ImageURLPart image URL part
type LLMProvider ¶
type LLMProvider interface {
// Basic chat functionality
Chat(messages []Message) (Message, error)
ChatStream(messages []Message) (<-chan StreamMessage, error)
// Tool call support
ChatWithTools(messages []Message, tools []Tool) (Message, error)
ChatWithToolsStream(messages []Message, tools []Tool) (<-chan StreamMessage, error)
// Model information
GetModelName() string
GetModelMetadata() ModelMetadata
}
LLMProvider defines LLM provider interface
type LangChainToolWrapper ¶
type LangChainToolWrapper struct {
// contains filtered or unexported fields
}
LangChainToolWrapper LangChain tool wrapper
func NewLangChainToolWrapper ¶
func NewLangChainToolWrapper(tool Tool) *LangChainToolWrapper
NewLangChainToolWrapper creates a new LangChain tool wrapper
func (*LangChainToolWrapper) Description ¶
func (w *LangChainToolWrapper) Description() string
Description returns tool description
func (*LangChainToolWrapper) Name ¶
func (w *LangChainToolWrapper) Name() string
Name returns tool name
type MemoryProvider ¶
type MemoryProvider interface {
// Load memory variables
LoadMemoryVariables() (map[string]interface{}, error)
// Save context
SaveContext(input, output map[string]interface{}) error
// Clear memory
Clear() error
// Get chat history
GetChatHistory() ([]Message, error)
// Compress memory (optional, for memory compression)
CompressMemory(llm LLMProvider, maxMessages int) error
}
MemoryProvider memory system interface
type Message ¶
type Message struct {
Role string `json:"role"` // "system", "user", "assistant", "tool"
Content string `json:"content"`
Name string `json:"name,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Parts []MessagePart `json:"parts,omitempty"` // Multi-modal content support
}
Message message structure
type MessagePart ¶
type MessagePart interface {
// contains filtered or unexported methods
}
MessagePart message part interface
type ModelMetadata ¶
type ModelMetadata struct {
Name string `json:"name"`
Version string `json:"version"`
MaxTokens int `json:"maxTokens"`
Tools []Tool `json:"tools,omitempty"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
ModelMetadata model metadata
type OutputParser ¶
type OutputParser interface {
Parse(output string) (interface{}, error)
GetFormatInstructions() string
}
OutputParser output parser interface
type RequestResponseMetadata ¶
type RequestResponseMetadata struct {
ItemIndex int `json:"itemIndex,omitempty"`
PreviousRequests []ToolCallData `json:"previousRequests,omitempty"`
IterationCount int `json:"iterationCount,omitempty"`
}
RequestResponseMetadata request response metadata
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
Content string `json:"content,omitempty"`
ToolResult interface{} `json:"toolResult,omitempty"`
EventName string `json:"eventName,omitempty"`
Data interface{} `json:"data,omitempty"`
}
StreamEvent stream event
type StreamMessage ¶
type StreamMessage struct {
Type string `json:"type"` // "chunk", "end", "error", "tool_calls"
Content string `json:"content,omitempty"`
Error string `json:"error,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
StreamMessage streaming message
type Tool ¶
type Tool interface {
// Tool basic information
Name() string
Description() string
Schema() map[string]interface{}
// Tool execution
Execute(input map[string]interface{}) (interface{}, error)
// Tool metadata
Metadata() ToolMetadata
}
Tool defines tool interface
type ToolAction ¶
type ToolAction struct {
NodeName string `json:"nodeName"`
Input map[string]interface{} `json:"input"`
Type string `json:"type"`
ID string `json:"id"`
Metadata ActionMetadata `json:"metadata"`
}
ToolAction tool action
type ToolActionStep ¶
type ToolActionStep struct {
Tool string `json:"tool"`
ToolInput interface{} `json:"toolInput"`
Log interface{} `json:"log"`
ToolCallID interface{} `json:"toolCallId"`
Type interface{} `json:"type"`
}
ToolActionStep tool action step
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
ToolCall tool call
type ToolCallData ¶
type ToolCallData struct {
Action ToolActionStep `json:"action"`
Observation string `json:"observation"`
}
ToolCallData tool call data
type ToolCallRequest ¶
type ToolCallRequest struct {
Tool string `json:"tool"`
ToolInput map[string]interface{} `json:"toolInput"`
ToolCallID string `json:"toolCallId"`
Type string `json:"type,omitempty"`
Log string `json:"log,omitempty"`
MessageLog []interface{} `json:"messageLog,omitempty"`
}
ToolCallRequest tool call request
type ToolFunction ¶
type ToolFunction struct {
Name string `json:"name"`
Arguments map[string]interface{} `json:"arguments"`
}
ToolFunction tool function
type ToolMetadata ¶
type ToolMetadata struct {
SourceNodeName string `json:"sourceNodeName"`
IsFromToolkit bool `json:"isFromToolkit"`
ToolType string `json:"toolType"` // "mcp","http","builtin"
Priority int `json:"priority,omitempty"` // 优先级,数字越大优先级越高
Dependencies []string `json:"dependencies,omitempty"` // 依赖的工具名称列表
MaxTruncationLength int `json:"maxTruncationLength,omitempty"` // 工具结果截断长度,0表示使用默认值
Extra map[string]interface{} `json:"extra,omitempty"`
}
ToolMetadata tool metadata