@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.js
CHANGED
|
@@ -2707,7 +2707,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
2707
2707
|
}
|
|
2708
2708
|
const contentParts = content.map(
|
|
2709
2709
|
(part, index) => {
|
|
2710
|
-
var _a17, _b17, _c2, _d2, _e2, _f2;
|
|
2710
|
+
var _a17, _b17, _c2, _d2, _e2, _f2, _g2;
|
|
2711
2711
|
const isLastTextPart = part.type === "text" && index === lastTextPartIndex;
|
|
2712
2712
|
const partCacheControl = getCacheControl(part.providerOptions);
|
|
2713
2713
|
const cacheControl = part.type === "text" ? partCacheControl != null ? partCacheControl : isLastTextPart ? messageCacheControl : void 0 : partCacheControl;
|
|
@@ -2730,14 +2730,26 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
2730
2730
|
}
|
|
2731
2731
|
}, cacheControl && { cache_control: cacheControl });
|
|
2732
2732
|
}
|
|
2733
|
-
if ((_b17 = part.mediaType) == null ? void 0 : _b17.startsWith("
|
|
2733
|
+
if ((_b17 = part.mediaType) == null ? void 0 : _b17.startsWith("video/")) {
|
|
2734
|
+
const url = getFileUrl({
|
|
2735
|
+
part,
|
|
2736
|
+
defaultMediaType: "video/mp4"
|
|
2737
|
+
});
|
|
2738
|
+
return __spreadValues({
|
|
2739
|
+
type: "video_url",
|
|
2740
|
+
video_url: {
|
|
2741
|
+
url
|
|
2742
|
+
}
|
|
2743
|
+
}, cacheControl && { cache_control: cacheControl });
|
|
2744
|
+
}
|
|
2745
|
+
if ((_c2 = part.mediaType) == null ? void 0 : _c2.startsWith("audio/")) {
|
|
2734
2746
|
return __spreadValues({
|
|
2735
2747
|
type: "input_audio",
|
|
2736
2748
|
input_audio: getInputAudioData(part)
|
|
2737
2749
|
}, cacheControl && { cache_control: cacheControl });
|
|
2738
2750
|
}
|
|
2739
2751
|
const fileName = String(
|
|
2740
|
-
(
|
|
2752
|
+
(_g2 = (_f2 = (_e2 = (_d2 = part.providerOptions) == null ? void 0 : _d2.openrouter) == null ? void 0 : _e2.filename) != null ? _f2 : part.filename) != null ? _g2 : ""
|
|
2741
2753
|
);
|
|
2742
2754
|
const fileData = getFileUrl({
|
|
2743
2755
|
part,
|
|
@@ -2895,7 +2907,7 @@ function getToolResultContent(input) {
|
|
|
2895
2907
|
}
|
|
2896
2908
|
function mapToolResultContentParts(parts) {
|
|
2897
2909
|
return parts.map((part) => {
|
|
2898
|
-
var _a16, _b16, _c;
|
|
2910
|
+
var _a16, _b16, _c, _d;
|
|
2899
2911
|
switch (part.type) {
|
|
2900
2912
|
case "text":
|
|
2901
2913
|
return { type: "text", text: part.text };
|
|
@@ -2927,7 +2939,13 @@ function mapToolResultContentParts(parts) {
|
|
|
2927
2939
|
image_url: { url: dataUrl }
|
|
2928
2940
|
};
|
|
2929
2941
|
}
|
|
2930
|
-
if ((_b16 = part.mediaType) == null ? void 0 : _b16.startsWith("
|
|
2942
|
+
if ((_b16 = part.mediaType) == null ? void 0 : _b16.startsWith("video/")) {
|
|
2943
|
+
return {
|
|
2944
|
+
type: "video_url",
|
|
2945
|
+
video_url: { url: dataUrl }
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
if ((_c = part.mediaType) == null ? void 0 : _c.startsWith("audio/")) {
|
|
2931
2949
|
const rawFormat = part.mediaType.replace("audio/", "");
|
|
2932
2950
|
const format = MIME_TO_FORMAT[rawFormat];
|
|
2933
2951
|
if (format !== void 0) {
|
|
@@ -2943,7 +2961,7 @@ function mapToolResultContentParts(parts) {
|
|
|
2943
2961
|
return {
|
|
2944
2962
|
type: "file",
|
|
2945
2963
|
file: {
|
|
2946
|
-
filename: (
|
|
2964
|
+
filename: (_d = part.filename) != null ? _d : "",
|
|
2947
2965
|
file_data: dataUrl
|
|
2948
2966
|
}
|
|
2949
2967
|
};
|
|
@@ -3552,7 +3570,8 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3552
3570
|
response: {
|
|
3553
3571
|
id: response.id,
|
|
3554
3572
|
modelId: response.model,
|
|
3555
|
-
headers: responseHeaders
|
|
3573
|
+
headers: responseHeaders,
|
|
3574
|
+
body: response
|
|
3556
3575
|
}
|
|
3557
3576
|
};
|
|
3558
3577
|
}
|
|
@@ -4813,7 +4832,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
4813
4832
|
}
|
|
4814
4833
|
|
|
4815
4834
|
// src/version.ts
|
|
4816
|
-
var VERSION2 = false ? "0.0.0-test" : "2.
|
|
4835
|
+
var VERSION2 = false ? "0.0.0-test" : "2.5.0";
|
|
4817
4836
|
|
|
4818
4837
|
// src/provider.ts
|
|
4819
4838
|
function createOpenRouter(options = {}) {
|