feat: 重构客户端结构体,增强块、消息、会话和租户模型,并更新API文档

This commit is contained in:
wizardchen
2025-12-02 22:47:13 +08:00
parent f26cbe02e1
commit 12497a2fea
17 changed files with 2728 additions and 46 deletions
+27
View File
@@ -12,6 +12,32 @@ import (
"time"
)
// ToolResult represents the result of a tool execution
type ToolResult struct {
Success bool `json:"success"` // Whether the tool executed successfully
Output string `json:"output"` // Human-readable output
Data map[string]interface{} `json:"data,omitempty"` // Structured data for programmatic use
Error string `json:"error,omitempty"` // Error message if execution failed
}
// ToolCall represents a single tool invocation within an agent step
type ToolCall struct {
ID string `json:"id"` // Function call ID from LLM
Name string `json:"name"` // Tool name
Args map[string]interface{} `json:"args"` // Tool arguments
Result *ToolResult `json:"result"` // Execution result
Reflection string `json:"reflection,omitempty"` // Agent's reflection on this tool call result
Duration int64 `json:"duration"` // Execution time in milliseconds
}
// AgentStep represents one iteration of the ReAct loop
type AgentStep struct {
Iteration int `json:"iteration"` // Iteration number (0-indexed)
Thought string `json:"thought"` // LLM's reasoning/thinking (Think phase)
ToolCalls []ToolCall `json:"tool_calls"` // Tools called in this step (Act phase)
Timestamp time.Time `json:"timestamp"` // When this step occurred
}
// Message message information
type Message struct {
ID string `json:"id"`
@@ -20,6 +46,7 @@ type Message struct {
Content string `json:"content"`
Role string `json:"role"`
KnowledgeReferences []*SearchResult `json:"knowledge_references"`
AgentSteps []AgentStep `json:"agent_steps,omitempty"` // Agent execution steps (only for assistant messages)
IsCompleted bool `json:"is_completed"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`