@openrouter/ai-sdk-provider 1.5.1 → 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.mjs
CHANGED
|
@@ -1804,9 +1804,15 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1804
1804
|
const fileAnnotations = (_k = choice.message.annotations) == null ? void 0 : _k.filter(
|
|
1805
1805
|
(a) => a.type === "file"
|
|
1806
1806
|
);
|
|
1807
|
+
const hasToolCalls = choice.message.tool_calls && choice.message.tool_calls.length > 0;
|
|
1808
|
+
const hasEncryptedReasoning = reasoningDetails.some(
|
|
1809
|
+
(d) => d.type === "reasoning.encrypted" /* Encrypted */ && d.data
|
|
1810
|
+
);
|
|
1811
|
+
const shouldOverrideFinishReason = hasToolCalls && hasEncryptedReasoning && choice.finish_reason === "stop";
|
|
1812
|
+
const effectiveFinishReason = shouldOverrideFinishReason ? "tool-calls" : mapOpenRouterFinishReason(choice.finish_reason);
|
|
1807
1813
|
return {
|
|
1808
1814
|
content,
|
|
1809
|
-
finishReason:
|
|
1815
|
+
finishReason: effectiveFinishReason,
|
|
1810
1816
|
usage: usageInfo,
|
|
1811
1817
|
warnings: [],
|
|
1812
1818
|
providerMetadata: {
|
|
@@ -2184,6 +2190,13 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2184
2190
|
},
|
|
2185
2191
|
flush(controller) {
|
|
2186
2192
|
var _a16;
|
|
2193
|
+
const hasToolCalls = toolCalls.length > 0;
|
|
2194
|
+
const hasEncryptedReasoning = accumulatedReasoningDetails.some(
|
|
2195
|
+
(d) => d.type === "reasoning.encrypted" /* Encrypted */ && d.data
|
|
2196
|
+
);
|
|
2197
|
+
if (hasToolCalls && hasEncryptedReasoning && finishReason === "stop") {
|
|
2198
|
+
finishReason = "tool-calls";
|
|
2199
|
+
}
|
|
2187
2200
|
if (finishReason === "tool-calls") {
|
|
2188
2201
|
for (const toolCall of toolCalls) {
|
|
2189
2202
|
if (toolCall && !toolCall.sent) {
|