feat: 新增Model管理模块
- 添加 Model 实体定义 - 实现 Model CRUD 接口 - 添加 Model 仓储层和服务层 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
69
server/internal/model/model_info.go
Normal file
69
server/internal/model/model_info.go
Normal file
@@ -0,0 +1,69 @@
|
||||
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 string `json:"status" gorm:"type:varchar(20);default:active"` // active/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"`
|
||||
}
|
||||
|
||||
// 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 string `json:"status"`
|
||||
}
|
||||
|
||||
// TestModelRequest 测试模型连接请求
|
||||
type TestModelRequest struct {
|
||||
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"`
|
||||
}
|
||||
|
||||
// TestModelResponse 测试模型连接响应
|
||||
type TestModelResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
Reference in New Issue
Block a user