🎨 优化项目结构 && 完善ai配置

This commit is contained in:
2026-03-03 15:39:23 +08:00
parent 557c865948
commit 2714e63d2a
585 changed files with 62223 additions and 100018 deletions

View File

@@ -4,18 +4,19 @@ import (
"git.echol.cn/loser/ai_proxy/server/global"
)
// AiProvider AI服务提供商配置
// AiProvider AI提供商配置
type AiProvider struct {
global.GVA_MODEL
Name string `json:"name" gorm:"comment:提供商名称;size:100;not null;uniqueIndex"`
Type string `json:"type" gorm:"comment:提供商类型;size:50;not null"` // openai, claude, gemini
BaseURL string `json:"baseUrl" gorm:"comment:API基础地址;size:500;not null"`
Endpoint string `json:"endpoint" gorm:"comment:API端点;size:200"` // 如 /v1/chat/completions
UpstreamKey string `json:"upstreamKey" gorm:"comment:上游API密钥;type:text"` // 上游 AI 的 key
Model string `json:"model" gorm:"comment:默认模型;size:100"`
ProxyKey string `json:"proxyKey" gorm:"comment:代理访问密钥;size:100;uniqueIndex"` // 用户访问本代理时使用的 key
Config map[string]interface{} `json:"config" gorm:"comment:额外配置;type:jsonb;serializer:json"`
IsActive bool `json:"isActive" gorm:"comment:是否启用;default:true"`
Name string `json:"name" gorm:"type:varchar(100);not null;uniqueIndex:idx_user_provider;comment:提供商名称"`
Type string `json:"type" gorm:"type:varchar(50);not null;comment:提供商类型"` // openai, claude, gemini
BaseURL string `json:"base_url" gorm:"type:varchar(255);not null;comment:API基础URL"`
APIKey string `json:"api_key" gorm:"type:varchar(255);not null;comment:API密钥"`
Model string `json:"model" gorm:"type:varchar(100);comment:默认模型"`
Enabled bool `json:"enabled" gorm:"default:true;comment:是否启用"`
Priority int `json:"priority" gorm:"default:0;comment:优先级"`
MaxRetries int `json:"max_retries" gorm:"default:3;comment:最大重试次数"`
Timeout int `json:"timeout" gorm:"default:60;comment:超时时间(秒)"`
UserID uint `json:"user_id" gorm:"index:idx_user_provider;comment:用户ID"`
}
func (AiProvider) TableName() string {