mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
feat(registry): add thinking budget support; populate Gemini models
This commit is contained in:
@@ -84,6 +84,7 @@ func GeminiModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 65536,
|
OutputTokenLimit: 65536,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "gemini-2.5-pro",
|
ID: "gemini-2.5-pro",
|
||||||
@@ -98,6 +99,7 @@ func GeminiModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 65536,
|
OutputTokenLimit: 65536,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "gemini-2.5-flash-lite",
|
ID: "gemini-2.5-flash-lite",
|
||||||
@@ -112,6 +114,7 @@ func GeminiModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 65536,
|
OutputTokenLimit: 65536,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
Thinking: &ThinkingSupport{Min: 512, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "gemini-2.5-flash-image-preview",
|
ID: "gemini-2.5-flash-image-preview",
|
||||||
@@ -126,6 +129,7 @@ func GeminiModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 8192,
|
OutputTokenLimit: 8192,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
// image models don't support thinkingConfig; leave Thinking nil
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "gemini-2.5-flash-image",
|
ID: "gemini-2.5-flash-image",
|
||||||
@@ -140,6 +144,7 @@ func GeminiModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 8192,
|
OutputTokenLimit: 8192,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
// image models don't support thinkingConfig; leave Thinking nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,9 +157,8 @@ func GetGeminiCLIModels() []*ModelInfo { return GeminiModels() }
|
|||||||
|
|
||||||
// GetAIStudioModels returns the Gemini model definitions for AI Studio integrations
|
// GetAIStudioModels returns the Gemini model definitions for AI Studio integrations
|
||||||
func GetAIStudioModels() []*ModelInfo {
|
func GetAIStudioModels() []*ModelInfo {
|
||||||
models := make([]*ModelInfo, 0, 8)
|
base := GeminiModels()
|
||||||
models = append(models, GeminiModels()...)
|
return append(base,
|
||||||
models = append(models,
|
|
||||||
&ModelInfo{
|
&ModelInfo{
|
||||||
ID: "gemini-pro-latest",
|
ID: "gemini-pro-latest",
|
||||||
Object: "model",
|
Object: "model",
|
||||||
@@ -168,6 +172,7 @@ func GetAIStudioModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 65536,
|
OutputTokenLimit: 65536,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true},
|
||||||
},
|
},
|
||||||
&ModelInfo{
|
&ModelInfo{
|
||||||
ID: "gemini-flash-latest",
|
ID: "gemini-flash-latest",
|
||||||
@@ -182,6 +187,7 @@ func GetAIStudioModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 65536,
|
OutputTokenLimit: 65536,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
Thinking: &ThinkingSupport{Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
|
||||||
},
|
},
|
||||||
&ModelInfo{
|
&ModelInfo{
|
||||||
ID: "gemini-flash-lite-latest",
|
ID: "gemini-flash-lite-latest",
|
||||||
@@ -196,9 +202,9 @@ func GetAIStudioModels() []*ModelInfo {
|
|||||||
InputTokenLimit: 1048576,
|
InputTokenLimit: 1048576,
|
||||||
OutputTokenLimit: 65536,
|
OutputTokenLimit: 65536,
|
||||||
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
|
||||||
|
Thinking: &ThinkingSupport{Min: 512, Max: 24576, ZeroAllowed: true, DynamicAllowed: true},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return models
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOpenAIModels returns the standard OpenAI model definitions
|
// GetOpenAIModels returns the standard OpenAI model definitions
|
||||||
|
|||||||
@@ -45,6 +45,23 @@ type ModelInfo struct {
|
|||||||
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
|
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
|
||||||
// SupportedParameters lists supported parameters
|
// SupportedParameters lists supported parameters
|
||||||
SupportedParameters []string `json:"supported_parameters,omitempty"`
|
SupportedParameters []string `json:"supported_parameters,omitempty"`
|
||||||
|
|
||||||
|
// Thinking holds provider-specific reasoning/thinking budget capabilities.
|
||||||
|
// This is optional and currently used for Gemini thinking budget normalization.
|
||||||
|
Thinking *ThinkingSupport `json:"thinking,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ThinkingSupport describes a model family's supported internal reasoning budget range.
|
||||||
|
// Values are interpreted in provider-native token units.
|
||||||
|
type ThinkingSupport struct {
|
||||||
|
// Min is the minimum allowed thinking budget (inclusive).
|
||||||
|
Min int `json:"min,omitempty"`
|
||||||
|
// Max is the maximum allowed thinking budget (inclusive).
|
||||||
|
Max int `json:"max,omitempty"`
|
||||||
|
// ZeroAllowed indicates whether 0 is a valid value (to disable thinking).
|
||||||
|
ZeroAllowed bool `json:"zero_allowed,omitempty"`
|
||||||
|
// DynamicAllowed indicates whether -1 is a valid value (dynamic thinking budget).
|
||||||
|
DynamicAllowed bool `json:"dynamic_allowed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModelRegistration tracks a model's availability
|
// ModelRegistration tracks a model's availability
|
||||||
@@ -652,6 +669,17 @@ func (r *ModelRegistry) GetModelProviders(modelID string) []string {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetModelInfo returns the registered ModelInfo for the given model ID, if present.
|
||||||
|
// Returns nil if the model is unknown to the registry.
|
||||||
|
func (r *ModelRegistry) GetModelInfo(modelID string) *ModelInfo {
|
||||||
|
r.mutex.RLock()
|
||||||
|
defer r.mutex.RUnlock()
|
||||||
|
if reg, ok := r.models[modelID]; ok && reg != nil {
|
||||||
|
return reg.Info
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// convertModelToMap converts ModelInfo to the appropriate format for different handler types
|
// convertModelToMap converts ModelInfo to the appropriate format for different handler types
|
||||||
func (r *ModelRegistry) convertModelToMap(model *ModelInfo, handlerType string) map[string]any {
|
func (r *ModelRegistry) convertModelToMap(model *ModelInfo, handlerType string) map[string]any {
|
||||||
if model == nil {
|
if model == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user