- 新增chat_sessions和chat_groups数据库表 - 更新skill_handler和model相关接口 - 修改main.go注册新路由 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
2.6 KiB
Go
72 lines
2.6 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// ModelInfo 模型信息
|
|
type ModelInfo struct {
|
|
ID string `json:"id" gorm:"primaryKey;type:varchar(36)"`
|
|
Name string `json:"name" gorm:"type:varchar(255);not null"`
|
|
ModelType string `json:"model_type" gorm:"type:varchar(50);not null"` // chat/embedding/rerank/vlm
|
|
Provider string `json:"provider" gorm:"type:varchar(50);not null"` // OpenAI/Ollama
|
|
Model string `json:"model" gorm:"type:varchar(255);not null"` // 模型标识
|
|
APIKey string `json:"api_key" gorm:"type:text"` // API 密钥
|
|
BaseURL string `json:"base_url" gorm:"type:varchar(500)"` // 基础 URL
|
|
APIEndpoint string `json:"api_endpoint" gorm:"type:varchar(500)"` // API 端点路径
|
|
Status int `json:"status" gorm:"type:tinyint;default:0"` // 1:active, 0:inactive
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (ModelInfo) TableName() string {
|
|
return "model_info"
|
|
}
|
|
|
|
// ModelListRequest 获取模型列表请求
|
|
type ModelListRequest struct {
|
|
}
|
|
|
|
// ModelListResponse 获取模型列表响应
|
|
type ModelListResponse struct {
|
|
List []ModelInfo `json:"list"`
|
|
}
|
|
|
|
// CreateModelRequest 创建模型请求
|
|
type CreateModelRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
ModelType string `json:"model_type" binding:"required"`
|
|
Provider string `json:"provider" binding:"required"`
|
|
Model string `json:"model" binding:"required"`
|
|
APIKey string `json:"api_key" binding:"required"`
|
|
BaseURL string `json:"base_url" binding:"required"`
|
|
APIEndpoint string `json:"api_endpoint"`
|
|
Status int `json:"status"`
|
|
}
|
|
|
|
// UpdateModelRequest 更新模型请求
|
|
type UpdateModelRequest struct {
|
|
Name string `json:"name"`
|
|
ModelType string `json:"model_type"`
|
|
Provider string `json:"provider"`
|
|
Model string `json:"model"`
|
|
APIKey string `json:"api_key"`
|
|
BaseURL string `json:"base_url"`
|
|
APIEndpoint string `json:"api_endpoint"`
|
|
Status int `json:"status"`
|
|
}
|
|
|
|
// TestModelRequest 测试模型连接请求
|
|
type TestModelRequest struct {
|
|
Provider string `json:"provider" binding:"required"`
|
|
Model string `json:"model" binding:"required"`
|
|
ModelType string `json:"model_type" binding:"required"`
|
|
APIKey string `json:"api_key" binding:"required"`
|
|
BaseURL string `json:"base_url" binding:"required"`
|
|
APIEndpoint string `json:"api_endpoint"`
|
|
}
|
|
|
|
// TestModelResponse 测试模型连接响应
|
|
type TestModelResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
}
|