Merge pull request #444 from router-for-me/agry
feat(registry): add explicit thinking support config for antigravity models
This commit is contained in:
@@ -943,8 +943,19 @@ func GetQwenModels() []*ModelInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIFlowModels returns supported models for iFlow OAuth accounts.
|
// GetAntigravityThinkingConfig returns the Thinking configuration for antigravity models.
|
||||||
|
// Keys use the ALIASED model names (after modelName2Alias conversion) for direct lookup.
|
||||||
|
func GetAntigravityThinkingConfig() map[string]*ThinkingSupport {
|
||||||
|
return map[string]*ThinkingSupport{
|
||||||
|
"gemini-2.5-flash": {Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
|
||||||
|
"gemini-2.5-flash-lite": {Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
|
||||||
|
"gemini-3-pro-preview": {Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
|
||||||
|
"gemini-claude-sonnet-4-5-thinking": {Min: 1024, Max: 200000, ZeroAllowed: false, DynamicAllowed: true},
|
||||||
|
"gemini-claude-opus-4-5-thinking": {Min: 1024, Max: 200000, ZeroAllowed: false, DynamicAllowed: true},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetIFlowModels returns supported models for iFlow OAuth accounts.
|
||||||
func GetIFlowModels() []*ModelInfo {
|
func GetIFlowModels() []*ModelInfo {
|
||||||
entries := []struct {
|
entries := []struct {
|
||||||
ID string
|
ID string
|
||||||
|
|||||||
@@ -366,29 +366,25 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
|
thinkingConfig := registry.GetAntigravityThinkingConfig()
|
||||||
models := make([]*registry.ModelInfo, 0, len(result.Map()))
|
models := make([]*registry.ModelInfo, 0, len(result.Map()))
|
||||||
for id := range result.Map() {
|
for originalName := range result.Map() {
|
||||||
id = modelName2Alias(id)
|
aliasName := modelName2Alias(originalName)
|
||||||
if id != "" {
|
if aliasName != "" {
|
||||||
modelInfo := ®istry.ModelInfo{
|
modelInfo := ®istry.ModelInfo{
|
||||||
ID: id,
|
ID: aliasName,
|
||||||
Name: id,
|
Name: aliasName,
|
||||||
Description: id,
|
Description: aliasName,
|
||||||
DisplayName: id,
|
DisplayName: aliasName,
|
||||||
Version: id,
|
Version: aliasName,
|
||||||
Object: "model",
|
Object: "model",
|
||||||
Created: now,
|
Created: now,
|
||||||
OwnedBy: antigravityAuthType,
|
OwnedBy: antigravityAuthType,
|
||||||
Type: antigravityAuthType,
|
Type: antigravityAuthType,
|
||||||
}
|
}
|
||||||
// Add Thinking support for thinking models
|
// Look up Thinking support from static config using alias name
|
||||||
if strings.HasSuffix(id, "-thinking") || strings.Contains(id, "-thinking-") {
|
if thinking, ok := thinkingConfig[aliasName]; ok {
|
||||||
modelInfo.Thinking = ®istry.ThinkingSupport{
|
modelInfo.Thinking = thinking
|
||||||
Min: 1024,
|
|
||||||
Max: 100000,
|
|
||||||
ZeroAllowed: false,
|
|
||||||
DynamicAllowed: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
models = append(models, modelInfo)
|
models = append(models, modelInfo)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,20 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Claude/Anthropic API format: thinking.type == "enabled" with budget_tokens
|
||||||
|
// This allows Claude Code and other Claude API clients to pass thinking configuration
|
||||||
|
if !gjson.GetBytes(out, "request.generationConfig.thinkingConfig").Exists() && util.ModelSupportsThinking(modelName) {
|
||||||
|
if t := gjson.GetBytes(rawJSON, "thinking"); t.Exists() && t.IsObject() {
|
||||||
|
if t.Get("type").String() == "enabled" {
|
||||||
|
if b := t.Get("budget_tokens"); b.Exists() && b.Type == gjson.Number {
|
||||||
|
budget := util.NormalizeThinkingBudget(modelName, int(b.Int()))
|
||||||
|
out, _ = sjson.SetBytes(out, "request.generationConfig.thinkingConfig.thinkingBudget", budget)
|
||||||
|
out, _ = sjson.SetBytes(out, "request.generationConfig.thinkingConfig.include_thoughts", true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For gemini-3-pro-preview, always send default thinkingConfig when none specified.
|
// For gemini-3-pro-preview, always send default thinkingConfig when none specified.
|
||||||
// This matches the official Gemini CLI behavior which always sends:
|
// This matches the official Gemini CLI behavior which always sends:
|
||||||
// { thinkingBudget: -1, includeThoughts: true }
|
// { thinkingBudget: -1, includeThoughts: true }
|
||||||
|
|||||||
Reference in New Issue
Block a user