@ai-sdk/deepseek 2.0.76 → 2.0.78
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 +16 -0
- package/dist/index.d.mts +25 -30
- package/dist/index.d.ts +25 -30
- package/dist/index.js +223 -165
- 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 +229 -166
- 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 +4 -4
- package/src/chat/deepseek-chat-api-types.ts +128 -84
- package/src/chat/deepseek-chat-options.ts +109 -60
- package/src/chat/deepseek-file-part-options.ts +27 -18
- package/src/internal/index.ts +18 -1
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
|
-
deepseekLanguageModelOptions: () =>
|
|
26
|
-
deepseekMessageProviderOptions: () =>
|
|
24
|
+
deepseekAssistantMessageProviderOptions: () => deepseekAssistantMessageProviderOptions2,
|
|
25
|
+
deepseekLanguageModelOptions: () => deepseekLanguageModelOptions2,
|
|
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 deepseekLanguageModelOptions = (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 deepseekLanguageModelOptions = 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) {
|
|
@@ -171,7 +204,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
171
204
|
let index = -1;
|
|
172
205
|
for (const { role, content, providerOptions } of prompt) {
|
|
173
206
|
index++;
|
|
174
|
-
const deepseekMessageOptions = await (0,
|
|
207
|
+
const deepseekMessageOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
175
208
|
provider: providerOptionsName,
|
|
176
209
|
providerOptions,
|
|
177
210
|
schema: deepseekAssistantMessageProviderOptions
|
|
@@ -223,7 +256,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
223
256
|
if (part.type === "text") {
|
|
224
257
|
userContent.push({ type: "text", text: part.text });
|
|
225
258
|
} else if (part.type === "file" && (part.mediaType === "image" || part.mediaType.startsWith("image/"))) {
|
|
226
|
-
const filePartOptions = await (0,
|
|
259
|
+
const filePartOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
227
260
|
provider: providerOptionsName,
|
|
228
261
|
providerOptions: part.providerOptions,
|
|
229
262
|
schema: deepseekFilePartProviderOptions
|
|
@@ -259,7 +292,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
259
292
|
}
|
|
260
293
|
});
|
|
261
294
|
} else {
|
|
262
|
-
const dataUrl = `data:${resolvedMediaType === "image/jpg" ? "image/jpeg" : resolvedMediaType};base64,${(0,
|
|
295
|
+
const dataUrl = `data:${resolvedMediaType === "image/jpg" ? "image/jpeg" : resolvedMediaType};base64,${(0, import_provider_utils3.convertToBase64)(part.data)}`;
|
|
263
296
|
if ((filePartOptions == null ? void 0 : filePartOptions.fileData) === true) {
|
|
264
297
|
if (filePartOptions.imageDetail != null) {
|
|
265
298
|
throw new import_provider.InvalidPromptError({
|
|
@@ -449,77 +482,102 @@ function convertDeepSeekUsage(usage) {
|
|
|
449
482
|
}
|
|
450
483
|
|
|
451
484
|
// src/chat/deepseek-chat-api-types.ts
|
|
452
|
-
var
|
|
485
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
453
486
|
var import_v43 = require("zod/v4");
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}).nullish()
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
import_v43.z.object({
|
|
481
|
-
token: import_v43.z.string(),
|
|
482
|
-
logprob: import_v43.z.number(),
|
|
483
|
-
bytes: import_v43.z.array(import_v43.z.number()).nullable()
|
|
487
|
+
function createTokenUsageSchema() {
|
|
488
|
+
return import_v43.z.looseObject({
|
|
489
|
+
prompt_tokens: import_v43.z.number().nullish(),
|
|
490
|
+
completion_tokens: import_v43.z.number().nullish(),
|
|
491
|
+
prompt_cache_hit_tokens: import_v43.z.number().nullish(),
|
|
492
|
+
prompt_cache_miss_tokens: import_v43.z.number().nullish(),
|
|
493
|
+
total_tokens: import_v43.z.number().nullish(),
|
|
494
|
+
prompt_tokens_details: import_v43.z.looseObject({
|
|
495
|
+
cached_tokens: import_v43.z.number().nullish()
|
|
496
|
+
}).nullish(),
|
|
497
|
+
completion_tokens_details: import_v43.z.looseObject({
|
|
498
|
+
reasoning_tokens: import_v43.z.number().nullish()
|
|
499
|
+
}).nullish()
|
|
500
|
+
}).nullish();
|
|
501
|
+
}
|
|
502
|
+
var tokenUsageSchema;
|
|
503
|
+
function getTokenUsageSchema() {
|
|
504
|
+
return tokenUsageSchema != null ? tokenUsageSchema : tokenUsageSchema = createTokenUsageSchema();
|
|
505
|
+
}
|
|
506
|
+
function createDeepSeekErrorSchema() {
|
|
507
|
+
return import_v43.z.object({
|
|
508
|
+
error: import_v43.z.object({
|
|
509
|
+
message: import_v43.z.string(),
|
|
510
|
+
type: import_v43.z.string().nullish(),
|
|
511
|
+
param: import_v43.z.any().nullish(),
|
|
512
|
+
code: import_v43.z.union([import_v43.z.string(), import_v43.z.number()]).nullish()
|
|
484
513
|
})
|
|
485
|
-
)
|
|
486
|
-
}
|
|
487
|
-
var
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
var errorSchema;
|
|
517
|
+
function getDeepSeekErrorSchema() {
|
|
518
|
+
return errorSchema != null ? errorSchema : errorSchema = createDeepSeekErrorSchema();
|
|
519
|
+
}
|
|
520
|
+
var deepSeekErrorSchema = (0, import_provider_utils4.lazySchema)(
|
|
521
|
+
() => (0, import_provider_utils4.zodSchema)(getDeepSeekErrorSchema())
|
|
522
|
+
);
|
|
523
|
+
function createDeepseekChatLogprobsSchema() {
|
|
524
|
+
const deepseekChatLogprobSchema = import_v43.z.object({
|
|
525
|
+
token: import_v43.z.string(),
|
|
526
|
+
logprob: import_v43.z.number(),
|
|
527
|
+
bytes: import_v43.z.array(import_v43.z.number()).nullable(),
|
|
528
|
+
top_logprobs: import_v43.z.array(
|
|
529
|
+
import_v43.z.object({
|
|
530
|
+
token: import_v43.z.string(),
|
|
531
|
+
logprob: import_v43.z.number(),
|
|
532
|
+
bytes: import_v43.z.array(import_v43.z.number()).nullable()
|
|
533
|
+
})
|
|
534
|
+
)
|
|
535
|
+
});
|
|
536
|
+
return import_v43.z.object({
|
|
537
|
+
content: import_v43.z.array(deepseekChatLogprobSchema).nullish(),
|
|
538
|
+
reasoning_content: import_v43.z.array(deepseekChatLogprobSchema).nullish()
|
|
539
|
+
}).nullish();
|
|
540
|
+
}
|
|
541
|
+
var logprobsSchema;
|
|
542
|
+
function getDeepseekChatLogprobsSchema() {
|
|
543
|
+
return logprobsSchema != null ? logprobsSchema : logprobsSchema = createDeepseekChatLogprobsSchema();
|
|
544
|
+
}
|
|
545
|
+
var deepseekChatResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
546
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
498
547
|
import_v43.z.object({
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
548
|
+
id: import_v43.z.string().nullish(),
|
|
549
|
+
created: import_v43.z.number().nullish(),
|
|
550
|
+
model: import_v43.z.string().nullish(),
|
|
551
|
+
object: import_v43.z.literal("chat.completion").nullish(),
|
|
552
|
+
system_fingerprint: import_v43.z.string().nullish(),
|
|
553
|
+
choices: import_v43.z.array(
|
|
554
|
+
import_v43.z.object({
|
|
555
|
+
index: import_v43.z.number().nullish(),
|
|
556
|
+
message: import_v43.z.object({
|
|
557
|
+
role: import_v43.z.literal("assistant").nullish(),
|
|
558
|
+
content: import_v43.z.string().nullish(),
|
|
559
|
+
reasoning_content: import_v43.z.string().nullish(),
|
|
560
|
+
tool_calls: import_v43.z.array(
|
|
561
|
+
import_v43.z.object({
|
|
562
|
+
id: import_v43.z.string().nullish(),
|
|
563
|
+
type: import_v43.z.literal("function").nullish(),
|
|
564
|
+
function: import_v43.z.object({
|
|
565
|
+
name: import_v43.z.string(),
|
|
566
|
+
arguments: import_v43.z.string()
|
|
567
|
+
})
|
|
568
|
+
})
|
|
569
|
+
).nullish()
|
|
570
|
+
}),
|
|
571
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
572
|
+
finish_reason: import_v43.z.string().nullish()
|
|
573
|
+
})
|
|
574
|
+
),
|
|
575
|
+
usage: getTokenUsageSchema()
|
|
517
576
|
})
|
|
518
|
-
)
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
() => (0, import_provider_utils2.zodSchema)(
|
|
577
|
+
)
|
|
578
|
+
);
|
|
579
|
+
var deepseekChatChunkSchema = (0, import_provider_utils4.lazySchema)(
|
|
580
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
523
581
|
import_v43.z.union([
|
|
524
582
|
import_v43.z.object({
|
|
525
583
|
id: import_v43.z.string().nullish(),
|
|
@@ -546,13 +604,13 @@ var deepseekChatChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
546
604
|
})
|
|
547
605
|
).nullish()
|
|
548
606
|
}).nullish(),
|
|
549
|
-
logprobs:
|
|
607
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
550
608
|
finish_reason: import_v43.z.string().nullish()
|
|
551
609
|
})
|
|
552
610
|
),
|
|
553
|
-
usage:
|
|
611
|
+
usage: getTokenUsageSchema()
|
|
554
612
|
}),
|
|
555
|
-
|
|
613
|
+
getDeepSeekErrorSchema()
|
|
556
614
|
])
|
|
557
615
|
)
|
|
558
616
|
);
|
|
@@ -690,7 +748,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
690
748
|
};
|
|
691
749
|
this.modelId = modelId;
|
|
692
750
|
this.config = config;
|
|
693
|
-
this.failedResponseHandler = (0,
|
|
751
|
+
this.failedResponseHandler = (0, import_provider_utils5.createJsonErrorResponseHandler)({
|
|
694
752
|
errorSchema: deepSeekErrorSchema,
|
|
695
753
|
errorToMessage: (error) => error.error.message
|
|
696
754
|
});
|
|
@@ -717,7 +775,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
717
775
|
tools
|
|
718
776
|
}) {
|
|
719
777
|
var _a, _b, _c, _d;
|
|
720
|
-
const deepseekOptions = (_a = await (0,
|
|
778
|
+
const deepseekOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
721
779
|
provider: this.providerOptionsName,
|
|
722
780
|
providerOptions,
|
|
723
781
|
schema: deepseekLanguageModelOptions
|
|
@@ -832,15 +890,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
832
890
|
responseHeaders,
|
|
833
891
|
value: responseBody,
|
|
834
892
|
rawValue: rawResponse
|
|
835
|
-
} = await (0,
|
|
893
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
836
894
|
url: this.config.url({
|
|
837
895
|
path: "/chat/completions",
|
|
838
896
|
modelId: this.modelId
|
|
839
897
|
}),
|
|
840
|
-
headers: (0,
|
|
898
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
841
899
|
body: args,
|
|
842
900
|
failedResponseHandler: this.failedResponseHandler,
|
|
843
|
-
successfulResponseHandler: (0,
|
|
901
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
844
902
|
deepseekChatResponseSchema
|
|
845
903
|
),
|
|
846
904
|
abortSignal: options.abortSignal,
|
|
@@ -859,7 +917,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
859
917
|
for (const toolCall of choice.message.tool_calls) {
|
|
860
918
|
content.push({
|
|
861
919
|
type: "tool-call",
|
|
862
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
920
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
863
921
|
toolName: toolCall.function.name,
|
|
864
922
|
input: toolCall.function.arguments
|
|
865
923
|
});
|
|
@@ -912,15 +970,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
912
970
|
stream: true,
|
|
913
971
|
stream_options: { include_usage: true }
|
|
914
972
|
};
|
|
915
|
-
const { responseHeaders, value: response } = await (0,
|
|
973
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
|
|
916
974
|
url: this.config.url({
|
|
917
975
|
path: "/chat/completions",
|
|
918
976
|
modelId: this.modelId
|
|
919
977
|
}),
|
|
920
|
-
headers: (0,
|
|
978
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
921
979
|
body,
|
|
922
980
|
failedResponseHandler: this.failedResponseHandler,
|
|
923
|
-
successfulResponseHandler: (0,
|
|
981
|
+
successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
|
|
924
982
|
deepseekChatChunkSchema
|
|
925
983
|
),
|
|
926
984
|
abortSignal: options.abortSignal,
|
|
@@ -1121,7 +1179,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1121
1179
|
});
|
|
1122
1180
|
controller.enqueue({
|
|
1123
1181
|
type: "tool-call",
|
|
1124
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
1182
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
1125
1183
|
toolName: toolCall.function.name,
|
|
1126
1184
|
input: toolCall.function.arguments
|
|
1127
1185
|
});
|
|
@@ -1162,6 +1220,11 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1162
1220
|
};
|
|
1163
1221
|
}
|
|
1164
1222
|
};
|
|
1223
|
+
|
|
1224
|
+
// src/internal/index.ts
|
|
1225
|
+
var deepseekLanguageModelOptions2 = getDeepseekChatOptionsSchema();
|
|
1226
|
+
var deepseekMessageProviderOptions2 = getDeepseekMessageOptionsSchema();
|
|
1227
|
+
var deepseekAssistantMessageProviderOptions2 = getDeepseekAssistantMessageOptionsSchema();
|
|
1165
1228
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1166
1229
|
0 && (module.exports = {
|
|
1167
1230
|
DeepSeekChatLanguageModel,
|