🎨 优化扩展模块,完成ai接入和对话功能

This commit is contained in:
2026-02-12 23:12:28 +08:00
parent 4e611d3a5e
commit 572f3aa15b
779 changed files with 194400 additions and 3136 deletions

View File

@@ -6,14 +6,21 @@ import (
)
// AIProvider AI 服务提供商配置
// 每个用户可以配置多个 AI 提供商(如 OpenAI、Claude、Gemini 等)
// UserID 为 NULL 表示系统预设的提供商配置
type AIProvider struct {
global.GVA_MODEL
UserID *uint `json:"userId" gorm:"index;comment:用户IDNULL表示系统配置"`
User *AppUser `json:"user" gorm:"foreignKey:UserID"`
User *AppUser `json:"user,omitempty" gorm:"foreignKey:UserID"`
ProviderName string `json:"providerName" gorm:"type:varchar(100);not null;index;comment:提供商名称"`
APIConfig datatypes.JSON `json:"apiConfig" gorm:"type:jsonb;not null;comment:API配置加密存储"`
ProviderType string `json:"providerType" gorm:"type:varchar(50);not null;default:openai;comment:提供商类型(openai/claude/gemini/custom)"`
BaseURL string `json:"baseUrl" gorm:"type:varchar(500);comment:API基础地址"`
APIKey string `json:"-" gorm:"type:varchar(500);comment:API密钥加密存储"`
APIConfig datatypes.JSON `json:"apiConfig" gorm:"type:jsonb;comment:额外API配置"`
Capabilities datatypes.JSON `json:"capabilities" gorm:"type:jsonb;comment:支持的能力(chat/image_gen等)"`
IsEnabled bool `json:"isEnabled" gorm:"default:true;comment:是否启用"`
IsDefault bool `json:"isDefault" gorm:"default:false;comment:是否为默认提供商"`
SortOrder int `json:"sortOrder" gorm:"default:0;comment:排序权重"`
}
func (AIProvider) TableName() string {
@@ -21,12 +28,14 @@ func (AIProvider) TableName() string {
}
// AIModel AI 模型配置
// 每个提供商下可以有多个模型(如 gpt-4o、gpt-4o-mini 等)
type AIModel struct {
global.GVA_MODEL
ProviderID uint `json:"providerId" gorm:"not null;index;comment:提供商ID"`
Provider *AIProvider `json:"provider" gorm:"foreignKey:ProviderID"`
ModelName string `json:"modelName" gorm:"type:varchar(200);not null;comment:模型名称"`
Provider *AIProvider `json:"provider,omitempty" gorm:"foreignKey:ProviderID"`
ModelName string `json:"modelName" gorm:"type:varchar(200);not null;comment:模型标识API调用用"`
DisplayName string `json:"displayName" gorm:"type:varchar(200);comment:模型显示名称"`
ModelType string `json:"modelType" gorm:"type:varchar(50);not null;default:chat;comment:模型类型(chat/image_gen)"`
Config datatypes.JSON `json:"config" gorm:"type:jsonb;comment:模型参数配置"`
IsEnabled bool `json:"isEnabled" gorm:"default:true;comment:是否启用"`
}