extrait 0.7.2 → 0.7.3
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.cjs +8 -2
- package/dist/index.js +8 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1710,7 +1710,8 @@ function createOpenAICompatibleAdapter(options) {
|
|
|
1710
1710
|
async function streamWithChatCompletionsPassThrough(options, fetcher, path, request, callbacks) {
|
|
1711
1711
|
const response = await sendOpenAIRequest(options, fetcher, path, request, buildChatCompletionsBody(options, request, {
|
|
1712
1712
|
messages: buildMessages(request),
|
|
1713
|
-
stream: true
|
|
1713
|
+
stream: true,
|
|
1714
|
+
stream_options: streamUsageOptions(request)
|
|
1714
1715
|
}));
|
|
1715
1716
|
if (!response.ok) {
|
|
1716
1717
|
const message = await response.text();
|
|
@@ -1802,6 +1803,10 @@ async function completeOpenAIRequest(options, fetcher, chatPath, responsesPath,
|
|
|
1802
1803
|
function buildChatCompletionsBody(options, request, overrides) {
|
|
1803
1804
|
return buildOpenAIRequestBody(options, request, "max_tokens", overrides);
|
|
1804
1805
|
}
|
|
1806
|
+
function streamUsageOptions(request) {
|
|
1807
|
+
const userOptions = isRecord2(request.body?.stream_options) ? request.body.stream_options : undefined;
|
|
1808
|
+
return { include_usage: true, ...userOptions };
|
|
1809
|
+
}
|
|
1805
1810
|
function buildResponsesBody(options, request, overrides) {
|
|
1806
1811
|
return buildOpenAIRequestBody(options, request, "max_output_tokens", overrides);
|
|
1807
1812
|
}
|
|
@@ -2059,7 +2064,8 @@ async function streamWithChatCompletionsWithMCP(options, fetcher, path, request,
|
|
|
2059
2064
|
tools: transportTools,
|
|
2060
2065
|
tool_choice: request.toolChoice,
|
|
2061
2066
|
parallel_tool_calls: request.parallelToolCalls,
|
|
2062
|
-
stream: true
|
|
2067
|
+
stream: true,
|
|
2068
|
+
stream_options: streamUsageOptions(request)
|
|
2063
2069
|
}));
|
|
2064
2070
|
if (!response.ok) {
|
|
2065
2071
|
const message = await response.text();
|
package/dist/index.js
CHANGED
|
@@ -1619,7 +1619,8 @@ function createOpenAICompatibleAdapter(options) {
|
|
|
1619
1619
|
async function streamWithChatCompletionsPassThrough(options, fetcher, path, request, callbacks) {
|
|
1620
1620
|
const response = await sendOpenAIRequest(options, fetcher, path, request, buildChatCompletionsBody(options, request, {
|
|
1621
1621
|
messages: buildMessages(request),
|
|
1622
|
-
stream: true
|
|
1622
|
+
stream: true,
|
|
1623
|
+
stream_options: streamUsageOptions(request)
|
|
1623
1624
|
}));
|
|
1624
1625
|
if (!response.ok) {
|
|
1625
1626
|
const message = await response.text();
|
|
@@ -1711,6 +1712,10 @@ async function completeOpenAIRequest(options, fetcher, chatPath, responsesPath,
|
|
|
1711
1712
|
function buildChatCompletionsBody(options, request, overrides) {
|
|
1712
1713
|
return buildOpenAIRequestBody(options, request, "max_tokens", overrides);
|
|
1713
1714
|
}
|
|
1715
|
+
function streamUsageOptions(request) {
|
|
1716
|
+
const userOptions = isRecord2(request.body?.stream_options) ? request.body.stream_options : undefined;
|
|
1717
|
+
return { include_usage: true, ...userOptions };
|
|
1718
|
+
}
|
|
1714
1719
|
function buildResponsesBody(options, request, overrides) {
|
|
1715
1720
|
return buildOpenAIRequestBody(options, request, "max_output_tokens", overrides);
|
|
1716
1721
|
}
|
|
@@ -1968,7 +1973,8 @@ async function streamWithChatCompletionsWithMCP(options, fetcher, path, request,
|
|
|
1968
1973
|
tools: transportTools,
|
|
1969
1974
|
tool_choice: request.toolChoice,
|
|
1970
1975
|
parallel_tool_calls: request.parallelToolCalls,
|
|
1971
|
-
stream: true
|
|
1976
|
+
stream: true,
|
|
1977
|
+
stream_options: streamUsageOptions(request)
|
|
1972
1978
|
}));
|
|
1973
1979
|
if (!response.ok) {
|
|
1974
1980
|
const message = await response.text();
|