@jaypie/llm 1.2.17 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.cjs
CHANGED
|
@@ -2229,7 +2229,7 @@ class OpenAiAdapter extends BaseProviderAdapter {
|
|
|
2229
2229
|
const model = request.model || this.defaultModel;
|
|
2230
2230
|
const openaiRequest = {
|
|
2231
2231
|
model,
|
|
2232
|
-
input: request.messages,
|
|
2232
|
+
input: this.sanitizeInputItems(request.messages),
|
|
2233
2233
|
};
|
|
2234
2234
|
if (request.user) {
|
|
2235
2235
|
openaiRequest.user = request.user;
|
|
@@ -2577,6 +2577,31 @@ class OpenAiAdapter extends BaseProviderAdapter {
|
|
|
2577
2577
|
//
|
|
2578
2578
|
// Private Helpers
|
|
2579
2579
|
//
|
|
2580
|
+
/**
|
|
2581
|
+
* Sanitize history items for the OpenAI Responses API.
|
|
2582
|
+
* Strips fields not accepted by specific item types (e.g., `name` on
|
|
2583
|
+
* function_call_output items) to prevent 400 "Unknown parameter" errors.
|
|
2584
|
+
*/
|
|
2585
|
+
sanitizeInputItems(messages) {
|
|
2586
|
+
return messages.map((item) => {
|
|
2587
|
+
const typedItem = item;
|
|
2588
|
+
// function_call_output only accepts: type, call_id, output, id, status
|
|
2589
|
+
if (typedItem.type === exports.LlmMessageType.FunctionCallOutput) {
|
|
2590
|
+
const sanitized = {
|
|
2591
|
+
type: typedItem.type,
|
|
2592
|
+
call_id: typedItem.call_id,
|
|
2593
|
+
output: typedItem.output,
|
|
2594
|
+
};
|
|
2595
|
+
if (typedItem.id)
|
|
2596
|
+
sanitized.id = typedItem.id;
|
|
2597
|
+
if (typedItem.status)
|
|
2598
|
+
sanitized.status = typedItem.status;
|
|
2599
|
+
return sanitized;
|
|
2600
|
+
}
|
|
2601
|
+
// All other items pass through as-is
|
|
2602
|
+
return item;
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2580
2605
|
hasToolCalls(response) {
|
|
2581
2606
|
if (!response.output || !Array.isArray(response.output)) {
|
|
2582
2607
|
return false;
|