Add reasoning/thinking configuration handling for Claude and OpenAI translators

- Implemented `thinkingConfig` handling to allow reasoning effort configuration in request generation.
- Added support for reasoning content deltas (`thinking_delta`) in response processing.
- Enhanced reasoning-related token budget mappings for various reasoning levels.
- Improved response handling logic to ensure proper reasoning content inclusion.
This commit is contained in:
Luis Pater
2025-09-04 09:43:22 +08:00
parent 9b627a93ac
commit f1d6f01585
5 changed files with 59 additions and 5 deletions

View File

@@ -41,6 +41,21 @@ func ConvertOpenAIRequestToClaude(modelName string, inputRawJSON []byte, stream
root := gjson.ParseBytes(rawJSON)
if v := root.Get("reasoning_effort"); v.Exists() {
out, _ = sjson.Set(out, "thinking.type", "enabled")
switch v.String() {
case "none":
out, _ = sjson.Set(out, "thinking.type", "disabled")
case "low":
out, _ = sjson.Set(out, "thinking.budget_tokens", 1024)
case "medium":
out, _ = sjson.Set(out, "thinking.budget_tokens", 8192)
case "high":
out, _ = sjson.Set(out, "thinking.budget_tokens", 24576)
}
}
// Helper for generating tool call IDs in the form: toolu_<alphanum>
// This ensures unique identifiers for tool calls in the Claude Code format
genToolCallID := func() string {