@ai-sdk/deepseek 1.0.62 → 1.0.64
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 +15 -0
- package/dist/index.d.mts +25 -30
- package/dist/index.d.ts +25 -30
- package/dist/index.js +230 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +216 -147
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +41 -31
- package/dist/internal/index.d.ts +41 -31
- package/dist/internal/index.js +236 -171
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +226 -152
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.js
CHANGED
|
@@ -21,104 +21,139 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
DeepSeekChatLanguageModel: () => DeepSeekChatLanguageModel,
|
|
24
|
-
deepseekAssistantMessageProviderOptions: () =>
|
|
25
|
-
deepseekChatOptions: () =>
|
|
26
|
-
deepseekMessageProviderOptions: () =>
|
|
24
|
+
deepseekAssistantMessageProviderOptions: () => deepseekAssistantMessageProviderOptions2,
|
|
25
|
+
deepseekChatOptions: () => deepseekChatOptions2,
|
|
26
|
+
deepseekMessageProviderOptions: () => deepseekMessageProviderOptions2
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(index_exports);
|
|
29
29
|
|
|
30
|
+
// src/chat/deepseek-chat-options.ts
|
|
31
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
32
|
+
var import_v4 = require("zod/v4");
|
|
33
|
+
function createDeepseekChatOptionsSchema() {
|
|
34
|
+
return import_v4.z.object({
|
|
35
|
+
/**
|
|
36
|
+
* Whether to return log probabilities for generated tokens.
|
|
37
|
+
*/
|
|
38
|
+
logprobs: import_v4.z.boolean().optional(),
|
|
39
|
+
/**
|
|
40
|
+
* Number of most likely tokens to return at each token position.
|
|
41
|
+
*
|
|
42
|
+
* Setting this option automatically enables `logprobs`.
|
|
43
|
+
*/
|
|
44
|
+
topLogprobs: import_v4.z.number().int().min(0).max(20).optional(),
|
|
45
|
+
/**
|
|
46
|
+
* An opaque identifier for the end user. DeepSeek uses this identifier for
|
|
47
|
+
* content-safety tracing and request isolation.
|
|
48
|
+
*
|
|
49
|
+
* Must contain only ASCII letters, numbers, underscores, and hyphens, and
|
|
50
|
+
* must be at most 512 characters long.
|
|
51
|
+
*/
|
|
52
|
+
userId: import_v4.z.string().regex(/^[a-zA-Z0-9_-]+$/, "userId must match /^[a-zA-Z0-9_-]+$/").max(512, "userId must be at most 512 characters long").optional(),
|
|
53
|
+
/**
|
|
54
|
+
* Type of thinking to use. Defaults to `enabled`.
|
|
55
|
+
*/
|
|
56
|
+
thinking: import_v4.z.object({
|
|
57
|
+
// `adaptive` is accepted at runtime for backwards compatibility and
|
|
58
|
+
// mapped to `enabled`, but is intentionally excluded from the exported
|
|
59
|
+
// provider options type.
|
|
60
|
+
type: import_v4.z.enum(["adaptive", "enabled", "disabled"]).optional()
|
|
61
|
+
}).optional(),
|
|
62
|
+
/**
|
|
63
|
+
* Controls the thinking strength for DeepSeek V4 reasoning models.
|
|
64
|
+
*/
|
|
65
|
+
// `medium` and `xhigh` are accepted at runtime for backwards compatibility
|
|
66
|
+
// and mapped to canonical DeepSeek values, but are intentionally excluded
|
|
67
|
+
// from the exported provider options type.
|
|
68
|
+
reasoningEffort: import_v4.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
69
|
+
/**
|
|
70
|
+
* Whether to use strict JSON schema validation for structured outputs.
|
|
71
|
+
* Only applies when the serving endpoint supports JSON schema response
|
|
72
|
+
* formats (e.g. Azure). Defaults to `true`.
|
|
73
|
+
*/
|
|
74
|
+
strictJsonSchema: import_v4.z.boolean().optional()
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
var chatOptionsSchema;
|
|
78
|
+
function getDeepseekChatOptionsSchema() {
|
|
79
|
+
return chatOptionsSchema != null ? chatOptionsSchema : chatOptionsSchema = createDeepseekChatOptionsSchema();
|
|
80
|
+
}
|
|
81
|
+
var deepseekChatOptions = (0, import_provider_utils.lazySchema)(
|
|
82
|
+
() => (0, import_provider_utils.zodSchema)(getDeepseekChatOptionsSchema())
|
|
83
|
+
);
|
|
84
|
+
function createDeepseekMessageOptionsSchema() {
|
|
85
|
+
return import_v4.z.object({
|
|
86
|
+
/**
|
|
87
|
+
* The name of the participant represented by the message.
|
|
88
|
+
*
|
|
89
|
+
* Supported on system, user, and assistant messages.
|
|
90
|
+
*/
|
|
91
|
+
name: import_v4.z.string().optional()
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
var messageOptionsSchema;
|
|
95
|
+
function getDeepseekMessageOptionsSchema() {
|
|
96
|
+
return messageOptionsSchema != null ? messageOptionsSchema : messageOptionsSchema = createDeepseekMessageOptionsSchema();
|
|
97
|
+
}
|
|
98
|
+
var deepseekMessageProviderOptions = (0, import_provider_utils.lazySchema)(
|
|
99
|
+
() => (0, import_provider_utils.zodSchema)(getDeepseekMessageOptionsSchema())
|
|
100
|
+
);
|
|
101
|
+
function createDeepseekAssistantMessageOptionsSchema() {
|
|
102
|
+
return getDeepseekMessageOptionsSchema().extend({
|
|
103
|
+
/**
|
|
104
|
+
* Whether the assistant message content is a prefix that DeepSeek should
|
|
105
|
+
* continue. This beta feature is only supported on the final assistant
|
|
106
|
+
* message when using a beta base URL.
|
|
107
|
+
*/
|
|
108
|
+
prefix: import_v4.z.literal(true).optional()
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
var assistantMessageOptionsSchema;
|
|
112
|
+
function getDeepseekAssistantMessageOptionsSchema() {
|
|
113
|
+
return assistantMessageOptionsSchema != null ? assistantMessageOptionsSchema : assistantMessageOptionsSchema = createDeepseekAssistantMessageOptionsSchema();
|
|
114
|
+
}
|
|
115
|
+
var deepseekAssistantMessageProviderOptions = (0, import_provider_utils.lazySchema)(
|
|
116
|
+
() => (0, import_provider_utils.zodSchema)(getDeepseekAssistantMessageOptionsSchema())
|
|
117
|
+
);
|
|
118
|
+
|
|
30
119
|
// src/chat/deepseek-chat-language-model.ts
|
|
31
120
|
var import_provider3 = require("@ai-sdk/provider");
|
|
32
|
-
var
|
|
121
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
33
122
|
|
|
34
123
|
// src/chat/convert-to-deepseek-chat-messages.ts
|
|
35
124
|
var import_provider = require("@ai-sdk/provider");
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
// src/chat/deepseek-chat-options.ts
|
|
39
|
-
var import_v4 = require("zod/v4");
|
|
40
|
-
var deepseekChatOptions = import_v4.z.object({
|
|
41
|
-
/**
|
|
42
|
-
* Whether to return log probabilities for generated tokens.
|
|
43
|
-
*/
|
|
44
|
-
logprobs: import_v4.z.boolean().optional(),
|
|
45
|
-
/**
|
|
46
|
-
* Number of most likely tokens to return at each token position.
|
|
47
|
-
*
|
|
48
|
-
* Setting this option automatically enables `logprobs`.
|
|
49
|
-
*/
|
|
50
|
-
topLogprobs: import_v4.z.number().int().min(0).max(20).optional(),
|
|
51
|
-
/**
|
|
52
|
-
* An opaque identifier for the end user. DeepSeek uses this identifier for
|
|
53
|
-
* content-safety tracing and request isolation.
|
|
54
|
-
*
|
|
55
|
-
* Must contain only ASCII letters, numbers, underscores, and hyphens, and
|
|
56
|
-
* must be at most 512 characters long.
|
|
57
|
-
*/
|
|
58
|
-
userId: import_v4.z.string().regex(/^[a-zA-Z0-9_-]+$/, "userId must match /^[a-zA-Z0-9_-]+$/").max(512, "userId must be at most 512 characters long").optional(),
|
|
59
|
-
/**
|
|
60
|
-
* Type of thinking to use. Defaults to `enabled`.
|
|
61
|
-
*/
|
|
62
|
-
thinking: import_v4.z.object({
|
|
63
|
-
// `adaptive` is accepted at runtime for backwards compatibility and
|
|
64
|
-
// mapped to `enabled`, but is intentionally excluded from the exported
|
|
65
|
-
// provider options type.
|
|
66
|
-
type: import_v4.z.enum(["adaptive", "enabled", "disabled"]).optional()
|
|
67
|
-
}).optional(),
|
|
68
|
-
/**
|
|
69
|
-
* Controls the thinking strength for DeepSeek V4 reasoning models.
|
|
70
|
-
*/
|
|
71
|
-
// `medium` and `xhigh` are accepted at runtime for backwards compatibility
|
|
72
|
-
// and mapped to canonical DeepSeek values, but are intentionally excluded
|
|
73
|
-
// from the exported provider options type.
|
|
74
|
-
reasoningEffort: import_v4.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
75
|
-
/**
|
|
76
|
-
* Whether to use strict JSON schema validation for structured outputs.
|
|
77
|
-
* Only applies when the serving endpoint supports JSON schema response
|
|
78
|
-
* formats (e.g. Azure). Defaults to `true`.
|
|
79
|
-
*/
|
|
80
|
-
strictJsonSchema: import_v4.z.boolean().optional()
|
|
81
|
-
});
|
|
82
|
-
var deepseekMessageProviderOptions = import_v4.z.object({
|
|
83
|
-
/**
|
|
84
|
-
* The name of the participant represented by the message.
|
|
85
|
-
*
|
|
86
|
-
* Supported on system, user, and assistant messages.
|
|
87
|
-
*/
|
|
88
|
-
name: import_v4.z.string().optional()
|
|
89
|
-
});
|
|
90
|
-
var deepseekAssistantMessageProviderOptions = deepseekMessageProviderOptions.extend({
|
|
91
|
-
/**
|
|
92
|
-
* Whether the assistant message content is a prefix that DeepSeek should
|
|
93
|
-
* continue. This beta feature is only supported on the final assistant
|
|
94
|
-
* message when using a beta base URL.
|
|
95
|
-
*/
|
|
96
|
-
prefix: import_v4.z.literal(true).optional()
|
|
97
|
-
});
|
|
125
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
98
126
|
|
|
99
127
|
// src/chat/deepseek-file-part-options.ts
|
|
128
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
100
129
|
var import_v42 = require("zod/v4");
|
|
101
|
-
var deepseekFilePartProviderOptions =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
var deepseekFilePartProviderOptions = (0, import_provider_utils2.lazySchema)(
|
|
131
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
132
|
+
import_v42.z.object({
|
|
133
|
+
/**
|
|
134
|
+
* Controls how DeepSeek processes an image sent as an `image_url` part.
|
|
135
|
+
*
|
|
136
|
+
* @see https://api-docs.deepseek.com/api/create-chat-completion/
|
|
137
|
+
*/
|
|
138
|
+
imageDetail: import_v42.z.enum(["low", "high", "original", "auto"]).optional(),
|
|
139
|
+
/**
|
|
140
|
+
* Sends inline image data as a DeepSeek `file` part using `file_data`
|
|
141
|
+
* instead of an `image_url` data URL. When set, the file part's filename
|
|
142
|
+
* is preserved.
|
|
143
|
+
*
|
|
144
|
+
* This option only applies to inline image data. It cannot be combined
|
|
145
|
+
* with `imageDetail`.
|
|
146
|
+
*/
|
|
147
|
+
fileData: import_v42.z.literal(true).optional()
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
);
|
|
118
151
|
|
|
119
152
|
// src/chat/is-deepseek-v4-model.ts
|
|
120
153
|
function isDeepSeekV4Model(modelId) {
|
|
121
|
-
return
|
|
154
|
+
return !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\.\d+)?)(?=[-/:.]|$)/.test(
|
|
155
|
+
modelId
|
|
156
|
+
);
|
|
122
157
|
}
|
|
123
158
|
|
|
124
159
|
// src/chat/convert-to-deepseek-chat-messages.ts
|
|
@@ -163,7 +198,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
163
198
|
let index = -1;
|
|
164
199
|
for (const { role, content, providerOptions } of prompt) {
|
|
165
200
|
index++;
|
|
166
|
-
const deepseekMessageOptions = await (0,
|
|
201
|
+
const deepseekMessageOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
167
202
|
provider: providerOptionsName,
|
|
168
203
|
providerOptions,
|
|
169
204
|
schema: deepseekAssistantMessageProviderOptions
|
|
@@ -215,7 +250,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
215
250
|
if (part.type === "text") {
|
|
216
251
|
userContent.push({ type: "text", text: part.text });
|
|
217
252
|
} else if (part.type === "file" && (part.mediaType === "image" || part.mediaType.startsWith("image/"))) {
|
|
218
|
-
const filePartOptions = await (0,
|
|
253
|
+
const filePartOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
219
254
|
provider: providerOptionsName,
|
|
220
255
|
providerOptions: part.providerOptions,
|
|
221
256
|
schema: deepseekFilePartProviderOptions
|
|
@@ -251,7 +286,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
251
286
|
}
|
|
252
287
|
});
|
|
253
288
|
} else {
|
|
254
|
-
const dataUrl = `data:${resolvedMediaType === "image/jpg" ? "image/jpeg" : resolvedMediaType};base64,${(0,
|
|
289
|
+
const dataUrl = `data:${resolvedMediaType === "image/jpg" ? "image/jpeg" : resolvedMediaType};base64,${(0, import_provider_utils3.convertToBase64)(part.data)}`;
|
|
255
290
|
if ((filePartOptions == null ? void 0 : filePartOptions.fileData) === true) {
|
|
256
291
|
if (filePartOptions.imageDetail != null) {
|
|
257
292
|
throw new import_provider.InvalidPromptError({
|
|
@@ -396,77 +431,102 @@ async function convertToDeepSeekChatMessages({
|
|
|
396
431
|
}
|
|
397
432
|
|
|
398
433
|
// src/chat/deepseek-chat-api-types.ts
|
|
399
|
-
var
|
|
434
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
400
435
|
var import_v43 = require("zod/v4");
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}).nullish()
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
import_v43.z.object({
|
|
428
|
-
token: import_v43.z.string(),
|
|
429
|
-
logprob: import_v43.z.number(),
|
|
430
|
-
bytes: import_v43.z.array(import_v43.z.number()).nullable()
|
|
436
|
+
function createTokenUsageSchema() {
|
|
437
|
+
return import_v43.z.object({
|
|
438
|
+
prompt_tokens: import_v43.z.number().nullish(),
|
|
439
|
+
completion_tokens: import_v43.z.number().nullish(),
|
|
440
|
+
prompt_cache_hit_tokens: import_v43.z.number().nullish(),
|
|
441
|
+
prompt_cache_miss_tokens: import_v43.z.number().nullish(),
|
|
442
|
+
total_tokens: import_v43.z.number().nullish(),
|
|
443
|
+
prompt_tokens_details: import_v43.z.object({
|
|
444
|
+
cached_tokens: import_v43.z.number().nullish()
|
|
445
|
+
}).nullish(),
|
|
446
|
+
completion_tokens_details: import_v43.z.object({
|
|
447
|
+
reasoning_tokens: import_v43.z.number().nullish()
|
|
448
|
+
}).nullish()
|
|
449
|
+
}).nullish();
|
|
450
|
+
}
|
|
451
|
+
var tokenUsageSchema;
|
|
452
|
+
function getTokenUsageSchema() {
|
|
453
|
+
return tokenUsageSchema != null ? tokenUsageSchema : tokenUsageSchema = createTokenUsageSchema();
|
|
454
|
+
}
|
|
455
|
+
function createDeepSeekErrorSchema() {
|
|
456
|
+
return import_v43.z.object({
|
|
457
|
+
error: import_v43.z.object({
|
|
458
|
+
message: import_v43.z.string(),
|
|
459
|
+
type: import_v43.z.string().nullish(),
|
|
460
|
+
param: import_v43.z.any().nullish(),
|
|
461
|
+
code: import_v43.z.union([import_v43.z.string(), import_v43.z.number()]).nullish()
|
|
431
462
|
})
|
|
432
|
-
)
|
|
433
|
-
}
|
|
434
|
-
var
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
var
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
var errorSchema;
|
|
466
|
+
function getDeepSeekErrorSchema() {
|
|
467
|
+
return errorSchema != null ? errorSchema : errorSchema = createDeepSeekErrorSchema();
|
|
468
|
+
}
|
|
469
|
+
var deepSeekErrorSchema = (0, import_provider_utils4.lazySchema)(
|
|
470
|
+
() => (0, import_provider_utils4.zodSchema)(getDeepSeekErrorSchema())
|
|
471
|
+
);
|
|
472
|
+
function createDeepseekChatLogprobsSchema() {
|
|
473
|
+
const deepseekChatLogprobSchema = import_v43.z.object({
|
|
474
|
+
token: import_v43.z.string(),
|
|
475
|
+
logprob: import_v43.z.number(),
|
|
476
|
+
bytes: import_v43.z.array(import_v43.z.number()).nullable(),
|
|
477
|
+
top_logprobs: import_v43.z.array(
|
|
478
|
+
import_v43.z.object({
|
|
479
|
+
token: import_v43.z.string(),
|
|
480
|
+
logprob: import_v43.z.number(),
|
|
481
|
+
bytes: import_v43.z.array(import_v43.z.number()).nullable()
|
|
482
|
+
})
|
|
483
|
+
)
|
|
484
|
+
});
|
|
485
|
+
return import_v43.z.object({
|
|
486
|
+
content: import_v43.z.array(deepseekChatLogprobSchema).nullish(),
|
|
487
|
+
reasoning_content: import_v43.z.array(deepseekChatLogprobSchema).nullish()
|
|
488
|
+
}).nullish();
|
|
489
|
+
}
|
|
490
|
+
var logprobsSchema;
|
|
491
|
+
function getDeepseekChatLogprobsSchema() {
|
|
492
|
+
return logprobsSchema != null ? logprobsSchema : logprobsSchema = createDeepseekChatLogprobsSchema();
|
|
493
|
+
}
|
|
494
|
+
var deepseekChatResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
495
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
445
496
|
import_v43.z.object({
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
497
|
+
id: import_v43.z.string().nullish(),
|
|
498
|
+
created: import_v43.z.number().nullish(),
|
|
499
|
+
model: import_v43.z.string().nullish(),
|
|
500
|
+
object: import_v43.z.literal("chat.completion").nullish(),
|
|
501
|
+
system_fingerprint: import_v43.z.string().nullish(),
|
|
502
|
+
choices: import_v43.z.array(
|
|
503
|
+
import_v43.z.object({
|
|
504
|
+
index: import_v43.z.number().nullish(),
|
|
505
|
+
message: import_v43.z.object({
|
|
506
|
+
role: import_v43.z.literal("assistant").nullish(),
|
|
507
|
+
content: import_v43.z.string().nullish(),
|
|
508
|
+
reasoning_content: import_v43.z.string().nullish(),
|
|
509
|
+
tool_calls: import_v43.z.array(
|
|
510
|
+
import_v43.z.object({
|
|
511
|
+
id: import_v43.z.string().nullish(),
|
|
512
|
+
type: import_v43.z.literal("function").nullish(),
|
|
513
|
+
function: import_v43.z.object({
|
|
514
|
+
name: import_v43.z.string(),
|
|
515
|
+
arguments: import_v43.z.string()
|
|
516
|
+
})
|
|
517
|
+
})
|
|
518
|
+
).nullish()
|
|
519
|
+
}),
|
|
520
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
521
|
+
finish_reason: import_v43.z.string().nullish()
|
|
522
|
+
})
|
|
523
|
+
),
|
|
524
|
+
usage: getTokenUsageSchema()
|
|
464
525
|
})
|
|
465
|
-
)
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
() => (0, import_provider_utils2.zodSchema)(
|
|
526
|
+
)
|
|
527
|
+
);
|
|
528
|
+
var deepseekChatChunkSchema = (0, import_provider_utils4.lazySchema)(
|
|
529
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
470
530
|
import_v43.z.union([
|
|
471
531
|
import_v43.z.object({
|
|
472
532
|
id: import_v43.z.string().nullish(),
|
|
@@ -493,13 +553,13 @@ var deepseekChatChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
493
553
|
})
|
|
494
554
|
).nullish()
|
|
495
555
|
}).nullish(),
|
|
496
|
-
logprobs:
|
|
556
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
497
557
|
finish_reason: import_v43.z.string().nullish()
|
|
498
558
|
})
|
|
499
559
|
),
|
|
500
|
-
usage:
|
|
560
|
+
usage: getTokenUsageSchema()
|
|
501
561
|
}),
|
|
502
|
-
|
|
562
|
+
getDeepSeekErrorSchema()
|
|
503
563
|
])
|
|
504
564
|
)
|
|
505
565
|
);
|
|
@@ -617,7 +677,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
617
677
|
};
|
|
618
678
|
this.modelId = modelId;
|
|
619
679
|
this.config = config;
|
|
620
|
-
this.failedResponseHandler = (0,
|
|
680
|
+
this.failedResponseHandler = (0, import_provider_utils5.createJsonErrorResponseHandler)({
|
|
621
681
|
errorSchema: deepSeekErrorSchema,
|
|
622
682
|
errorToMessage: (error) => error.error.message
|
|
623
683
|
});
|
|
@@ -644,7 +704,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
644
704
|
seed
|
|
645
705
|
}) {
|
|
646
706
|
var _a, _b, _c, _d;
|
|
647
|
-
const deepseekOptions = (_a = await (0,
|
|
707
|
+
const deepseekOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
648
708
|
provider: this.providerOptionsName,
|
|
649
709
|
providerOptions,
|
|
650
710
|
schema: deepseekChatOptions
|
|
@@ -757,15 +817,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
757
817
|
responseHeaders,
|
|
758
818
|
value: responseBody,
|
|
759
819
|
rawValue: rawResponse
|
|
760
|
-
} = await (0,
|
|
820
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
761
821
|
url: this.config.url({
|
|
762
822
|
path: "/chat/completions",
|
|
763
823
|
modelId: this.modelId
|
|
764
824
|
}),
|
|
765
|
-
headers: (0,
|
|
825
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
766
826
|
body: args,
|
|
767
827
|
failedResponseHandler: this.failedResponseHandler,
|
|
768
|
-
successfulResponseHandler: (0,
|
|
828
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
769
829
|
deepseekChatResponseSchema
|
|
770
830
|
),
|
|
771
831
|
abortSignal: options.abortSignal,
|
|
@@ -784,7 +844,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
784
844
|
for (const toolCall of choice.message.tool_calls) {
|
|
785
845
|
content.push({
|
|
786
846
|
type: "tool-call",
|
|
787
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
847
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
788
848
|
toolName: toolCall.function.name,
|
|
789
849
|
input: toolCall.function.arguments
|
|
790
850
|
});
|
|
@@ -841,15 +901,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
841
901
|
stream: true,
|
|
842
902
|
stream_options: { include_usage: true }
|
|
843
903
|
};
|
|
844
|
-
const { responseHeaders, value: response } = await (0,
|
|
904
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
|
|
845
905
|
url: this.config.url({
|
|
846
906
|
path: "/chat/completions",
|
|
847
907
|
modelId: this.modelId
|
|
848
908
|
}),
|
|
849
|
-
headers: (0,
|
|
909
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
850
910
|
body,
|
|
851
911
|
failedResponseHandler: this.failedResponseHandler,
|
|
852
|
-
successfulResponseHandler: (0,
|
|
912
|
+
successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
|
|
853
913
|
deepseekChatChunkSchema
|
|
854
914
|
),
|
|
855
915
|
abortSignal: options.abortSignal,
|
|
@@ -1009,14 +1069,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1009
1069
|
delta: toolCall2.function.arguments
|
|
1010
1070
|
});
|
|
1011
1071
|
}
|
|
1012
|
-
if ((0,
|
|
1072
|
+
if ((0, import_provider_utils5.isParsableJson)(toolCall2.function.arguments)) {
|
|
1013
1073
|
controller.enqueue({
|
|
1014
1074
|
type: "tool-input-end",
|
|
1015
1075
|
id: toolCall2.id
|
|
1016
1076
|
});
|
|
1017
1077
|
controller.enqueue({
|
|
1018
1078
|
type: "tool-call",
|
|
1019
|
-
toolCallId: (_g = toolCall2.id) != null ? _g : (0,
|
|
1079
|
+
toolCallId: (_g = toolCall2.id) != null ? _g : (0, import_provider_utils5.generateId)(),
|
|
1020
1080
|
toolName: toolCall2.function.name,
|
|
1021
1081
|
input: toolCall2.function.arguments
|
|
1022
1082
|
});
|
|
@@ -1037,14 +1097,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1037
1097
|
id: toolCall.id,
|
|
1038
1098
|
delta: (_k = toolCallDelta.function.arguments) != null ? _k : ""
|
|
1039
1099
|
});
|
|
1040
|
-
if (((_l = toolCall.function) == null ? void 0 : _l.name) != null && ((_m = toolCall.function) == null ? void 0 : _m.arguments) != null && (0,
|
|
1100
|
+
if (((_l = toolCall.function) == null ? void 0 : _l.name) != null && ((_m = toolCall.function) == null ? void 0 : _m.arguments) != null && (0, import_provider_utils5.isParsableJson)(toolCall.function.arguments)) {
|
|
1041
1101
|
controller.enqueue({
|
|
1042
1102
|
type: "tool-input-end",
|
|
1043
1103
|
id: toolCall.id
|
|
1044
1104
|
});
|
|
1045
1105
|
controller.enqueue({
|
|
1046
1106
|
type: "tool-call",
|
|
1047
|
-
toolCallId: (_n = toolCall.id) != null ? _n : (0,
|
|
1107
|
+
toolCallId: (_n = toolCall.id) != null ? _n : (0, import_provider_utils5.generateId)(),
|
|
1048
1108
|
toolName: toolCall.function.name,
|
|
1049
1109
|
input: toolCall.function.arguments
|
|
1050
1110
|
});
|
|
@@ -1070,7 +1130,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1070
1130
|
});
|
|
1071
1131
|
controller.enqueue({
|
|
1072
1132
|
type: "tool-call",
|
|
1073
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
1133
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
1074
1134
|
toolName: toolCall.function.name,
|
|
1075
1135
|
input: toolCall.function.arguments
|
|
1076
1136
|
});
|
|
@@ -1118,6 +1178,11 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1118
1178
|
};
|
|
1119
1179
|
}
|
|
1120
1180
|
};
|
|
1181
|
+
|
|
1182
|
+
// src/internal/index.ts
|
|
1183
|
+
var deepseekChatOptions2 = getDeepseekChatOptionsSchema();
|
|
1184
|
+
var deepseekMessageProviderOptions2 = getDeepseekMessageOptionsSchema();
|
|
1185
|
+
var deepseekAssistantMessageProviderOptions2 = getDeepseekAssistantMessageOptionsSchema();
|
|
1121
1186
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1122
1187
|
0 && (module.exports = {
|
|
1123
1188
|
DeepSeekChatLanguageModel,
|