Compare commits

..

No commits in common. "1b685002b83e8b853f745858d7d94cda5a62066e" and "7fdcf01534f2ffdc61c8156ae117edf5e2c4e948" have entirely different histories.

View file

@ -188,16 +188,6 @@ func knownModelIDs() []string {
return []string{"glm-5.1", "glm-5", "kimi-k2.6", "kimi-k2.5", "mimo-v2.5-pro", "mimo-v2.5", "mimo-v2-pro", "mimo-v2-omni", "minimax-m2.7", "minimax-m2.5", "deepseek-v4-pro[1M]", "deepseek-v4-flash[1M]", "qwen3.6-plus", "qwen3.5-plus"} return []string{"glm-5.1", "glm-5", "kimi-k2.6", "kimi-k2.5", "mimo-v2.5-pro", "mimo-v2.5", "mimo-v2-pro", "mimo-v2-omni", "minimax-m2.7", "minimax-m2.5", "deepseek-v4-pro[1M]", "deepseek-v4-flash[1M]", "qwen3.6-plus", "qwen3.5-plus"}
} }
func isKnownModelID(model string) bool {
cleaned := cleanModelName(model)
for _, m := range knownModelIDs() {
if cleanModelName(m) == cleaned {
return true
}
}
return false
}
func cleanModelName(model string) string { func cleanModelName(model string) string {
model = strings.TrimSuffix(model, "[1M]") model = strings.TrimSuffix(model, "[1M]")
model = strings.TrimSuffix(model, "[128K]") model = strings.TrimSuffix(model, "[128K]")
@ -458,7 +448,7 @@ func proxyChatCompletions(w http.ResponseWriter, r *http.Request, cfg Config) {
dm := cleanModelName(cfg.Model) dm := cleanModelName(cfg.Model)
var reqMap map[string]any var reqMap map[string]any
if json.Unmarshal(body, &reqMap) == nil { if json.Unmarshal(body, &reqMap) == nil {
if m, _ := reqMap["model"].(string); m == "" || !isKnownModelID(m) { if m, _ := reqMap["model"].(string); m == "" || strings.HasPrefix(m, "claude-") {
reqMap["model"] = dm reqMap["model"] = dm
body, _ = json.Marshal(reqMap) body, _ = json.Marshal(reqMap)
} }
@ -637,7 +627,7 @@ func stripRawChatImageDetails(req map[string]any) bool {
func convertRequest(ar AnthropicRequest, defaultModel string) OAIRequest { func convertRequest(ar AnthropicRequest, defaultModel string) OAIRequest {
model := cleanModelName(ar.Model) model := cleanModelName(ar.Model)
if model == "" || !isKnownModelID(model) { if model == "" || strings.HasPrefix(model, "claude-") || defaultModel != "" {
model = cleanModelName(defaultModel) model = cleanModelName(defaultModel)
} }
if model == "" { if model == "" {
@ -658,7 +648,7 @@ func convertRequest(ar AnthropicRequest, defaultModel string) OAIRequest {
func responsesToChat(rr ResponsesRequest, defaultModel string) OAIRequest { func responsesToChat(rr ResponsesRequest, defaultModel string) OAIRequest {
model := cleanModelName(rr.Model) model := cleanModelName(rr.Model)
if model == "" || !isKnownModelID(model) { if model == "" || defaultModel != "" {
model = cleanModelName(defaultModel) model = cleanModelName(defaultModel)
} }
if model == "" { if model == "" {