@ai-sdk/deepseek 1.0.63 → 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 +9 -0
- package/dist/index.d.mts +25 -30
- package/dist/index.d.ts +25 -30
- package/dist/index.js +227 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +213 -146
- 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 +233 -170
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +223 -151
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.js
CHANGED
|
@@ -21,100 +21,133 @@ 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) {
|
|
@@ -165,7 +198,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
165
198
|
let index = -1;
|
|
166
199
|
for (const { role, content, providerOptions } of prompt) {
|
|
167
200
|
index++;
|
|
168
|
-
const deepseekMessageOptions = await (0,
|
|
201
|
+
const deepseekMessageOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
169
202
|
provider: providerOptionsName,
|
|
170
203
|
providerOptions,
|
|
171
204
|
schema: deepseekAssistantMessageProviderOptions
|
|
@@ -217,7 +250,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
217
250
|
if (part.type === "text") {
|
|
218
251
|
userContent.push({ type: "text", text: part.text });
|
|
219
252
|
} else if (part.type === "file" && (part.mediaType === "image" || part.mediaType.startsWith("image/"))) {
|
|
220
|
-
const filePartOptions = await (0,
|
|
253
|
+
const filePartOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
221
254
|
provider: providerOptionsName,
|
|
222
255
|
providerOptions: part.providerOptions,
|
|
223
256
|
schema: deepseekFilePartProviderOptions
|
|
@@ -253,7 +286,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
253
286
|
}
|
|
254
287
|
});
|
|
255
288
|
} else {
|
|
256
|
-
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)}`;
|
|
257
290
|
if ((filePartOptions == null ? void 0 : filePartOptions.fileData) === true) {
|
|
258
291
|
if (filePartOptions.imageDetail != null) {
|
|
259
292
|
throw new import_provider.InvalidPromptError({
|
|
@@ -398,77 +431,102 @@ async function convertToDeepSeekChatMessages({
|
|
|
398
431
|
}
|
|
399
432
|
|
|
400
433
|
// src/chat/deepseek-chat-api-types.ts
|
|
401
|
-
var
|
|
434
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
402
435
|
var import_v43 = require("zod/v4");
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}).nullish()
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
import_v43.z.object({
|
|
430
|
-
token: import_v43.z.string(),
|
|
431
|
-
logprob: import_v43.z.number(),
|
|
432
|
-
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()
|
|
433
462
|
})
|
|
434
|
-
)
|
|
435
|
-
}
|
|
436
|
-
var
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
var
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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)(
|
|
447
496
|
import_v43.z.object({
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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()
|
|
466
525
|
})
|
|
467
|
-
)
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
() => (0, import_provider_utils2.zodSchema)(
|
|
526
|
+
)
|
|
527
|
+
);
|
|
528
|
+
var deepseekChatChunkSchema = (0, import_provider_utils4.lazySchema)(
|
|
529
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
472
530
|
import_v43.z.union([
|
|
473
531
|
import_v43.z.object({
|
|
474
532
|
id: import_v43.z.string().nullish(),
|
|
@@ -495,13 +553,13 @@ var deepseekChatChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
495
553
|
})
|
|
496
554
|
).nullish()
|
|
497
555
|
}).nullish(),
|
|
498
|
-
logprobs:
|
|
556
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
499
557
|
finish_reason: import_v43.z.string().nullish()
|
|
500
558
|
})
|
|
501
559
|
),
|
|
502
|
-
usage:
|
|
560
|
+
usage: getTokenUsageSchema()
|
|
503
561
|
}),
|
|
504
|
-
|
|
562
|
+
getDeepSeekErrorSchema()
|
|
505
563
|
])
|
|
506
564
|
)
|
|
507
565
|
);
|
|
@@ -619,7 +677,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
619
677
|
};
|
|
620
678
|
this.modelId = modelId;
|
|
621
679
|
this.config = config;
|
|
622
|
-
this.failedResponseHandler = (0,
|
|
680
|
+
this.failedResponseHandler = (0, import_provider_utils5.createJsonErrorResponseHandler)({
|
|
623
681
|
errorSchema: deepSeekErrorSchema,
|
|
624
682
|
errorToMessage: (error) => error.error.message
|
|
625
683
|
});
|
|
@@ -646,7 +704,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
646
704
|
seed
|
|
647
705
|
}) {
|
|
648
706
|
var _a, _b, _c, _d;
|
|
649
|
-
const deepseekOptions = (_a = await (0,
|
|
707
|
+
const deepseekOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
650
708
|
provider: this.providerOptionsName,
|
|
651
709
|
providerOptions,
|
|
652
710
|
schema: deepseekChatOptions
|
|
@@ -759,15 +817,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
759
817
|
responseHeaders,
|
|
760
818
|
value: responseBody,
|
|
761
819
|
rawValue: rawResponse
|
|
762
|
-
} = await (0,
|
|
820
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
763
821
|
url: this.config.url({
|
|
764
822
|
path: "/chat/completions",
|
|
765
823
|
modelId: this.modelId
|
|
766
824
|
}),
|
|
767
|
-
headers: (0,
|
|
825
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
768
826
|
body: args,
|
|
769
827
|
failedResponseHandler: this.failedResponseHandler,
|
|
770
|
-
successfulResponseHandler: (0,
|
|
828
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
771
829
|
deepseekChatResponseSchema
|
|
772
830
|
),
|
|
773
831
|
abortSignal: options.abortSignal,
|
|
@@ -786,7 +844,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
786
844
|
for (const toolCall of choice.message.tool_calls) {
|
|
787
845
|
content.push({
|
|
788
846
|
type: "tool-call",
|
|
789
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
847
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
790
848
|
toolName: toolCall.function.name,
|
|
791
849
|
input: toolCall.function.arguments
|
|
792
850
|
});
|
|
@@ -843,15 +901,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
843
901
|
stream: true,
|
|
844
902
|
stream_options: { include_usage: true }
|
|
845
903
|
};
|
|
846
|
-
const { responseHeaders, value: response } = await (0,
|
|
904
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
|
|
847
905
|
url: this.config.url({
|
|
848
906
|
path: "/chat/completions",
|
|
849
907
|
modelId: this.modelId
|
|
850
908
|
}),
|
|
851
|
-
headers: (0,
|
|
909
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
852
910
|
body,
|
|
853
911
|
failedResponseHandler: this.failedResponseHandler,
|
|
854
|
-
successfulResponseHandler: (0,
|
|
912
|
+
successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
|
|
855
913
|
deepseekChatChunkSchema
|
|
856
914
|
),
|
|
857
915
|
abortSignal: options.abortSignal,
|
|
@@ -1011,14 +1069,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1011
1069
|
delta: toolCall2.function.arguments
|
|
1012
1070
|
});
|
|
1013
1071
|
}
|
|
1014
|
-
if ((0,
|
|
1072
|
+
if ((0, import_provider_utils5.isParsableJson)(toolCall2.function.arguments)) {
|
|
1015
1073
|
controller.enqueue({
|
|
1016
1074
|
type: "tool-input-end",
|
|
1017
1075
|
id: toolCall2.id
|
|
1018
1076
|
});
|
|
1019
1077
|
controller.enqueue({
|
|
1020
1078
|
type: "tool-call",
|
|
1021
|
-
toolCallId: (_g = toolCall2.id) != null ? _g : (0,
|
|
1079
|
+
toolCallId: (_g = toolCall2.id) != null ? _g : (0, import_provider_utils5.generateId)(),
|
|
1022
1080
|
toolName: toolCall2.function.name,
|
|
1023
1081
|
input: toolCall2.function.arguments
|
|
1024
1082
|
});
|
|
@@ -1039,14 +1097,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1039
1097
|
id: toolCall.id,
|
|
1040
1098
|
delta: (_k = toolCallDelta.function.arguments) != null ? _k : ""
|
|
1041
1099
|
});
|
|
1042
|
-
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)) {
|
|
1043
1101
|
controller.enqueue({
|
|
1044
1102
|
type: "tool-input-end",
|
|
1045
1103
|
id: toolCall.id
|
|
1046
1104
|
});
|
|
1047
1105
|
controller.enqueue({
|
|
1048
1106
|
type: "tool-call",
|
|
1049
|
-
toolCallId: (_n = toolCall.id) != null ? _n : (0,
|
|
1107
|
+
toolCallId: (_n = toolCall.id) != null ? _n : (0, import_provider_utils5.generateId)(),
|
|
1050
1108
|
toolName: toolCall.function.name,
|
|
1051
1109
|
input: toolCall.function.arguments
|
|
1052
1110
|
});
|
|
@@ -1072,7 +1130,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1072
1130
|
});
|
|
1073
1131
|
controller.enqueue({
|
|
1074
1132
|
type: "tool-call",
|
|
1075
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
1133
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
1076
1134
|
toolName: toolCall.function.name,
|
|
1077
1135
|
input: toolCall.function.arguments
|
|
1078
1136
|
});
|
|
@@ -1120,6 +1178,11 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1120
1178
|
};
|
|
1121
1179
|
}
|
|
1122
1180
|
};
|
|
1181
|
+
|
|
1182
|
+
// src/internal/index.ts
|
|
1183
|
+
var deepseekChatOptions2 = getDeepseekChatOptionsSchema();
|
|
1184
|
+
var deepseekMessageProviderOptions2 = getDeepseekMessageOptionsSchema();
|
|
1185
|
+
var deepseekAssistantMessageProviderOptions2 = getDeepseekAssistantMessageOptionsSchema();
|
|
1123
1186
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1124
1187
|
0 && (module.exports = {
|
|
1125
1188
|
DeepSeekChatLanguageModel,
|