mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-18 13:23:33 +08:00
fix: openaiResponsesToAnthropic usage fallback for OpenAI-compatible APIs
Non-streaming adapter only read `output_tokens`/`input_tokens` (Anthropic-style), but many OpenAI-compatible providers (e.g. Jiutian MoMA) return standard `completion_tokens`/`prompt_tokens` fields. This caused a null reference error when reading `output_tokens` from such responses. The streaming adapter already handles `completion_tokens` correctly, and the Azure adapter uses the same fallback pattern applied here. Fixes #383 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
dbb8c95905
commit
3759588f5b
@ -38,8 +38,8 @@ export function openaiResponsesToAnthropic(response: OpenAIResponsesResponse, mo
|
||||
stop_reason: mapStatus(response.status, hasToolUse),
|
||||
stop_sequence: null,
|
||||
usage: {
|
||||
input_tokens: response.usage?.input_tokens || 0,
|
||||
output_tokens: response.usage?.output_tokens || 0,
|
||||
input_tokens: response.usage?.input_tokens ?? response.usage?.prompt_tokens ?? 0,
|
||||
output_tokens: response.usage?.output_tokens ?? response.usage?.completion_tokens ?? 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user