refactor: deduplicate and improve OpenAI Responses API conversion

- Extract shared map_responses_stop_reason and build_anthropic_usage_from_responses into transform_responses.rs as pub(crate)
- Align cache token extraction priority: OpenAI nested details as fallback, direct Anthropic fields as override
- Extract resolve_content_index helper to eliminate 3x copy-paste in streaming_responses.rs
- Add streaming reasoning/thinking event handlers (response.reasoning.delta/done)
- Add explanatory comment to transform_response heuristic detection
- Add openai_responses to api_format doc comment and needs_transform test
- Add explicit no-op match arms for lifecycle events
- Add promptCacheKey to TS ProviderMeta type
- Update toast i18n key to be generic for both OpenAI formats (zh/en/ja)
This commit is contained in:
Jason
2026-03-05 21:52:41 +08:00
parent a30e2096bb
commit 11f70f676e
11 changed files with 1201 additions and 110 deletions
+3 -3
View File
@@ -155,11 +155,11 @@ export function useProviderActions(activeApp: AppId) {
(provider.meta?.apiFormat === "openai_chat" ||
provider.meta?.apiFormat === "openai_responses")
) {
// OpenAI Chat 格式供应商:显示代理提示
// OpenAI format provider: show proxy hint
toast.info(
t("notifications.openAIChatFormatHint", {
t("notifications.openAIFormatHint", {
defaultValue:
"此供应商使用 OpenAI Chat 格式,需要开启代理服务才能正常使用",
"此供应商使用 OpenAI 兼容格式,需要开启代理服务才能正常使用",
}),
{
duration: 5000,