fix(keling): 统一 Omni 模型别名与生产绑定
ci / verify (pull_request) Successful in 21m44s
ci / verify (pull_request) Successful in 21m44s
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user