@ai-sdk/deepseek 3.0.49 → 3.0.50
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/CHANGELOG.md +6 -0
- package/dist/index.js +78 -15
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +77 -14
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat/convert-to-deepseek-chat-messages.ts +107 -18
- package/src/chat/deepseek-chat-api-types.ts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -136,6 +136,27 @@ var supportedImageMediaTypes = /* @__PURE__ */ new Set([
|
|
|
136
136
|
"image/png",
|
|
137
137
|
"image/webp"
|
|
138
138
|
]);
|
|
139
|
+
function resolveDeepSeekImageMediaType(part) {
|
|
140
|
+
const resolvedMediaType = resolveFullMediaType({ part });
|
|
141
|
+
if (!supportedImageMediaTypes.has(resolvedMediaType)) {
|
|
142
|
+
throw new UnsupportedFunctionalityError({
|
|
143
|
+
functionality: `DeepSeek image media type ${resolvedMediaType}`,
|
|
144
|
+
message: "DeepSeek supports JPEG, PNG, GIF, and WebP image inputs."
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return resolvedMediaType;
|
|
148
|
+
}
|
|
149
|
+
function validateDeepSeekImageUrl({
|
|
150
|
+
url,
|
|
151
|
+
prompt
|
|
152
|
+
}) {
|
|
153
|
+
if (url.length > 8192) {
|
|
154
|
+
throw new InvalidPromptError({
|
|
155
|
+
prompt,
|
|
156
|
+
message: "DeepSeek image URLs must not exceed 8192 characters."
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
139
160
|
async function convertToDeepSeekChatMessages({
|
|
140
161
|
prompt,
|
|
141
162
|
responseFormat,
|
|
@@ -242,21 +263,10 @@ async function convertToDeepSeekChatMessages({
|
|
|
242
263
|
})
|
|
243
264
|
});
|
|
244
265
|
} else if (part.data.type === "url" || part.data.type === "data") {
|
|
245
|
-
const resolvedMediaType =
|
|
246
|
-
if (!supportedImageMediaTypes.has(resolvedMediaType)) {
|
|
247
|
-
throw new UnsupportedFunctionalityError({
|
|
248
|
-
functionality: `DeepSeek image media type ${resolvedMediaType}`,
|
|
249
|
-
message: "DeepSeek supports JPEG, PNG, GIF, and WebP image inputs."
|
|
250
|
-
});
|
|
251
|
-
}
|
|
266
|
+
const resolvedMediaType = resolveDeepSeekImageMediaType(part);
|
|
252
267
|
if (part.data.type === "url") {
|
|
253
268
|
const url = part.data.url.toString();
|
|
254
|
-
|
|
255
|
-
throw new InvalidPromptError({
|
|
256
|
-
prompt,
|
|
257
|
-
message: "DeepSeek image URLs must not exceed 8192 characters."
|
|
258
|
-
});
|
|
259
|
-
}
|
|
269
|
+
validateDeepSeekImageUrl({ url, prompt });
|
|
260
270
|
if ((filePartOptions == null ? void 0 : filePartOptions.fileData) === true) {
|
|
261
271
|
throw new InvalidPromptError({
|
|
262
272
|
prompt,
|
|
@@ -403,11 +413,64 @@ async function convertToDeepSeekChatMessages({
|
|
|
403
413
|
case "execution-denied":
|
|
404
414
|
contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
|
|
405
415
|
break;
|
|
406
|
-
case "content":
|
|
407
416
|
case "json":
|
|
408
417
|
case "error-json":
|
|
409
418
|
contentValue = JSON.stringify(output.value);
|
|
410
419
|
break;
|
|
420
|
+
case "content": {
|
|
421
|
+
const hasImagePart = output.value.some(
|
|
422
|
+
(part) => part.type === "file" && (part.data.type === "reference" || part.data.type === "url" || part.data.type === "data") && getTopLevelMediaType(part.mediaType) === "image"
|
|
423
|
+
);
|
|
424
|
+
if (!hasImagePart) {
|
|
425
|
+
contentValue = JSON.stringify(output.value);
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
contentValue = [];
|
|
429
|
+
for (const part of output.value) {
|
|
430
|
+
if (part.type === "text") {
|
|
431
|
+
contentValue.push({ type: "text", text: part.text });
|
|
432
|
+
} else if (part.type === "file" && (part.data.type === "reference" || part.data.type === "url" || part.data.type === "data") && getTopLevelMediaType(part.mediaType) === "image") {
|
|
433
|
+
if (part.data.type === "reference") {
|
|
434
|
+
contentValue.push({
|
|
435
|
+
type: "file",
|
|
436
|
+
file_id: resolveProviderReference({
|
|
437
|
+
reference: part.data.reference,
|
|
438
|
+
provider: "deepseek"
|
|
439
|
+
})
|
|
440
|
+
});
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
const filePartOptions = await parseProviderOptions({
|
|
444
|
+
provider: providerOptionsName,
|
|
445
|
+
providerOptions: part.providerOptions,
|
|
446
|
+
schema: deepseekFilePartProviderOptions
|
|
447
|
+
});
|
|
448
|
+
const resolvedMediaType = resolveDeepSeekImageMediaType(part);
|
|
449
|
+
let url;
|
|
450
|
+
if (part.data.type === "url") {
|
|
451
|
+
url = part.data.url.toString();
|
|
452
|
+
validateDeepSeekImageUrl({ url, prompt });
|
|
453
|
+
} else {
|
|
454
|
+
url = `data:${resolvedMediaType === "image/jpg" ? "image/jpeg" : resolvedMediaType};base64,${convertToBase64(part.data.data)}`;
|
|
455
|
+
}
|
|
456
|
+
contentValue.push({
|
|
457
|
+
type: "image_url",
|
|
458
|
+
image_url: {
|
|
459
|
+
url,
|
|
460
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
461
|
+
detail: filePartOptions.imageDetail
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
} else {
|
|
466
|
+
warnings.push({
|
|
467
|
+
type: "unsupported",
|
|
468
|
+
feature: `tool result content part type: ${part.type}`
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
411
474
|
}
|
|
412
475
|
messages.push({
|
|
413
476
|
role: "tool",
|
|
@@ -1402,7 +1465,7 @@ function hasSupportedFilenameExtension(filename) {
|
|
|
1402
1465
|
}
|
|
1403
1466
|
|
|
1404
1467
|
// src/version.ts
|
|
1405
|
-
var VERSION = true ? "3.0.
|
|
1468
|
+
var VERSION = true ? "3.0.50" : "0.0.0-test";
|
|
1406
1469
|
|
|
1407
1470
|
// src/deepseek-provider.ts
|
|
1408
1471
|
function createDeepSeek(options = {}) {
|