@openrouter/ai-sdk-provider 2.4.3 → 2.5.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.js +27 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +26 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +26 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2674,7 +2674,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
2674
2674
|
}
|
|
2675
2675
|
const contentParts = content.map(
|
|
2676
2676
|
(part, index) => {
|
|
2677
|
-
var _a17, _b17, _c2, _d2, _e2, _f2;
|
|
2677
|
+
var _a17, _b17, _c2, _d2, _e2, _f2, _g2;
|
|
2678
2678
|
const isLastTextPart = part.type === "text" && index === lastTextPartIndex;
|
|
2679
2679
|
const partCacheControl = getCacheControl(part.providerOptions);
|
|
2680
2680
|
const cacheControl = part.type === "text" ? partCacheControl != null ? partCacheControl : isLastTextPart ? messageCacheControl : void 0 : partCacheControl;
|
|
@@ -2697,14 +2697,26 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
2697
2697
|
}
|
|
2698
2698
|
}, cacheControl && { cache_control: cacheControl });
|
|
2699
2699
|
}
|
|
2700
|
-
if ((_b17 = part.mediaType) == null ? void 0 : _b17.startsWith("
|
|
2700
|
+
if ((_b17 = part.mediaType) == null ? void 0 : _b17.startsWith("video/")) {
|
|
2701
|
+
const url = getFileUrl({
|
|
2702
|
+
part,
|
|
2703
|
+
defaultMediaType: "video/mp4"
|
|
2704
|
+
});
|
|
2705
|
+
return __spreadValues({
|
|
2706
|
+
type: "video_url",
|
|
2707
|
+
video_url: {
|
|
2708
|
+
url
|
|
2709
|
+
}
|
|
2710
|
+
}, cacheControl && { cache_control: cacheControl });
|
|
2711
|
+
}
|
|
2712
|
+
if ((_c2 = part.mediaType) == null ? void 0 : _c2.startsWith("audio/")) {
|
|
2701
2713
|
return __spreadValues({
|
|
2702
2714
|
type: "input_audio",
|
|
2703
2715
|
input_audio: getInputAudioData(part)
|
|
2704
2716
|
}, cacheControl && { cache_control: cacheControl });
|
|
2705
2717
|
}
|
|
2706
2718
|
const fileName = String(
|
|
2707
|
-
(
|
|
2719
|
+
(_g2 = (_f2 = (_e2 = (_d2 = part.providerOptions) == null ? void 0 : _d2.openrouter) == null ? void 0 : _e2.filename) != null ? _f2 : part.filename) != null ? _g2 : ""
|
|
2708
2720
|
);
|
|
2709
2721
|
const fileData = getFileUrl({
|
|
2710
2722
|
part,
|
|
@@ -2862,7 +2874,7 @@ function getToolResultContent(input) {
|
|
|
2862
2874
|
}
|
|
2863
2875
|
function mapToolResultContentParts(parts) {
|
|
2864
2876
|
return parts.map((part) => {
|
|
2865
|
-
var _a16, _b16, _c;
|
|
2877
|
+
var _a16, _b16, _c, _d;
|
|
2866
2878
|
switch (part.type) {
|
|
2867
2879
|
case "text":
|
|
2868
2880
|
return { type: "text", text: part.text };
|
|
@@ -2894,7 +2906,13 @@ function mapToolResultContentParts(parts) {
|
|
|
2894
2906
|
image_url: { url: dataUrl }
|
|
2895
2907
|
};
|
|
2896
2908
|
}
|
|
2897
|
-
if ((_b16 = part.mediaType) == null ? void 0 : _b16.startsWith("
|
|
2909
|
+
if ((_b16 = part.mediaType) == null ? void 0 : _b16.startsWith("video/")) {
|
|
2910
|
+
return {
|
|
2911
|
+
type: "video_url",
|
|
2912
|
+
video_url: { url: dataUrl }
|
|
2913
|
+
};
|
|
2914
|
+
}
|
|
2915
|
+
if ((_c = part.mediaType) == null ? void 0 : _c.startsWith("audio/")) {
|
|
2898
2916
|
const rawFormat = part.mediaType.replace("audio/", "");
|
|
2899
2917
|
const format = MIME_TO_FORMAT[rawFormat];
|
|
2900
2918
|
if (format !== void 0) {
|
|
@@ -2910,7 +2928,7 @@ function mapToolResultContentParts(parts) {
|
|
|
2910
2928
|
return {
|
|
2911
2929
|
type: "file",
|
|
2912
2930
|
file: {
|
|
2913
|
-
filename: (
|
|
2931
|
+
filename: (_d = part.filename) != null ? _d : "",
|
|
2914
2932
|
file_data: dataUrl
|
|
2915
2933
|
}
|
|
2916
2934
|
};
|
|
@@ -3519,7 +3537,8 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3519
3537
|
response: {
|
|
3520
3538
|
id: response.id,
|
|
3521
3539
|
modelId: response.model,
|
|
3522
|
-
headers: responseHeaders
|
|
3540
|
+
headers: responseHeaders,
|
|
3541
|
+
body: response
|
|
3523
3542
|
}
|
|
3524
3543
|
};
|
|
3525
3544
|
}
|
|
@@ -4780,7 +4799,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
4780
4799
|
}
|
|
4781
4800
|
|
|
4782
4801
|
// src/version.ts
|
|
4783
|
-
var VERSION2 = false ? "0.0.0-test" : "2.
|
|
4802
|
+
var VERSION2 = false ? "0.0.0-test" : "2.5.0";
|
|
4784
4803
|
|
|
4785
4804
|
// src/provider.ts
|
|
4786
4805
|
function createOpenRouter(options = {}) {
|