fix: resolve retired/preview gemini model routing and test configuration errors
This commit is contained in:
@@ -201,6 +201,16 @@ func (p *GeminiProvider) ResponsesStream(ctx context.Context, req *models.Respon
|
||||
}
|
||||
|
||||
func (p *GeminiProvider) ChatCompletion(ctx context.Context, req *models.UnifiedRequest) (*models.ChatCompletionResponse, error) {
|
||||
// Map deprecated or preview model names to active equivalents
|
||||
switch req.Model {
|
||||
case "gemini-2.0-flash":
|
||||
req.Model = "gemini-2.5-flash"
|
||||
case "gemini-3-flash":
|
||||
req.Model = "gemini-3-flash-preview"
|
||||
case "gemini-3-pro":
|
||||
req.Model = "gemini-3-pro-preview"
|
||||
}
|
||||
|
||||
// Gemini mapping
|
||||
var contents []GeminiContent
|
||||
|
||||
@@ -354,7 +364,10 @@ func (p *GeminiProvider) ChatCompletion(ctx context.Context, req *models.Unified
|
||||
|
||||
baseURL := p.config.BaseURL
|
||||
lowerModel := strings.ToLower(req.Model)
|
||||
if strings.Contains(lowerModel, "preview") || strings.Contains(lowerModel, "3.1") || strings.Contains(lowerModel, "2.0") || strings.Contains(lowerModel, "thinking") || hasMappedTools {
|
||||
if strings.Contains(lowerModel, "preview") ||
|
||||
strings.Contains(lowerModel, "thinking") ||
|
||||
strings.Contains(lowerModel, "gemini-") ||
|
||||
hasMappedTools {
|
||||
// Use v1beta for preview, newer models, or when using tools
|
||||
if !strings.Contains(baseURL, "v1beta") {
|
||||
baseURL = strings.Replace(baseURL, "/v1", "/v1beta", 1)
|
||||
@@ -468,6 +481,16 @@ func (p *GeminiProvider) ChatCompletion(ctx context.Context, req *models.Unified
|
||||
}
|
||||
|
||||
func (p *GeminiProvider) ChatCompletionStream(ctx context.Context, req *models.UnifiedRequest) (<-chan *models.ChatCompletionStreamResponse, error) {
|
||||
// Map deprecated or preview model names to active equivalents
|
||||
switch req.Model {
|
||||
case "gemini-2.0-flash":
|
||||
req.Model = "gemini-2.5-flash"
|
||||
case "gemini-3-flash":
|
||||
req.Model = "gemini-3-flash-preview"
|
||||
case "gemini-3-pro":
|
||||
req.Model = "gemini-3-pro-preview"
|
||||
}
|
||||
|
||||
// Simplified Gemini mapping
|
||||
var contents []GeminiContent
|
||||
for i := 0; i < len(req.Messages); i++ {
|
||||
@@ -598,7 +621,10 @@ func (p *GeminiProvider) ChatCompletionStream(ctx context.Context, req *models.U
|
||||
|
||||
baseURL := p.config.BaseURL
|
||||
lowerModel := strings.ToLower(req.Model)
|
||||
if strings.Contains(lowerModel, "preview") || strings.Contains(lowerModel, "3.1") || strings.Contains(lowerModel, "2.0") || strings.Contains(lowerModel, "thinking") || hasMappedTools {
|
||||
if strings.Contains(lowerModel, "preview") ||
|
||||
strings.Contains(lowerModel, "thinking") ||
|
||||
strings.Contains(lowerModel, "gemini-") ||
|
||||
hasMappedTools {
|
||||
// Use v1beta for preview, newer models, or when using tools
|
||||
if !strings.Contains(baseURL, "v1beta") {
|
||||
baseURL = strings.Replace(baseURL, "/v1", "/v1beta", 1)
|
||||
|
||||
Reference in New Issue
Block a user