- 重命名模块 jwts -> schedule_converter
- 新增 service 包,统一业务逻辑层
- 新增 pkg/logger 包,使用 slog 结构化日志
- 新增 pkg/errors 包,统一错误处理
- 拆分 captcha 包,图片识别移至 service/recognizer
- 清理 models 包,只保留数据结构定义
- 消除 grpc/handler.go 中的重复代码
- 简化 main.go,使用 slog 和 context
- 配置支持单例模式和结构化配置
- 使用 any 替代 interface{}
- 使用 sync.Map 替代 map + RWMutex
39 lines
872 B
Go
39 lines
872 B
Go
package models
|
|
|
|
// APIRequest API请求结构
|
|
type APIRequest struct {
|
|
Model string `json:"model"`
|
|
Messages []Message `json:"messages"`
|
|
MaxTokens int `json:"max_tokens"`
|
|
EnableThinking *bool `json:"enable_thinking,omitempty"`
|
|
ThinkingBudget *int `json:"thinking_budget,omitempty"`
|
|
}
|
|
|
|
// Message 消息结构
|
|
type Message struct {
|
|
Role string `json:"role"`
|
|
Content any `json:"content"`
|
|
}
|
|
|
|
// ContentItem 内容项
|
|
type ContentItem struct {
|
|
Type string `json:"type,omitempty"`
|
|
Text string `json:"text,omitempty"`
|
|
ImageURL *ImageURL `json:"image_url,omitempty"`
|
|
}
|
|
|
|
// ImageURL 图片URL
|
|
type ImageURL struct {
|
|
URL string `json:"url"`
|
|
}
|
|
|
|
// APIResponse API响应结构
|
|
type APIResponse struct {
|
|
Choices []Choice `json:"choices"`
|
|
}
|
|
|
|
// Choice 选择
|
|
type Choice struct {
|
|
Message Message `json:"message"`
|
|
}
|