@openrouter/ai-sdk-provider 1.5.0 → 1.5.2
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.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +14 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +14 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.js
CHANGED
|
@@ -1838,9 +1838,15 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1838
1838
|
const fileAnnotations = (_k = choice.message.annotations) == null ? void 0 : _k.filter(
|
|
1839
1839
|
(a) => a.type === "file"
|
|
1840
1840
|
);
|
|
1841
|
+
const hasToolCalls = choice.message.tool_calls && choice.message.tool_calls.length > 0;
|
|
1842
|
+
const hasEncryptedReasoning = reasoningDetails.some(
|
|
1843
|
+
(d) => d.type === "reasoning.encrypted" /* Encrypted */ && d.data
|
|
1844
|
+
);
|
|
1845
|
+
const shouldOverrideFinishReason = hasToolCalls && hasEncryptedReasoning && choice.finish_reason === "stop";
|
|
1846
|
+
const effectiveFinishReason = shouldOverrideFinishReason ? "tool-calls" : mapOpenRouterFinishReason(choice.finish_reason);
|
|
1841
1847
|
return {
|
|
1842
1848
|
content,
|
|
1843
|
-
finishReason:
|
|
1849
|
+
finishReason: effectiveFinishReason,
|
|
1844
1850
|
usage: usageInfo,
|
|
1845
1851
|
warnings: [],
|
|
1846
1852
|
providerMetadata: {
|
|
@@ -2218,6 +2224,13 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2218
2224
|
},
|
|
2219
2225
|
flush(controller) {
|
|
2220
2226
|
var _a16;
|
|
2227
|
+
const hasToolCalls = toolCalls.length > 0;
|
|
2228
|
+
const hasEncryptedReasoning = accumulatedReasoningDetails.some(
|
|
2229
|
+
(d) => d.type === "reasoning.encrypted" /* Encrypted */ && d.data
|
|
2230
|
+
);
|
|
2231
|
+
if (hasToolCalls && hasEncryptedReasoning && finishReason === "stop") {
|
|
2232
|
+
finishReason = "tool-calls";
|
|
2233
|
+
}
|
|
2221
2234
|
if (finishReason === "tool-calls") {
|
|
2222
2235
|
for (const toolCall of toolCalls) {
|
|
2223
2236
|
if (toolCall && !toolCall.sent) {
|