@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/index.js
CHANGED
|
@@ -28,100 +28,135 @@ module.exports = __toCommonJS(index_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/deepseek-provider.ts
|
|
30
30
|
var import_provider4 = require("@ai-sdk/provider");
|
|
31
|
-
var
|
|
31
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
33
|
// src/chat/deepseek-chat-language-model.ts
|
|
34
34
|
var import_provider3 = require("@ai-sdk/provider");
|
|
35
|
-
var
|
|
35
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
36
36
|
|
|
37
37
|
// src/chat/convert-to-deepseek-chat-messages.ts
|
|
38
38
|
var import_provider = require("@ai-sdk/provider");
|
|
39
|
-
var
|
|
39
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
40
40
|
|
|
41
41
|
// src/chat/deepseek-chat-options.ts
|
|
42
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
42
43
|
var import_v4 = require("zod/v4");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
44
|
+
function createDeepseekChatOptionsSchema() {
|
|
45
|
+
return import_v4.z.object({
|
|
46
|
+
/**
|
|
47
|
+
* Whether to return log probabilities for generated tokens.
|
|
48
|
+
*/
|
|
49
|
+
logprobs: import_v4.z.boolean().optional(),
|
|
50
|
+
/**
|
|
51
|
+
* Number of most likely tokens to return at each token position.
|
|
52
|
+
*
|
|
53
|
+
* Setting this option automatically enables `logprobs`.
|
|
54
|
+
*/
|
|
55
|
+
topLogprobs: import_v4.z.number().int().min(0).max(20).optional(),
|
|
56
|
+
/**
|
|
57
|
+
* An opaque identifier for the end user. DeepSeek uses this identifier for
|
|
58
|
+
* content-safety tracing and request isolation.
|
|
59
|
+
*
|
|
60
|
+
* Must contain only ASCII letters, numbers, underscores, and hyphens, and
|
|
61
|
+
* must be at most 512 characters long.
|
|
62
|
+
*/
|
|
63
|
+
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(),
|
|
64
|
+
/**
|
|
65
|
+
* Type of thinking to use. Defaults to `enabled`.
|
|
66
|
+
*/
|
|
67
|
+
thinking: import_v4.z.object({
|
|
68
|
+
// `adaptive` is accepted at runtime for backwards compatibility and
|
|
69
|
+
// mapped to `enabled`, but is intentionally excluded from the exported
|
|
70
|
+
// provider options type.
|
|
71
|
+
type: import_v4.z.enum(["adaptive", "enabled", "disabled"]).optional()
|
|
72
|
+
}).optional(),
|
|
73
|
+
/**
|
|
74
|
+
* Controls the thinking strength for DeepSeek V4 reasoning models.
|
|
75
|
+
*/
|
|
76
|
+
// `medium` and `xhigh` are accepted at runtime for backwards compatibility
|
|
77
|
+
// and mapped to canonical DeepSeek values, but are intentionally excluded
|
|
78
|
+
// from the exported provider options type.
|
|
79
|
+
reasoningEffort: import_v4.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
80
|
+
/**
|
|
81
|
+
* Whether to use strict JSON schema validation for structured outputs.
|
|
82
|
+
* Only applies when the serving endpoint supports JSON schema response
|
|
83
|
+
* formats (e.g. Azure). Defaults to `true`.
|
|
84
|
+
*/
|
|
85
|
+
strictJsonSchema: import_v4.z.boolean().optional()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
var chatOptionsSchema;
|
|
89
|
+
function getDeepseekChatOptionsSchema() {
|
|
90
|
+
return chatOptionsSchema != null ? chatOptionsSchema : chatOptionsSchema = createDeepseekChatOptionsSchema();
|
|
91
|
+
}
|
|
92
|
+
var deepseekChatOptions = (0, import_provider_utils.lazySchema)(
|
|
93
|
+
() => (0, import_provider_utils.zodSchema)(getDeepseekChatOptionsSchema())
|
|
94
|
+
);
|
|
95
|
+
function createDeepseekMessageOptionsSchema() {
|
|
96
|
+
return import_v4.z.object({
|
|
97
|
+
/**
|
|
98
|
+
* The name of the participant represented by the message.
|
|
99
|
+
*
|
|
100
|
+
* Supported on system, user, and assistant messages.
|
|
101
|
+
*/
|
|
102
|
+
name: import_v4.z.string().optional()
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
var messageOptionsSchema;
|
|
106
|
+
function getDeepseekMessageOptionsSchema() {
|
|
107
|
+
return messageOptionsSchema != null ? messageOptionsSchema : messageOptionsSchema = createDeepseekMessageOptionsSchema();
|
|
108
|
+
}
|
|
109
|
+
var deepseekMessageProviderOptions = (0, import_provider_utils.lazySchema)(
|
|
110
|
+
() => (0, import_provider_utils.zodSchema)(getDeepseekMessageOptionsSchema())
|
|
111
|
+
);
|
|
112
|
+
function createDeepseekAssistantMessageOptionsSchema() {
|
|
113
|
+
return getDeepseekMessageOptionsSchema().extend({
|
|
114
|
+
/**
|
|
115
|
+
* Whether the assistant message content is a prefix that DeepSeek should
|
|
116
|
+
* continue. This beta feature is only supported on the final assistant
|
|
117
|
+
* message when using a beta base URL.
|
|
118
|
+
*/
|
|
119
|
+
prefix: import_v4.z.literal(true).optional()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
var assistantMessageOptionsSchema;
|
|
123
|
+
function getDeepseekAssistantMessageOptionsSchema() {
|
|
124
|
+
return assistantMessageOptionsSchema != null ? assistantMessageOptionsSchema : assistantMessageOptionsSchema = createDeepseekAssistantMessageOptionsSchema();
|
|
125
|
+
}
|
|
126
|
+
var deepseekAssistantMessageProviderOptions = (0, import_provider_utils.lazySchema)(
|
|
127
|
+
() => (0, import_provider_utils.zodSchema)(getDeepseekAssistantMessageOptionsSchema())
|
|
128
|
+
);
|
|
101
129
|
|
|
102
130
|
// src/chat/deepseek-file-part-options.ts
|
|
131
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
103
132
|
var import_v42 = require("zod/v4");
|
|
104
|
-
var deepseekFilePartProviderOptions =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
133
|
+
var deepseekFilePartProviderOptions = (0, import_provider_utils2.lazySchema)(
|
|
134
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
135
|
+
import_v42.z.object({
|
|
136
|
+
/**
|
|
137
|
+
* Controls how DeepSeek processes an image sent as an `image_url` part.
|
|
138
|
+
*
|
|
139
|
+
* @see https://api-docs.deepseek.com/api/create-chat-completion/
|
|
140
|
+
*/
|
|
141
|
+
imageDetail: import_v42.z.enum(["low", "high", "original", "auto"]).optional(),
|
|
142
|
+
/**
|
|
143
|
+
* Sends inline image data as a DeepSeek `file` part using `file_data`
|
|
144
|
+
* instead of an `image_url` data URL. When set, the file part's filename
|
|
145
|
+
* is preserved.
|
|
146
|
+
*
|
|
147
|
+
* This option only applies to inline image data. It cannot be combined
|
|
148
|
+
* with `imageDetail`.
|
|
149
|
+
*/
|
|
150
|
+
fileData: import_v42.z.literal(true).optional()
|
|
151
|
+
})
|
|
152
|
+
)
|
|
153
|
+
);
|
|
121
154
|
|
|
122
155
|
// src/chat/is-deepseek-v4-model.ts
|
|
123
156
|
function isDeepSeekV4Model(modelId) {
|
|
124
|
-
return
|
|
157
|
+
return !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\.\d+)?)(?=[-/:.]|$)/.test(
|
|
158
|
+
modelId
|
|
159
|
+
);
|
|
125
160
|
}
|
|
126
161
|
|
|
127
162
|
// src/chat/convert-to-deepseek-chat-messages.ts
|
|
@@ -166,7 +201,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
166
201
|
let index = -1;
|
|
167
202
|
for (const { role, content, providerOptions } of prompt) {
|
|
168
203
|
index++;
|
|
169
|
-
const deepseekMessageOptions = await (0,
|
|
204
|
+
const deepseekMessageOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
170
205
|
provider: providerOptionsName,
|
|
171
206
|
providerOptions,
|
|
172
207
|
schema: deepseekAssistantMessageProviderOptions
|
|
@@ -218,7 +253,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
218
253
|
if (part.type === "text") {
|
|
219
254
|
userContent.push({ type: "text", text: part.text });
|
|
220
255
|
} else if (part.type === "file" && (part.mediaType === "image" || part.mediaType.startsWith("image/"))) {
|
|
221
|
-
const filePartOptions = await (0,
|
|
256
|
+
const filePartOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
222
257
|
provider: providerOptionsName,
|
|
223
258
|
providerOptions: part.providerOptions,
|
|
224
259
|
schema: deepseekFilePartProviderOptions
|
|
@@ -254,7 +289,7 @@ async function convertToDeepSeekChatMessages({
|
|
|
254
289
|
}
|
|
255
290
|
});
|
|
256
291
|
} else {
|
|
257
|
-
const dataUrl = `data:${resolvedMediaType === "image/jpg" ? "image/jpeg" : resolvedMediaType};base64,${(0,
|
|
292
|
+
const dataUrl = `data:${resolvedMediaType === "image/jpg" ? "image/jpeg" : resolvedMediaType};base64,${(0, import_provider_utils3.convertToBase64)(part.data)}`;
|
|
258
293
|
if ((filePartOptions == null ? void 0 : filePartOptions.fileData) === true) {
|
|
259
294
|
if (filePartOptions.imageDetail != null) {
|
|
260
295
|
throw new import_provider.InvalidPromptError({
|
|
@@ -399,77 +434,102 @@ async function convertToDeepSeekChatMessages({
|
|
|
399
434
|
}
|
|
400
435
|
|
|
401
436
|
// src/chat/deepseek-chat-api-types.ts
|
|
402
|
-
var
|
|
437
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
403
438
|
var import_v43 = require("zod/v4");
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}).nullish()
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
import_v43.z.object({
|
|
431
|
-
token: import_v43.z.string(),
|
|
432
|
-
logprob: import_v43.z.number(),
|
|
433
|
-
bytes: import_v43.z.array(import_v43.z.number()).nullable()
|
|
439
|
+
function createTokenUsageSchema() {
|
|
440
|
+
return import_v43.z.object({
|
|
441
|
+
prompt_tokens: import_v43.z.number().nullish(),
|
|
442
|
+
completion_tokens: import_v43.z.number().nullish(),
|
|
443
|
+
prompt_cache_hit_tokens: import_v43.z.number().nullish(),
|
|
444
|
+
prompt_cache_miss_tokens: import_v43.z.number().nullish(),
|
|
445
|
+
total_tokens: import_v43.z.number().nullish(),
|
|
446
|
+
prompt_tokens_details: import_v43.z.object({
|
|
447
|
+
cached_tokens: import_v43.z.number().nullish()
|
|
448
|
+
}).nullish(),
|
|
449
|
+
completion_tokens_details: import_v43.z.object({
|
|
450
|
+
reasoning_tokens: import_v43.z.number().nullish()
|
|
451
|
+
}).nullish()
|
|
452
|
+
}).nullish();
|
|
453
|
+
}
|
|
454
|
+
var tokenUsageSchema;
|
|
455
|
+
function getTokenUsageSchema() {
|
|
456
|
+
return tokenUsageSchema != null ? tokenUsageSchema : tokenUsageSchema = createTokenUsageSchema();
|
|
457
|
+
}
|
|
458
|
+
function createDeepSeekErrorSchema() {
|
|
459
|
+
return import_v43.z.object({
|
|
460
|
+
error: import_v43.z.object({
|
|
461
|
+
message: import_v43.z.string(),
|
|
462
|
+
type: import_v43.z.string().nullish(),
|
|
463
|
+
param: import_v43.z.any().nullish(),
|
|
464
|
+
code: import_v43.z.union([import_v43.z.string(), import_v43.z.number()]).nullish()
|
|
434
465
|
})
|
|
435
|
-
)
|
|
436
|
-
}
|
|
437
|
-
var
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
var
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
var errorSchema;
|
|
469
|
+
function getDeepSeekErrorSchema() {
|
|
470
|
+
return errorSchema != null ? errorSchema : errorSchema = createDeepSeekErrorSchema();
|
|
471
|
+
}
|
|
472
|
+
var deepSeekErrorSchema = (0, import_provider_utils4.lazySchema)(
|
|
473
|
+
() => (0, import_provider_utils4.zodSchema)(getDeepSeekErrorSchema())
|
|
474
|
+
);
|
|
475
|
+
function createDeepseekChatLogprobsSchema() {
|
|
476
|
+
const deepseekChatLogprobSchema = import_v43.z.object({
|
|
477
|
+
token: import_v43.z.string(),
|
|
478
|
+
logprob: import_v43.z.number(),
|
|
479
|
+
bytes: import_v43.z.array(import_v43.z.number()).nullable(),
|
|
480
|
+
top_logprobs: import_v43.z.array(
|
|
481
|
+
import_v43.z.object({
|
|
482
|
+
token: import_v43.z.string(),
|
|
483
|
+
logprob: import_v43.z.number(),
|
|
484
|
+
bytes: import_v43.z.array(import_v43.z.number()).nullable()
|
|
485
|
+
})
|
|
486
|
+
)
|
|
487
|
+
});
|
|
488
|
+
return import_v43.z.object({
|
|
489
|
+
content: import_v43.z.array(deepseekChatLogprobSchema).nullish(),
|
|
490
|
+
reasoning_content: import_v43.z.array(deepseekChatLogprobSchema).nullish()
|
|
491
|
+
}).nullish();
|
|
492
|
+
}
|
|
493
|
+
var logprobsSchema;
|
|
494
|
+
function getDeepseekChatLogprobsSchema() {
|
|
495
|
+
return logprobsSchema != null ? logprobsSchema : logprobsSchema = createDeepseekChatLogprobsSchema();
|
|
496
|
+
}
|
|
497
|
+
var deepseekChatResponseSchema = (0, import_provider_utils4.lazySchema)(
|
|
498
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
448
499
|
import_v43.z.object({
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
500
|
+
id: import_v43.z.string().nullish(),
|
|
501
|
+
created: import_v43.z.number().nullish(),
|
|
502
|
+
model: import_v43.z.string().nullish(),
|
|
503
|
+
object: import_v43.z.literal("chat.completion").nullish(),
|
|
504
|
+
system_fingerprint: import_v43.z.string().nullish(),
|
|
505
|
+
choices: import_v43.z.array(
|
|
506
|
+
import_v43.z.object({
|
|
507
|
+
index: import_v43.z.number().nullish(),
|
|
508
|
+
message: import_v43.z.object({
|
|
509
|
+
role: import_v43.z.literal("assistant").nullish(),
|
|
510
|
+
content: import_v43.z.string().nullish(),
|
|
511
|
+
reasoning_content: import_v43.z.string().nullish(),
|
|
512
|
+
tool_calls: import_v43.z.array(
|
|
513
|
+
import_v43.z.object({
|
|
514
|
+
id: import_v43.z.string().nullish(),
|
|
515
|
+
type: import_v43.z.literal("function").nullish(),
|
|
516
|
+
function: import_v43.z.object({
|
|
517
|
+
name: import_v43.z.string(),
|
|
518
|
+
arguments: import_v43.z.string()
|
|
519
|
+
})
|
|
520
|
+
})
|
|
521
|
+
).nullish()
|
|
522
|
+
}),
|
|
523
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
524
|
+
finish_reason: import_v43.z.string().nullish()
|
|
525
|
+
})
|
|
526
|
+
),
|
|
527
|
+
usage: getTokenUsageSchema()
|
|
467
528
|
})
|
|
468
|
-
)
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
() => (0, import_provider_utils2.zodSchema)(
|
|
529
|
+
)
|
|
530
|
+
);
|
|
531
|
+
var deepseekChatChunkSchema = (0, import_provider_utils4.lazySchema)(
|
|
532
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
473
533
|
import_v43.z.union([
|
|
474
534
|
import_v43.z.object({
|
|
475
535
|
id: import_v43.z.string().nullish(),
|
|
@@ -496,13 +556,13 @@ var deepseekChatChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
496
556
|
})
|
|
497
557
|
).nullish()
|
|
498
558
|
}).nullish(),
|
|
499
|
-
logprobs:
|
|
559
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
500
560
|
finish_reason: import_v43.z.string().nullish()
|
|
501
561
|
})
|
|
502
562
|
),
|
|
503
|
-
usage:
|
|
563
|
+
usage: getTokenUsageSchema()
|
|
504
564
|
}),
|
|
505
|
-
|
|
565
|
+
getDeepSeekErrorSchema()
|
|
506
566
|
])
|
|
507
567
|
)
|
|
508
568
|
);
|
|
@@ -620,7 +680,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
620
680
|
};
|
|
621
681
|
this.modelId = modelId;
|
|
622
682
|
this.config = config;
|
|
623
|
-
this.failedResponseHandler = (0,
|
|
683
|
+
this.failedResponseHandler = (0, import_provider_utils5.createJsonErrorResponseHandler)({
|
|
624
684
|
errorSchema: deepSeekErrorSchema,
|
|
625
685
|
errorToMessage: (error) => error.error.message
|
|
626
686
|
});
|
|
@@ -647,7 +707,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
647
707
|
seed
|
|
648
708
|
}) {
|
|
649
709
|
var _a, _b, _c, _d;
|
|
650
|
-
const deepseekOptions = (_a = await (0,
|
|
710
|
+
const deepseekOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
|
|
651
711
|
provider: this.providerOptionsName,
|
|
652
712
|
providerOptions,
|
|
653
713
|
schema: deepseekChatOptions
|
|
@@ -760,15 +820,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
760
820
|
responseHeaders,
|
|
761
821
|
value: responseBody,
|
|
762
822
|
rawValue: rawResponse
|
|
763
|
-
} = await (0,
|
|
823
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
764
824
|
url: this.config.url({
|
|
765
825
|
path: "/chat/completions",
|
|
766
826
|
modelId: this.modelId
|
|
767
827
|
}),
|
|
768
|
-
headers: (0,
|
|
828
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
769
829
|
body: args,
|
|
770
830
|
failedResponseHandler: this.failedResponseHandler,
|
|
771
|
-
successfulResponseHandler: (0,
|
|
831
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
772
832
|
deepseekChatResponseSchema
|
|
773
833
|
),
|
|
774
834
|
abortSignal: options.abortSignal,
|
|
@@ -787,7 +847,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
787
847
|
for (const toolCall of choice.message.tool_calls) {
|
|
788
848
|
content.push({
|
|
789
849
|
type: "tool-call",
|
|
790
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
850
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
791
851
|
toolName: toolCall.function.name,
|
|
792
852
|
input: toolCall.function.arguments
|
|
793
853
|
});
|
|
@@ -844,15 +904,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
844
904
|
stream: true,
|
|
845
905
|
stream_options: { include_usage: true }
|
|
846
906
|
};
|
|
847
|
-
const { responseHeaders, value: response } = await (0,
|
|
907
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
|
|
848
908
|
url: this.config.url({
|
|
849
909
|
path: "/chat/completions",
|
|
850
910
|
modelId: this.modelId
|
|
851
911
|
}),
|
|
852
|
-
headers: (0,
|
|
912
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
|
|
853
913
|
body,
|
|
854
914
|
failedResponseHandler: this.failedResponseHandler,
|
|
855
|
-
successfulResponseHandler: (0,
|
|
915
|
+
successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
|
|
856
916
|
deepseekChatChunkSchema
|
|
857
917
|
),
|
|
858
918
|
abortSignal: options.abortSignal,
|
|
@@ -1012,14 +1072,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1012
1072
|
delta: toolCall2.function.arguments
|
|
1013
1073
|
});
|
|
1014
1074
|
}
|
|
1015
|
-
if ((0,
|
|
1075
|
+
if ((0, import_provider_utils5.isParsableJson)(toolCall2.function.arguments)) {
|
|
1016
1076
|
controller.enqueue({
|
|
1017
1077
|
type: "tool-input-end",
|
|
1018
1078
|
id: toolCall2.id
|
|
1019
1079
|
});
|
|
1020
1080
|
controller.enqueue({
|
|
1021
1081
|
type: "tool-call",
|
|
1022
|
-
toolCallId: (_g = toolCall2.id) != null ? _g : (0,
|
|
1082
|
+
toolCallId: (_g = toolCall2.id) != null ? _g : (0, import_provider_utils5.generateId)(),
|
|
1023
1083
|
toolName: toolCall2.function.name,
|
|
1024
1084
|
input: toolCall2.function.arguments
|
|
1025
1085
|
});
|
|
@@ -1040,14 +1100,14 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1040
1100
|
id: toolCall.id,
|
|
1041
1101
|
delta: (_k = toolCallDelta.function.arguments) != null ? _k : ""
|
|
1042
1102
|
});
|
|
1043
|
-
if (((_l = toolCall.function) == null ? void 0 : _l.name) != null && ((_m = toolCall.function) == null ? void 0 : _m.arguments) != null && (0,
|
|
1103
|
+
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)) {
|
|
1044
1104
|
controller.enqueue({
|
|
1045
1105
|
type: "tool-input-end",
|
|
1046
1106
|
id: toolCall.id
|
|
1047
1107
|
});
|
|
1048
1108
|
controller.enqueue({
|
|
1049
1109
|
type: "tool-call",
|
|
1050
|
-
toolCallId: (_n = toolCall.id) != null ? _n : (0,
|
|
1110
|
+
toolCallId: (_n = toolCall.id) != null ? _n : (0, import_provider_utils5.generateId)(),
|
|
1051
1111
|
toolName: toolCall.function.name,
|
|
1052
1112
|
input: toolCall.function.arguments
|
|
1053
1113
|
});
|
|
@@ -1073,7 +1133,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1073
1133
|
});
|
|
1074
1134
|
controller.enqueue({
|
|
1075
1135
|
type: "tool-call",
|
|
1076
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0,
|
|
1136
|
+
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
|
|
1077
1137
|
toolName: toolCall.function.name,
|
|
1078
1138
|
input: toolCall.function.arguments
|
|
1079
1139
|
});
|
|
@@ -1123,15 +1183,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1123
1183
|
};
|
|
1124
1184
|
|
|
1125
1185
|
// src/version.ts
|
|
1126
|
-
var VERSION = true ? "1.0.
|
|
1186
|
+
var VERSION = true ? "1.0.64" : "0.0.0-test";
|
|
1127
1187
|
|
|
1128
1188
|
// src/deepseek-provider.ts
|
|
1129
1189
|
function createDeepSeek(options = {}) {
|
|
1130
1190
|
var _a;
|
|
1131
|
-
const baseURL = (_a = (0,
|
|
1132
|
-
const getHeaders = () => (0,
|
|
1191
|
+
const baseURL = (_a = (0, import_provider_utils6.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.deepseek.com";
|
|
1192
|
+
const getHeaders = () => (0, import_provider_utils6.withUserAgentSuffix)(
|
|
1133
1193
|
{
|
|
1134
|
-
Authorization: `Bearer ${(0,
|
|
1194
|
+
Authorization: `Bearer ${(0, import_provider_utils6.loadApiKey)({
|
|
1135
1195
|
apiKey: options.apiKey,
|
|
1136
1196
|
environmentVariableName: "DEEPSEEK_API_KEY",
|
|
1137
1197
|
description: "DeepSeek API key"
|