6f1e0d347b
- 移除独立的ai-config.ts文件,将其功能整合到use-config-store - 更新所有组件导入路径从 "@/lib/ai-config" 到 "@/stores/use-config-store" - 实现云端渠道和本地直连两种配置模式的支持 - 添加模型渠道配置管理和API请求代理转发功能 - 统一配置验证逻辑和有效配置获取方法 - 更新组件中使用的配置状态钩子和API调用方式
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package model
|
|
|
|
import "encoding/json"
|
|
|
|
type SettingKey string
|
|
|
|
const (
|
|
SettingKeyPublic SettingKey = "public"
|
|
SettingKeyPrivate SettingKey = "private"
|
|
)
|
|
|
|
// ModelChannel 模型渠道配置。
|
|
type ModelChannel struct {
|
|
Protocol string `json:"protocol"`
|
|
Name string `json:"name"`
|
|
BaseURL string `json:"baseUrl"`
|
|
APIKey string `json:"apiKey"`
|
|
Models []string `json:"models"`
|
|
Weight int `json:"weight"`
|
|
Enabled bool `json:"enabled"`
|
|
Remark string `json:"remark"`
|
|
}
|
|
|
|
// PublicModelChannelSetting 公开模型渠道配置。
|
|
type PublicModelChannelSetting struct {
|
|
AvailableModels []string `json:"availableModels"`
|
|
DefaultModel string `json:"defaultModel"`
|
|
DefaultImageModel string `json:"defaultImageModel"`
|
|
DefaultTextModel string `json:"defaultTextModel"`
|
|
SystemPrompt string `json:"systemPrompt"`
|
|
AllowCustomChannel bool `json:"allowCustomChannel"`
|
|
}
|
|
|
|
// PublicSetting 公开配置。
|
|
type PublicSetting struct {
|
|
ModelChannel PublicModelChannelSetting `json:"modelChannel"`
|
|
}
|
|
|
|
// PrivateSetting 私有配置。
|
|
type PrivateSetting struct {
|
|
Channels []ModelChannel `json:"channels"`
|
|
}
|
|
|
|
// Setting 系统配置。
|
|
type Setting struct {
|
|
Key SettingKey `json:"key" gorm:"primaryKey"`
|
|
Value json.RawMessage `json:"value" gorm:"serializer:json"`
|
|
CreatedAt string `json:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt"`
|
|
}
|
|
|
|
// Settings 系统公开和私有配置。
|
|
type Settings struct {
|
|
Public PublicSetting `json:"public"`
|
|
Private PrivateSetting `json:"private"`
|
|
}
|