History

Merge branch 'router-for-me:main' into main

Luis Pater committed 8 months agov6.8.23-0

Commit 57d18bb2 parents 10b9c6c 7b0eb413 files · +37 −3Browse files

Unified · Split

3 files
  1. internal/auth/claude/anthropic_auth.go +1 −1
  2. internal/registry/model_definitions_static_data.go +15 −0
  3. internal/translator/codex/claude/codex_claude_response.go +21 −2
internal/auth/claude/anthropic_auth.go+1−1
@@ -20,7 +20,7 @@ import ( · 19 unmodified lines
20// OAuth configuration constants for Claude/Anthropic20// OAuth configuration constants for Claude/Anthropic
21const (21const (
22 AuthURL = "https://claude.ai/oauth/authorize"22 AuthURL = "https://claude.ai/oauth/authorize"
23 TokenURL = "https://console.anthropic.com/v1/oauth/token"23 TokenURL = "https://api.anthropic.com/v1/oauth/token"
24 ClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e"24 ClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e"
25 RedirectURI = "http://localhost:54545/callback"25 RedirectURI = "http://localhost:54545/callback"
26)26)
internal/registry/model_definitions_static_data.go+15−0
@@ -306,6 +306,21 @@ func GetGeminiVertexModels() []*ModelInfo { · 305 unmodified lines
306 SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},306 SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
307 Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"minimal", "low", "medium", "high"}},307 Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"minimal", "low", "medium", "high"}},
308 },308 },
309 {
310 ID: "gemini-3.1-pro-preview",
311 Object: "model",
312 Created: 1771491385,
313 OwnedBy: "google",
314 Type: "gemini",
315 Name: "models/gemini-3.1-pro-preview",
316 Version: "3.1",
317 DisplayName: "Gemini 3.1 Pro Preview",
318 Description: "Gemini 3.1 Pro Preview",
319 InputTokenLimit: 1048576,
320 OutputTokenLimit: 65536,
321 SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
322 Thinking: &ThinkingSupport{Min: 1, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}},
323 },
309 {324 {
310 ID: "gemini-3-pro-image-preview",325 ID: "gemini-3-pro-image-preview",
311 Object: "model",326 Object: "model",
internal/translator/codex/claude/codex_claude_response.go+21−2
@@ -22,8 +22,9 @@ var ( · 21 unmodified lines
22 22
23// ConvertCodexResponseToClaudeParams holds parameters for response conversion.23// ConvertCodexResponseToClaudeParams holds parameters for response conversion.
24type ConvertCodexResponseToClaudeParams struct {24type ConvertCodexResponseToClaudeParams struct {
25 HasToolCall bool25 HasToolCall bool
26 BlockIndex int26 BlockIndex int
27 HasReceivedArgumentsDelta bool
27}28}
28 29
29// ConvertCodexResponseToClaude performs sophisticated streaming response format conversion.30// ConvertCodexResponseToClaude performs sophisticated streaming response format conversion.
@@ -137,6 +138,7 @@ func ConvertCodexResponseToClaude(_ context.Context, _ string, originalRequestRa · 107 unmodified lines
137 itemType := itemResult.Get("type").String()138 itemType := itemResult.Get("type").String()
138 if itemType == "function_call" {139 if itemType == "function_call" {
139 (*param).(*ConvertCodexResponseToClaudeParams).HasToolCall = true140 (*param).(*ConvertCodexResponseToClaudeParams).HasToolCall = true
141 (*param).(*ConvertCodexResponseToClaudeParams).HasReceivedArgumentsDelta = false
140 template = `{"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"","name":"","input":{}}}`142 template = `{"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"","name":"","input":{}}}`
141 template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)143 template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)
142 template, _ = sjson.Set(template, "content_block.id", itemResult.Get("call_id").String())144 template, _ = sjson.Set(template, "content_block.id", itemResult.Get("call_id").String())
@@ -171,12 +173,29 @@ func ConvertCodexResponseToClaude(_ context.Context, _ string, originalRequestRa · 28 unmodified lines
171 output += fmt.Sprintf("data: %s\n\n", template)173 output += fmt.Sprintf("data: %s\n\n", template)
172 }174 }
173 } else if typeStr == "response.function_call_arguments.delta" {175 } else if typeStr == "response.function_call_arguments.delta" {
176 (*param).(*ConvertCodexResponseToClaudeParams).HasReceivedArgumentsDelta = true
174 template = `{"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""}}`177 template = `{"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""}}`
175 template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)178 template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)
176 template, _ = sjson.Set(template, "delta.partial_json", rootResult.Get("delta").String())179 template, _ = sjson.Set(template, "delta.partial_json", rootResult.Get("delta").String())
177 180
178 output += "event: content_block_delta\n"181 output += "event: content_block_delta\n"
179 output += fmt.Sprintf("data: %s\n\n", template)182 output += fmt.Sprintf("data: %s\n\n", template)
183 } else if typeStr == "response.function_call_arguments.done" {
184 // Some models (e.g. gpt-5.3-codex-spark) send function call arguments
185 // in a single "done" event without preceding "delta" events.
186 // Emit the full arguments as a single input_json_delta so the
187 // downstream Claude client receives the complete tool input.
188 // When delta events were already received, skip to avoid duplicating arguments.
189 if !(*param).(*ConvertCodexResponseToClaudeParams).HasReceivedArgumentsDelta {
190 if args := rootResult.Get("arguments").String(); args != "" {
191 template = `{"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""}}`
192 template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)
193 template, _ = sjson.Set(template, "delta.partial_json", args)
194
195 output += "event: content_block_delta\n"
196 output += fmt.Sprintf("data: %s\n\n", template)
197 }
198 }
180 }199 }
181 200
182 return []string{output}201 return []string{output}