Files
Cyrene/backend/ai-core/internal/model/message.go
T
AskaEth 9a8fb8d0ce feat: Phase 6.3 视觉理解 — 多模态图片输入 + OCR/Vision 工具 + 图片编码管线
- LLMMessage 新增 Images 字段支持多模态 content array
- OpenAIProvider 支持 image_url content parts
- VisionTool: 图片读取 + base64 编码 + OCR/场景描述/综合分析
- 对话管道全线支持 images 参数传递 (Gateway->Orchestrator->Synthesizer->LLM)
- 自动根据图片有无构建 text-only 或 multimodal content

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 22:28:42 +08:00

72 lines
2.4 KiB
Go

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"`
Images []string `json:"images,omitempty"` // 图片 base64 data URL 列表 (多模态)
Name string `json:"name,omitempty"` // 可选发送者名称
ToolCallID string `json:"tool_call_id,omitempty"` // 工具调用关联ID (tool role 消息关联调用)
ToolCalls []ToolCall `json:"tool_calls,omitempty"` // 助手消息中的工具调用列表
ReasoningContent string `json:"reasoning_content,omitempty"` // DeepSeek 思考链内容(需回传)
}
// ImageContent is a multimodal content part for images.
type ImageContent struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *ImageURL `json:"image_url,omitempty"`
}
// ImageURL holds an image URL (can be a data: URL or http: URL).
type ImageURL struct {
URL string `json:"url"`
Detail string `json:"detail,omitempty"` // low, high, auto
}
// 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"`
ReasoningContent string `json:"reasoning_content,omitempty"` // DeepSeek 思考链内容
}
// 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"`
}