dev 分支暂存
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Role 消息角色
|
||||
type Role string
|
||||
|
||||
const (
|
||||
RoleSystem Role = "system"
|
||||
RoleUser Role = "user"
|
||||
RoleAssistant Role = "assistant"
|
||||
RoleTool Role = "tool"
|
||||
)
|
||||
|
||||
// LLMMessage 发送给LLM的消息
|
||||
type LLMMessage struct {
|
||||
Role Role `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Name string `json:"name,omitempty"` // 可选发送者名称
|
||||
ToolCallID string `json:"tool_call_id,omitempty"` // 工具调用关联ID
|
||||
}
|
||||
|
||||
// ChatMessage 数据库存储的对话消息
|
||||
type ChatMessage struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
SessionID string `json:"session_id" db:"session_id"`
|
||||
UserID string `json:"user_id" db:"user_id"`
|
||||
Role Role `json:"role" db:"role"`
|
||||
Content string `json:"content" db:"content"`
|
||||
Mode string `json:"mode" db:"mode"` // text | voice_msg | voice_assistant
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
}
|
||||
|
||||
// LLMResponse LLM返回的响应
|
||||
type LLMResponse struct {
|
||||
Content string `json:"content"`
|
||||
FinishReason string `json:"finish_reason"` // stop | length | tool_calls
|
||||
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
||||
Usage Usage `json:"usage,omitempty"`
|
||||
}
|
||||
|
||||
// ToolCall 工具调用
|
||||
type ToolCall struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Arguments string `json:"arguments"`
|
||||
}
|
||||
|
||||
// Usage token用量统计
|
||||
type Usage struct {
|
||||
PromptTokens int `json:"prompt_tokens"`
|
||||
CompletionTokens int `json:"completion_tokens"`
|
||||
TotalTokens int `json:"total_tokens"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user