@@ -8,6 +8,10 @@ import { register } from "../index.js";
|
|||||||
import { FORMATS } from "../formats.js";
|
import { FORMATS } from "../formats.js";
|
||||||
import { normalizeResponsesInput } from "../helpers/responsesApiHelper.js";
|
import { normalizeResponsesInput } from "../helpers/responsesApiHelper.js";
|
||||||
|
|
||||||
|
// Responses API enforces max 64 chars on call_id (#393)
|
||||||
|
const MAX_CALL_ID_LEN = 64;
|
||||||
|
const clampCallId = (id) => (typeof id === "string" && id.length > MAX_CALL_ID_LEN ? id.substring(0, MAX_CALL_ID_LEN) : id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert OpenAI Responses API request to OpenAI Chat Completions format
|
* Convert OpenAI Responses API request to OpenAI Chat Completions format
|
||||||
*/
|
*/
|
||||||
@@ -221,7 +225,7 @@ export function openaiToOpenAIResponsesRequest(model, body, stream, credentials)
|
|||||||
for (const tc of msg.tool_calls) {
|
for (const tc of msg.tool_calls) {
|
||||||
result.input.push({
|
result.input.push({
|
||||||
type: "function_call",
|
type: "function_call",
|
||||||
call_id: tc.id,
|
call_id: clampCallId(tc.id),
|
||||||
name: tc.function?.name || "",
|
name: tc.function?.name || "",
|
||||||
arguments: tc.function?.arguments || "{}"
|
arguments: tc.function?.arguments || "{}"
|
||||||
});
|
});
|
||||||
@@ -237,7 +241,7 @@ export function openaiToOpenAIResponsesRequest(model, body, stream, credentials)
|
|||||||
: JSON.stringify(msg.content);
|
: JSON.stringify(msg.content);
|
||||||
result.input.push({
|
result.input.push({
|
||||||
type: "function_call_output",
|
type: "function_call_output",
|
||||||
call_id: msg.tool_call_id,
|
call_id: clampCallId(msg.tool_call_id),
|
||||||
output
|
output
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user