This commit is contained in:
@@ -185,6 +185,14 @@ export async function handleNonStreamingResponse({ providerResponse, provider, m
|
|||||||
translatedResponse.usage = filterUsageForFormat(addBufferToUsage(translatedResponse.usage), sourceFormat);
|
translatedResponse.usage = filterUsageForFormat(addBufferToUsage(translatedResponse.usage), sourceFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip reasoning_content — some clients (e.g. Firecrawl AI SDK) have JSON parsers that
|
||||||
|
// break on this non-standard field, even though OpenAI allows it in extensions.
|
||||||
|
if (translatedResponse?.choices) {
|
||||||
|
for (const choice of translatedResponse.choices) {
|
||||||
|
if (choice?.message) delete choice.message.reasoning_content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reqLogger.logConvertedResponse(translatedResponse);
|
reqLogger.logConvertedResponse(translatedResponse);
|
||||||
|
|
||||||
const totalLatency = Date.now() - requestStartTime;
|
const totalLatency = Date.now() - requestStartTime;
|
||||||
|
|||||||
@@ -210,6 +210,13 @@ export async function handleForcedSSEToJson({ providerResponse, sourceFormat, pr
|
|||||||
status: "success"
|
status: "success"
|
||||||
}, { endpoint: clientRawRequest?.endpoint || null })).catch(() => {});
|
}, { endpoint: clientRawRequest?.endpoint || null })).catch(() => {});
|
||||||
|
|
||||||
|
// Strip reasoning_content — breaks JSON parsers in some clients (e.g. Firecrawl AI SDK)
|
||||||
|
if (parsed?.choices) {
|
||||||
|
for (const choice of parsed.choices) {
|
||||||
|
if (choice?.message) delete choice.message.reasoning_content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { success: true, response: new Response(JSON.stringify(parsed), { headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" } }) };
|
return { success: true, response: new Response(JSON.stringify(parsed), { headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" } }) };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[ChatCore] Chat Completions SSE→JSON failed:", err);
|
console.error("[ChatCore] Chat Completions SSE→JSON failed:", err);
|
||||||
|
|||||||
Reference in New Issue
Block a user