fix(keling): 统一 Omni 模型别名与生产绑定
ci / verify (pull_request) Successful in 21m44s

This commit is contained in:
2026-07-22 10:00:30 +08:00
parent 9872068596
commit d37fb3ea60
6 changed files with 56 additions and 19 deletions
+16 -1
View File
@@ -1070,11 +1070,15 @@ func (s *Server) createTask(kind string, compatible bool) http.Handler {
return
}
}
model := requestModelName(body)
requestedModel := requestModelName(body)
model := canonicalTaskModelName(kind, requestedModel)
if model == "" {
writeError(w, http.StatusBadRequest, "model is required")
return
}
if model != requestedModel {
body["model"] = model
}
if !apiKeyScopeAllowed(user, kind) {
writeError(w, http.StatusForbidden, "api key scope does not allow this capability")
return
@@ -1402,6 +1406,17 @@ func requestModelName(body map[string]any) string {
return modelNameFromValue(body["model"])
}
func canonicalTaskModelName(kind string, model string) string {
model = strings.TrimSpace(model)
if kind != "videos.generations" {
return model
}
if canonical, ok := canonicalKlingOmniModel(model); ok {
return canonical
}
return model
}
func modelNameFromValue(value any) string {
switch typed := value.(type) {
case string: