feat: add --model flag, isKnownModelID routing, [1M] context tag
This commit is contained in:
parent
7fdcf01534
commit
db1dd25a9b
1 changed files with 13 additions and 3 deletions
|
|
@ -188,6 +188,16 @@ 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"}
|
||||
}
|
||||
|
||||
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 {
|
||||
model = strings.TrimSuffix(model, "[1M]")
|
||||
model = strings.TrimSuffix(model, "[128K]")
|
||||
|
|
@ -448,7 +458,7 @@ func proxyChatCompletions(w http.ResponseWriter, r *http.Request, cfg Config) {
|
|||
dm := cleanModelName(cfg.Model)
|
||||
var reqMap map[string]any
|
||||
if json.Unmarshal(body, &reqMap) == nil {
|
||||
if m, _ := reqMap["model"].(string); m == "" || strings.HasPrefix(m, "claude-") {
|
||||
if m, _ := reqMap["model"].(string); m == "" || !isKnownModelID(m) {
|
||||
reqMap["model"] = dm
|
||||
body, _ = json.Marshal(reqMap)
|
||||
}
|
||||
|
|
@ -627,7 +637,7 @@ func stripRawChatImageDetails(req map[string]any) bool {
|
|||
|
||||
func convertRequest(ar AnthropicRequest, defaultModel string) OAIRequest {
|
||||
model := cleanModelName(ar.Model)
|
||||
if model == "" || strings.HasPrefix(model, "claude-") || defaultModel != "" {
|
||||
if model == "" || !isKnownModelID(model) {
|
||||
model = cleanModelName(defaultModel)
|
||||
}
|
||||
if model == "" {
|
||||
|
|
@ -648,7 +658,7 @@ func convertRequest(ar AnthropicRequest, defaultModel string) OAIRequest {
|
|||
|
||||
func responsesToChat(rr ResponsesRequest, defaultModel string) OAIRequest {
|
||||
model := cleanModelName(rr.Model)
|
||||
if model == "" || defaultModel != "" {
|
||||
if model == "" || !isKnownModelID(model) {
|
||||
model = cleanModelName(defaultModel)
|
||||
}
|
||||
if model == "" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue