mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 20:40:52 +08:00
refactor(antigravity): remove hardcoded model aliases
This commit is contained in:
@@ -206,7 +206,22 @@ nonstream-keepalive-interval: 0
|
|||||||
# Supported channels: gemini-cli, vertex, aistudio, antigravity, claude, codex, qwen, iflow.
|
# Supported channels: gemini-cli, vertex, aistudio, antigravity, claude, codex, qwen, iflow.
|
||||||
# NOTE: Mappings do not apply to gemini-api-key, codex-api-key, claude-api-key, openai-compatibility, vertex-api-key, or ampcode.
|
# NOTE: Mappings do not apply to gemini-api-key, codex-api-key, claude-api-key, openai-compatibility, vertex-api-key, or ampcode.
|
||||||
# You can repeat the same name with different aliases to expose multiple client model names.
|
# You can repeat the same name with different aliases to expose multiple client model names.
|
||||||
# oauth-model-mappings:
|
oauth-model-mappings:
|
||||||
|
antigravity:
|
||||||
|
- name: "rev19-uic3-1p"
|
||||||
|
alias: "gemini-2.5-computer-use-preview-10-2025"
|
||||||
|
- name: "gemini-3-pro-image"
|
||||||
|
alias: "gemini-3-pro-image-preview"
|
||||||
|
- name: "gemini-3-pro-high"
|
||||||
|
alias: "gemini-3-pro-preview"
|
||||||
|
- name: "gemini-3-flash"
|
||||||
|
alias: "gemini-3-flash-preview"
|
||||||
|
- name: "claude-sonnet-4-5"
|
||||||
|
alias: "gemini-claude-sonnet-4-5"
|
||||||
|
- name: "claude-sonnet-4-5-thinking"
|
||||||
|
alias: "gemini-claude-sonnet-4-5-thinking"
|
||||||
|
- name: "claude-opus-4-5-thinking"
|
||||||
|
alias: "gemini-claude-opus-4-5-thinking"
|
||||||
# gemini-cli:
|
# gemini-cli:
|
||||||
# - name: "gemini-2.5-pro" # original model name under this channel
|
# - name: "gemini-2.5-pro" # original model name under this channel
|
||||||
# alias: "g2.5p" # client-visible alias
|
# alias: "g2.5p" # client-visible alias
|
||||||
@@ -217,9 +232,6 @@ nonstream-keepalive-interval: 0
|
|||||||
# aistudio:
|
# aistudio:
|
||||||
# - name: "gemini-2.5-pro"
|
# - name: "gemini-2.5-pro"
|
||||||
# alias: "g2.5p"
|
# alias: "g2.5p"
|
||||||
# antigravity:
|
|
||||||
# - name: "gemini-3-pro-preview"
|
|
||||||
# alias: "g3p"
|
|
||||||
# claude:
|
# claude:
|
||||||
# - name: "claude-sonnet-4-5-20250929"
|
# - name: "claude-sonnet-4-5-20250929"
|
||||||
# alias: "cs4.5"
|
# alias: "cs4.5"
|
||||||
|
|||||||
@@ -768,17 +768,17 @@ type AntigravityModelConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetAntigravityModelConfig returns static configuration for antigravity models.
|
// GetAntigravityModelConfig returns static configuration for antigravity models.
|
||||||
// Keys use the ALIASED model names (after modelName2Alias conversion) for direct lookup.
|
// Keys use upstream model names returned by the Antigravity models endpoint.
|
||||||
func GetAntigravityModelConfig() map[string]*AntigravityModelConfig {
|
func GetAntigravityModelConfig() map[string]*AntigravityModelConfig {
|
||||||
return map[string]*AntigravityModelConfig{
|
return map[string]*AntigravityModelConfig{
|
||||||
"gemini-2.5-flash": {Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, Name: "models/gemini-2.5-flash"},
|
"gemini-2.5-flash": {Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, Name: "models/gemini-2.5-flash"},
|
||||||
"gemini-2.5-flash-lite": {Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, Name: "models/gemini-2.5-flash-lite"},
|
"gemini-2.5-flash-lite": {Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, Name: "models/gemini-2.5-flash-lite"},
|
||||||
"gemini-2.5-computer-use-preview-10-2025": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true}, Name: "models/gemini-2.5-computer-use-preview-10-2025"},
|
"rev19-uic3-1p": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true}, Name: "models/rev19-uic3-1p"},
|
||||||
"gemini-3-pro-preview": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}}, Name: "models/gemini-3-pro-preview"},
|
"gemini-3-pro-high": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}}, Name: "models/gemini-3-pro-high"},
|
||||||
"gemini-3-pro-image-preview": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}}, Name: "models/gemini-3-pro-image-preview"},
|
"gemini-3-pro-image": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}}, Name: "models/gemini-3-pro-image"},
|
||||||
"gemini-3-flash-preview": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"minimal", "low", "medium", "high"}}, Name: "models/gemini-3-flash-preview"},
|
"gemini-3-flash": {Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"minimal", "low", "medium", "high"}}, Name: "models/gemini-3-flash"},
|
||||||
"gemini-claude-sonnet-4-5-thinking": {Thinking: &ThinkingSupport{Min: 1024, Max: 128000, ZeroAllowed: true, DynamicAllowed: false}, MaxCompletionTokens: 64000},
|
"claude-sonnet-4-5-thinking": {Thinking: &ThinkingSupport{Min: 1024, Max: 128000, ZeroAllowed: true, DynamicAllowed: false}, MaxCompletionTokens: 64000},
|
||||||
"gemini-claude-opus-4-5-thinking": {Thinking: &ThinkingSupport{Min: 1024, Max: 128000, ZeroAllowed: true, DynamicAllowed: false}, MaxCompletionTokens: 64000},
|
"claude-opus-4-5-thinking": {Thinking: &ThinkingSupport{Min: 1024, Max: 128000, ZeroAllowed: true, DynamicAllowed: false}, MaxCompletionTokens: 64000},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1005,25 +1005,31 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
modelConfig := registry.GetAntigravityModelConfig()
|
modelConfig := registry.GetAntigravityModelConfig()
|
||||||
models := make([]*registry.ModelInfo, 0, len(result.Map()))
|
models := make([]*registry.ModelInfo, 0, len(result.Map()))
|
||||||
for originalName := range result.Map() {
|
for originalName := range result.Map() {
|
||||||
aliasName := modelName2Alias(originalName)
|
modelID := strings.TrimSpace(originalName)
|
||||||
if aliasName != "" {
|
if modelID == "" {
|
||||||
cfg := modelConfig[aliasName]
|
continue
|
||||||
modelName := aliasName
|
}
|
||||||
|
switch modelID {
|
||||||
|
case "chat_20706", "chat_23310", "gemini-2.5-flash-thinking", "gemini-3-pro-low", "gemini-2.5-pro":
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cfg := modelConfig[modelID]
|
||||||
|
modelName := modelID
|
||||||
if cfg != nil && cfg.Name != "" {
|
if cfg != nil && cfg.Name != "" {
|
||||||
modelName = cfg.Name
|
modelName = cfg.Name
|
||||||
}
|
}
|
||||||
modelInfo := ®istry.ModelInfo{
|
modelInfo := ®istry.ModelInfo{
|
||||||
ID: aliasName,
|
ID: modelID,
|
||||||
Name: modelName,
|
Name: modelName,
|
||||||
Description: aliasName,
|
Description: modelID,
|
||||||
DisplayName: aliasName,
|
DisplayName: modelID,
|
||||||
Version: aliasName,
|
Version: modelID,
|
||||||
Object: "model",
|
Object: "model",
|
||||||
Created: now,
|
Created: now,
|
||||||
OwnedBy: antigravityAuthType,
|
OwnedBy: antigravityAuthType,
|
||||||
Type: antigravityAuthType,
|
Type: antigravityAuthType,
|
||||||
}
|
}
|
||||||
// Look up Thinking support from static config using alias name
|
// Look up Thinking support from static config using upstream model name.
|
||||||
if cfg != nil {
|
if cfg != nil {
|
||||||
if cfg.Thinking != nil {
|
if cfg.Thinking != nil {
|
||||||
modelInfo.Thinking = cfg.Thinking
|
modelInfo.Thinking = cfg.Thinking
|
||||||
@@ -1034,7 +1040,6 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
}
|
}
|
||||||
models = append(models, modelInfo)
|
models = append(models, modelInfo)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return models
|
return models
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -1171,7 +1176,7 @@ func (e *AntigravityExecutor) buildRequest(ctx context.Context, auth *cliproxyau
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
payload = geminiToAntigravity(modelName, payload, projectID)
|
payload = geminiToAntigravity(modelName, payload, projectID)
|
||||||
payload, _ = sjson.SetBytes(payload, "model", alias2ModelName(modelName))
|
payload, _ = sjson.SetBytes(payload, "model", modelName)
|
||||||
|
|
||||||
if strings.Contains(modelName, "claude") {
|
if strings.Contains(modelName, "claude") {
|
||||||
strJSON := string(payload)
|
strJSON := string(payload)
|
||||||
@@ -1443,50 +1448,6 @@ func generateProjectID() string {
|
|||||||
return adj + "-" + noun + "-" + randomPart
|
return adj + "-" + noun + "-" + randomPart
|
||||||
}
|
}
|
||||||
|
|
||||||
func modelName2Alias(modelName string) string {
|
|
||||||
switch modelName {
|
|
||||||
case "rev19-uic3-1p":
|
|
||||||
return "gemini-2.5-computer-use-preview-10-2025"
|
|
||||||
case "gemini-3-pro-image":
|
|
||||||
return "gemini-3-pro-image-preview"
|
|
||||||
case "gemini-3-pro-high":
|
|
||||||
return "gemini-3-pro-preview"
|
|
||||||
case "gemini-3-flash":
|
|
||||||
return "gemini-3-flash-preview"
|
|
||||||
case "claude-sonnet-4-5":
|
|
||||||
return "gemini-claude-sonnet-4-5"
|
|
||||||
case "claude-sonnet-4-5-thinking":
|
|
||||||
return "gemini-claude-sonnet-4-5-thinking"
|
|
||||||
case "claude-opus-4-5-thinking":
|
|
||||||
return "gemini-claude-opus-4-5-thinking"
|
|
||||||
case "chat_20706", "chat_23310", "gemini-2.5-flash-thinking", "gemini-3-pro-low", "gemini-2.5-pro":
|
|
||||||
return ""
|
|
||||||
default:
|
|
||||||
return modelName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func alias2ModelName(modelName string) string {
|
|
||||||
switch modelName {
|
|
||||||
case "gemini-2.5-computer-use-preview-10-2025":
|
|
||||||
return "rev19-uic3-1p"
|
|
||||||
case "gemini-3-pro-image-preview":
|
|
||||||
return "gemini-3-pro-image"
|
|
||||||
case "gemini-3-pro-preview":
|
|
||||||
return "gemini-3-pro-high"
|
|
||||||
case "gemini-3-flash-preview":
|
|
||||||
return "gemini-3-flash"
|
|
||||||
case "gemini-claude-sonnet-4-5":
|
|
||||||
return "claude-sonnet-4-5"
|
|
||||||
case "gemini-claude-sonnet-4-5-thinking":
|
|
||||||
return "claude-sonnet-4-5-thinking"
|
|
||||||
case "gemini-claude-opus-4-5-thinking":
|
|
||||||
return "claude-opus-4-5-thinking"
|
|
||||||
default:
|
|
||||||
return modelName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// normalizeAntigravityThinking performs Antigravity-specific thinking config normalization.
|
// normalizeAntigravityThinking performs Antigravity-specific thinking config normalization.
|
||||||
// This function is called AFTER thinking.ApplyThinking() to apply Claude-specific constraints.
|
// This function is called AFTER thinking.ApplyThinking() to apply Claude-specific constraints.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user