mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 16:04:01 +00:00
feat(models): add collision-safe aliases and model echoes (#125)
This commit is contained in:
1 parent
a0fbd6b6cb
commit
9b44a031ca
14 files changed
+443
-23
No files matched your search
@@ -201,6 +201,12 @@ type SecretInput struct {
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
type ModelsUpdate struct {
|
||||
config.ModelsConfig
|
||||
Aliases *map[string]string `json:"aliases,omitempty"`
|
||||
StripFreeSuffix *bool `json:"strip_free_suffix,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigUpdate is the body of PUT /api/config. Secrets carry either a new
|
||||
// value or the ID of the existing one. The WebUI username and password are
|
||||
// not changed here; they go through /api/account.
|
||||
@@ -217,7 +223,7 @@ type ConfigUpdate struct {
|
||||
ProxyBindings map[string]string `json:"proxy_bindings,omitempty"`
|
||||
Upstream config.UpstreamConfig `json:"upstream"`
|
||||
Retry config.RetryConfig `json:"retry"`
|
||||
Models config.ModelsConfig `json:"models"`
|
||||
Models ModelsUpdate `json:"models"`
|
||||
Performance config.PerformanceConfig `json:"performance"`
|
||||
Logging config.LoggingConfig `json:"logging"`
|
||||
Prefer config.Tier `json:"prefer"`
|
||||
@@ -280,7 +286,7 @@ func (a *Server) handlePutConfig(w http.ResponseWriter, r *http.Request) {
|
||||
Listen: update.Listen, ServerKeys: serverKeys, ZenKeys: zenKeys, GoKeys: goKeys, Anonymous: update.Anonymous, Warp: update.Warp, Proxies: proxies, ProxyFile: update.ProxyFile,
|
||||
ProxyBindings: proxyBindings,
|
||||
KeysDirect: current.KeysDirect,
|
||||
Upstream: update.Upstream, Retry: update.Retry, Models: update.Models, Performance: update.Performance, Logging: update.Logging, Prefer: update.Prefer,
|
||||
Upstream: update.Upstream, Retry: update.Retry, Models: update.Models.ModelsConfig, Performance: update.Performance, Logging: update.Logging, Prefer: update.Prefer,
|
||||
Reasoning: reasoning,
|
||||
WebUI: config.WebUIConfig{Enabled: update.WebUI.Enabled, Listen: update.WebUI.Listen, Username: current.WebUI.Username, PasswordHash: current.WebUI.PasswordHash, SessionTTLMinutes: update.WebUI.SessionTTLMinutes},
|
||||
}
|
||||
@@ -296,6 +302,14 @@ func (a *Server) handlePutConfig(w http.ResponseWriter, r *http.Request) {
|
||||
if update.KeysDirect != nil {
|
||||
candidate.KeysDirect = *update.KeysDirect
|
||||
}
|
||||
candidate.Models.Aliases = latest.Models.Aliases
|
||||
if update.Models.Aliases != nil {
|
||||
candidate.Models.Aliases = *update.Models.Aliases
|
||||
}
|
||||
candidate.Models.StripFreeSuffix = latest.Models.StripFreeSuffix
|
||||
if update.Models.StripFreeSuffix != nil {
|
||||
candidate.Models.StripFreeSuffix = *update.Models.StripFreeSuffix
|
||||
}
|
||||
candidate.WebUI.Username = latest.WebUI.Username
|
||||
candidate.WebUI.PasswordHash = latest.WebUI.PasswordHash
|
||||
if update.Reasoning == nil {
|
||||
|
||||
Reference in new issue
Block a user