feat: add --model flag, isKnownModelID routing, [1M] context tag #10

Merged
opencode merged 1 commit from renekv/ocgo:main into main 2026-05-26 03:50:21 +00:00
Showing only changes of commit db1dd25a9b - Show all commits

View file

@ -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 == "" {