@victor-software-house/pi-openai-proxy 4.8.0 → 4.9.0
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/index.mjs +38 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1247,15 +1247,23 @@ const REASONING_EFFORT_MAP = {
|
|
|
1247
1247
|
xhigh: "xhigh"
|
|
1248
1248
|
};
|
|
1249
1249
|
/**
|
|
1250
|
-
* APIs that
|
|
1251
|
-
*
|
|
1250
|
+
* APIs that accept the full set of OpenAI passthrough fields (stop, seed, top_p,
|
|
1251
|
+
* tool_choice, frequency_penalty, etc.) as top-level payload properties.
|
|
1252
1252
|
*/
|
|
1253
|
-
const
|
|
1253
|
+
const OPENAI_FULL_PASSTHROUGH_APIS = new Set([
|
|
1254
1254
|
"openai-completions",
|
|
1255
1255
|
"openai-responses",
|
|
1256
1256
|
"azure-openai-responses",
|
|
1257
1257
|
"mistral-conversations"
|
|
1258
1258
|
]);
|
|
1259
|
+
/**
|
|
1260
|
+
* The Codex Responses API accepts only tool_choice and parallel_tool_calls.
|
|
1261
|
+
* Other standard fields (top_p, seed, stop, user, frequency_penalty, etc.)
|
|
1262
|
+
* are rejected with "Unsupported parameter". The SDK hardcodes
|
|
1263
|
+
* tool_choice: "auto" and parallel_tool_calls: true; onPayload overrides
|
|
1264
|
+
* those when the client sends explicit values.
|
|
1265
|
+
*/
|
|
1266
|
+
const CODEX_APIS = new Set(["openai-codex-responses"]);
|
|
1259
1267
|
const ANTHROPIC_APIS = new Set(["anthropic-messages"]);
|
|
1260
1268
|
const GOOGLE_APIS = new Set([
|
|
1261
1269
|
"google-generative-ai",
|
|
@@ -1462,13 +1470,36 @@ function patchGooglePayload(payload, request) {
|
|
|
1462
1470
|
return patched;
|
|
1463
1471
|
}
|
|
1464
1472
|
/**
|
|
1473
|
+
* Collect the restricted set of fields the Codex Responses API accepts.
|
|
1474
|
+
*
|
|
1475
|
+
* Only tool_choice and parallel_tool_calls are supported. The SDK hardcodes
|
|
1476
|
+
* tool_choice: "auto" and parallel_tool_calls: true; these overrides let clients
|
|
1477
|
+
* control tool behavior explicitly.
|
|
1478
|
+
*
|
|
1479
|
+
* @internal Exported for unit testing only.
|
|
1480
|
+
*/
|
|
1481
|
+
function collectCodexPayloadFields(request) {
|
|
1482
|
+
const fields = {};
|
|
1483
|
+
let hasFields = false;
|
|
1484
|
+
if (request.tool_choice !== void 0) {
|
|
1485
|
+
fields["tool_choice"] = request.tool_choice;
|
|
1486
|
+
hasFields = true;
|
|
1487
|
+
}
|
|
1488
|
+
if (request.parallel_tool_calls !== void 0) {
|
|
1489
|
+
fields["parallel_tool_calls"] = request.parallel_tool_calls;
|
|
1490
|
+
hasFields = true;
|
|
1491
|
+
}
|
|
1492
|
+
return hasFields ? fields : void 0;
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1465
1495
|
* Collect API-specific payload fields from an OpenAI request.
|
|
1466
1496
|
*
|
|
1467
1497
|
* Dispatches to the appropriate translator based on the target API:
|
|
1468
|
-
* - OpenAI
|
|
1498
|
+
* - OpenAI full passthrough: all standard fields (same names)
|
|
1499
|
+
* - Codex: restricted to tool_choice + parallel_tool_calls only
|
|
1469
1500
|
* - Anthropic: translated field names and formats
|
|
1470
1501
|
* - Google: nested generationConfig patching (handled separately in onPayload)
|
|
1471
|
-
* - Others (Bedrock
|
|
1502
|
+
* - Others (Bedrock): no passthrough
|
|
1472
1503
|
*
|
|
1473
1504
|
* For Google APIs, returns undefined (patching is done directly in onPayload
|
|
1474
1505
|
* via patchGooglePayload because the payload structure is nested).
|
|
@@ -1476,7 +1507,8 @@ function patchGooglePayload(payload, request) {
|
|
|
1476
1507
|
* @internal Exported for unit testing only.
|
|
1477
1508
|
*/
|
|
1478
1509
|
function collectPayloadFields(request, api) {
|
|
1479
|
-
if (
|
|
1510
|
+
if (OPENAI_FULL_PASSTHROUGH_APIS.has(api)) return collectOpenAIPayloadFields(request);
|
|
1511
|
+
if (CODEX_APIS.has(api)) return collectCodexPayloadFields(request);
|
|
1480
1512
|
if (ANTHROPIC_APIS.has(api)) return collectAnthropicPayloadFields(request);
|
|
1481
1513
|
}
|
|
1482
1514
|
/**
|
package/package.json
CHANGED