@openrouter/ai-sdk-provider 1.2.4 → 1.2.5
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 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +14 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +14 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1106,8 +1106,9 @@ function getCacheControl(providerMetadata) {
|
|
|
1106
1106
|
return (_c = (_b = (_a15 = openrouter2 == null ? void 0 : openrouter2.cacheControl) != null ? _a15 : openrouter2 == null ? void 0 : openrouter2.cache_control) != null ? _b : anthropic == null ? void 0 : anthropic.cacheControl) != null ? _c : anthropic == null ? void 0 : anthropic.cache_control;
|
|
1107
1107
|
}
|
|
1108
1108
|
function convertToOpenRouterChatMessages(prompt) {
|
|
1109
|
-
var _a15, _b, _c, _d, _e;
|
|
1109
|
+
var _a15, _b, _c, _d, _e, _f;
|
|
1110
1110
|
const messages = [];
|
|
1111
|
+
const accumulatedReasoningDetails = [];
|
|
1111
1112
|
for (const { role, content, providerOptions } of prompt) {
|
|
1112
1113
|
switch (role) {
|
|
1113
1114
|
case "system": {
|
|
@@ -1137,7 +1138,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1137
1138
|
const messageCacheControl = getCacheControl(providerOptions);
|
|
1138
1139
|
const contentParts = content.map(
|
|
1139
1140
|
(part) => {
|
|
1140
|
-
var _a16, _b2, _c2, _d2, _e2,
|
|
1141
|
+
var _a16, _b2, _c2, _d2, _e2, _f2;
|
|
1141
1142
|
const cacheControl = (_a16 = getCacheControl(part.providerOptions)) != null ? _a16 : messageCacheControl;
|
|
1142
1143
|
switch (part.type) {
|
|
1143
1144
|
case "text":
|
|
@@ -1163,7 +1164,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1163
1164
|
};
|
|
1164
1165
|
}
|
|
1165
1166
|
const fileName = String(
|
|
1166
|
-
(
|
|
1167
|
+
(_f2 = (_e2 = (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2.openrouter) == null ? void 0 : _d2.filename) != null ? _e2 : part.filename) != null ? _f2 : ""
|
|
1167
1168
|
);
|
|
1168
1169
|
const fileData = getFileUrl({
|
|
1169
1170
|
part,
|
|
@@ -1217,6 +1218,12 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1217
1218
|
break;
|
|
1218
1219
|
}
|
|
1219
1220
|
case "tool-call": {
|
|
1221
|
+
const partReasoningDetails = (_c = part.providerOptions) == null ? void 0 : _c.openrouter;
|
|
1222
|
+
if ((partReasoningDetails == null ? void 0 : partReasoningDetails.reasoning_details) && Array.isArray(partReasoningDetails.reasoning_details)) {
|
|
1223
|
+
accumulatedReasoningDetails.push(
|
|
1224
|
+
...partReasoningDetails.reasoning_details
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1220
1227
|
toolCalls.push({
|
|
1221
1228
|
id: part.toolCallId,
|
|
1222
1229
|
type: "function",
|
|
@@ -1239,14 +1246,14 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1239
1246
|
}
|
|
1240
1247
|
}
|
|
1241
1248
|
const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
|
|
1242
|
-
const
|
|
1249
|
+
const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
|
|
1250
|
+
const finalReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) && messageReasoningDetails.length > 0 ? messageReasoningDetails : accumulatedReasoningDetails.length > 0 ? accumulatedReasoningDetails : void 0;
|
|
1243
1251
|
messages.push({
|
|
1244
1252
|
role: "assistant",
|
|
1245
1253
|
content: text,
|
|
1246
1254
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
1247
1255
|
reasoning: reasoning || void 0,
|
|
1248
|
-
|
|
1249
|
-
reasoning_details: preservedReasoningDetails && Array.isArray(preservedReasoningDetails) && preservedReasoningDetails.length > 0 ? preservedReasoningDetails : void 0,
|
|
1256
|
+
reasoning_details: finalReasoningDetails,
|
|
1250
1257
|
cache_control: getCacheControl(providerOptions)
|
|
1251
1258
|
});
|
|
1252
1259
|
break;
|
|
@@ -1258,7 +1265,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
1258
1265
|
role: "tool",
|
|
1259
1266
|
tool_call_id: toolResponse.toolCallId,
|
|
1260
1267
|
content: content2,
|
|
1261
|
-
cache_control: (
|
|
1268
|
+
cache_control: (_f = getCacheControl(providerOptions)) != null ? _f : getCacheControl(toolResponse.providerOptions)
|
|
1262
1269
|
});
|
|
1263
1270
|
}
|
|
1264
1271
|
break;
|
|
@@ -2621,7 +2628,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
2621
2628
|
}
|
|
2622
2629
|
|
|
2623
2630
|
// src/version.ts
|
|
2624
|
-
var VERSION = false ? "0.0.0-test" : "1.2.
|
|
2631
|
+
var VERSION = false ? "0.0.0-test" : "1.2.5";
|
|
2625
2632
|
|
|
2626
2633
|
// src/provider.ts
|
|
2627
2634
|
function createOpenRouter(options = {}) {
|