ai_config.go 1.7 KB

12345678910111213141516171819202122232425
  1. package models
  2. import (
  3. "time"
  4. )
  5. // AIConfig AI 配置模型
  6. // 支持多种模型类型(文本、图片、语音、视频)和不同的协议路径
  7. type AIConfig struct {
  8. ID uint `json:"id" gorm:"primaryKey"`
  9. UserID uint `json:"user_id"` // 配置所属的用户(管理员)
  10. Provider string `json:"provider" gorm:"type:varchar(50)"` // 服务提供商(如:openai、claude、custom,仅用于标识)
  11. APIURL string `json:"api_url" gorm:"type:varchar(500)"` // API 地址(支持不同的协议路径)
  12. APIKey string `json:"api_key" gorm:"type:varchar(1000)"` // API Key(加密存储)
  13. Model string `json:"model" gorm:"type:varchar(100)"` // 模型名称(如:gpt-3.5-turbo、gpt-4)
  14. ModelType string `json:"model_type" gorm:"type:varchar(20);default:'text'"` // 模型类型:text、image、audio、video
  15. IsActive bool `json:"is_active" gorm:"default:true"` // 是否启用(服务商级别)
  16. IsPublic bool `json:"is_public" gorm:"default:false"` // 是否开放给访客使用(模型级别)
  17. Description string `json:"description" gorm:"type:varchar(500)"` // 配置描述
  18. // 可选的适配参数(JSON 格式,用于适配不同服务商的细微差异)
  19. // 例如:{"auth_header": "X-API-Key", "response_path": "data.choices[0].message.content"}
  20. AdapterConfig string `json:"adapter_config" gorm:"type:text"` // 适配器配置(JSON 格式)
  21. CreatedAt time.Time `json:"created_at"`
  22. UpdatedAt time.Time `json:"updated_at"`
  23. }