feat: support Responses to Chat (#5787)
* fix(openai): harden Chat-to-Responses compatibility Add a shared Responses-to-Chat stream state machine and use it from the OpenAI relay path. Preserve assistant text alongside tool calls, bind tool argument deltas by output_index, map incomplete finish reasons, support reasoning/custom tool events, and buffer upstream SSE for non-stream Chat clients. Add deterministic service tests and relay SSE tests for the conversion path. Related to #5745. * refactor: rename openaicompat to relayconvert for improved clarity * feat(gemini): support responses request conversion * feat: add responses to chat conversion support * fix: harden responses chat conversion edge cases
This commit is contained in:
@@ -43,6 +43,10 @@ export const ADVANCED_CUSTOM_CONVERTER_OPTIONS: Array<{
|
||||
value: 'openai_chat_completions_to_openai_responses',
|
||||
label: 'OpenAI Chat to OpenAI Responses',
|
||||
},
|
||||
{
|
||||
value: 'openai_responses_to_openai_chat_completions',
|
||||
label: 'OpenAI Responses to OpenAI Chat',
|
||||
},
|
||||
{
|
||||
value: 'gemini_generate_content_to_openai_chat_completions',
|
||||
label: 'Gemini Generate Content to OpenAI Chat',
|
||||
@@ -326,6 +330,9 @@ export function getAdvancedCustomUpstreamPathPlaceholder(
|
||||
if (converter === 'openai_chat_completions_to_anthropic_messages') {
|
||||
return '/v1/messages'
|
||||
}
|
||||
if (converter === 'openai_responses_to_openai_chat_completions') {
|
||||
return '/v1/chat/completions'
|
||||
}
|
||||
return '/v1/chat/completions'
|
||||
}
|
||||
|
||||
@@ -573,6 +580,9 @@ function isConverterPathAllowed(
|
||||
) {
|
||||
return incomingPath === '/v1/chat/completions'
|
||||
}
|
||||
if (converter === 'openai_responses_to_openai_chat_completions') {
|
||||
return incomingPath === '/v1/responses'
|
||||
}
|
||||
return (
|
||||
incomingPath.includes(':generateContent') ||
|
||||
incomingPath.includes(':streamGenerateContent')
|
||||
|
||||
+1
@@ -131,6 +131,7 @@ export type AdvancedCustomConverter =
|
||||
| 'anthropic_messages_to_openai_chat_completions'
|
||||
| 'openai_chat_completions_to_anthropic_messages'
|
||||
| 'openai_chat_completions_to_openai_responses'
|
||||
| 'openai_responses_to_openai_chat_completions'
|
||||
| 'gemini_generate_content_to_openai_chat_completions'
|
||||
| 'openai_chat_completions_to_gemini_generate_content'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user