Files
2026-06-01 23:43:53 +08:00

101 lines
3.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import "encoding/json"
type SettingKey string
const (
SettingKeyPublic SettingKey = "public"
SettingKeyPrivate SettingKey = "private"
)
// ModelChannel 模型渠道配置。
type ModelChannel struct {
Protocol string `json:"protocol"`
Compatibility string `json:"compatibility"`
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"`
RequestOptions ModelRequestOptions `json:"requestOptions"`
}
// ModelRequestOptions 控制 OpenAI 兼容接口的可选请求参数。
type ModelRequestOptions struct {
// ImageResponseFormat 为图片生成/编辑请求设置 response_format。
// OpenAI 默认使用 b64_jsonSub2API 推荐使用 url,避免部分上游不返回 b64_json。
ImageResponseFormat string `json:"imageResponseFormat"`
}
// ModelCost 模型算力点配置。
type ModelCost struct {
Model string `json:"model"`
Credits int `json:"credits"`
}
// PublicModelChannelSetting 公开模型渠道配置。
type PublicModelChannelSetting struct {
AvailableModels []string `json:"availableModels"`
ModelCosts []ModelCost `json:"modelCosts"`
DefaultModel string `json:"defaultModel"`
DefaultImageModel string `json:"defaultImageModel"`
DefaultVideoModel string `json:"defaultVideoModel"`
DefaultTextModel string `json:"defaultTextModel"`
SystemPrompt string `json:"systemPrompt"`
AllowCustomChannel *bool `json:"allowCustomChannel"`
}
// PublicSetting 公开配置。
type PublicSetting struct {
ModelChannel PublicModelChannelSetting `json:"modelChannel"`
Auth PublicAuthSetting `json:"auth"`
}
type PublicAuthSetting struct {
AllowRegister *bool `json:"allowRegister"`
LinuxDo PublicLinuxDoAuthSetting `json:"linuxDo"`
}
type PublicLinuxDoAuthSetting struct {
Enabled bool `json:"enabled"`
}
// PrivateSetting 私有配置。
type PrivateSetting struct {
Channels []ModelChannel `json:"channels"`
PromptSync PromptSyncSetting `json:"promptSync"`
Auth PrivateAuthSetting `json:"auth"`
}
// PromptSyncSetting 提示词定时同步配置。
type PromptSyncSetting struct {
Enabled *bool `json:"enabled"`
Cron string `json:"cron"`
}
type PrivateAuthSetting struct {
LinuxDo PrivateLinuxDoAuthSetting `json:"linuxDo"`
}
type PrivateLinuxDoAuthSetting struct {
ClientID string `json:"clientId"`
ClientSecret string `json:"clientSecret"`
}
// 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"`
}