@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.mjs
CHANGED
|
@@ -31,89 +31,130 @@ import {
|
|
|
31
31
|
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
32
32
|
|
|
33
33
|
// src/chat/deepseek-chat-options.ts
|
|
34
|
+
import {
|
|
35
|
+
lazySchema,
|
|
36
|
+
zodSchema
|
|
37
|
+
} from "@ai-sdk/provider-utils";
|
|
34
38
|
import { z } from "zod/v4";
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
39
|
+
function createDeepseekChatOptionsSchema() {
|
|
40
|
+
return z.object({
|
|
41
|
+
/**
|
|
42
|
+
* Whether to return log probabilities for generated tokens.
|
|
43
|
+
*/
|
|
44
|
+
logprobs: 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: 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: 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: 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: 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: 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: z.boolean().optional()
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var chatOptionsSchema;
|
|
84
|
+
function getDeepseekChatOptionsSchema() {
|
|
85
|
+
return chatOptionsSchema != null ? chatOptionsSchema : chatOptionsSchema = createDeepseekChatOptionsSchema();
|
|
86
|
+
}
|
|
87
|
+
var deepseekChatOptions = lazySchema(
|
|
88
|
+
() => zodSchema(getDeepseekChatOptionsSchema())
|
|
89
|
+
);
|
|
90
|
+
function createDeepseekMessageOptionsSchema() {
|
|
91
|
+
return z.object({
|
|
92
|
+
/**
|
|
93
|
+
* The name of the participant represented by the message.
|
|
94
|
+
*
|
|
95
|
+
* Supported on system, user, and assistant messages.
|
|
96
|
+
*/
|
|
97
|
+
name: z.string().optional()
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
var messageOptionsSchema;
|
|
101
|
+
function getDeepseekMessageOptionsSchema() {
|
|
102
|
+
return messageOptionsSchema != null ? messageOptionsSchema : messageOptionsSchema = createDeepseekMessageOptionsSchema();
|
|
103
|
+
}
|
|
104
|
+
var deepseekMessageProviderOptions = lazySchema(
|
|
105
|
+
() => zodSchema(getDeepseekMessageOptionsSchema())
|
|
106
|
+
);
|
|
107
|
+
function createDeepseekAssistantMessageOptionsSchema() {
|
|
108
|
+
return getDeepseekMessageOptionsSchema().extend({
|
|
109
|
+
/**
|
|
110
|
+
* Whether the assistant message content is a prefix that DeepSeek should
|
|
111
|
+
* continue. This beta feature is only supported on the final assistant
|
|
112
|
+
* message when using a beta base URL.
|
|
113
|
+
*/
|
|
114
|
+
prefix: z.literal(true).optional()
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
var assistantMessageOptionsSchema;
|
|
118
|
+
function getDeepseekAssistantMessageOptionsSchema() {
|
|
119
|
+
return assistantMessageOptionsSchema != null ? assistantMessageOptionsSchema : assistantMessageOptionsSchema = createDeepseekAssistantMessageOptionsSchema();
|
|
120
|
+
}
|
|
121
|
+
var deepseekAssistantMessageProviderOptions = lazySchema(
|
|
122
|
+
() => zodSchema(getDeepseekAssistantMessageOptionsSchema())
|
|
123
|
+
);
|
|
93
124
|
|
|
94
125
|
// src/chat/deepseek-file-part-options.ts
|
|
126
|
+
import {
|
|
127
|
+
lazySchema as lazySchema2,
|
|
128
|
+
zodSchema as zodSchema2
|
|
129
|
+
} from "@ai-sdk/provider-utils";
|
|
95
130
|
import { z as z2 } from "zod/v4";
|
|
96
|
-
var deepseekFilePartProviderOptions =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
131
|
+
var deepseekFilePartProviderOptions = lazySchema2(
|
|
132
|
+
() => zodSchema2(
|
|
133
|
+
z2.object({
|
|
134
|
+
/**
|
|
135
|
+
* Controls how DeepSeek processes an image sent as an `image_url` part.
|
|
136
|
+
*
|
|
137
|
+
* @see https://api-docs.deepseek.com/api/create-chat-completion/
|
|
138
|
+
*/
|
|
139
|
+
imageDetail: z2.enum(["low", "high", "original", "auto"]).optional(),
|
|
140
|
+
/**
|
|
141
|
+
* Sends inline image data as a DeepSeek `file` part using `file_data`
|
|
142
|
+
* instead of an `image_url` data URL. When set, the file part's filename
|
|
143
|
+
* is preserved.
|
|
144
|
+
*
|
|
145
|
+
* This option only applies to inline image data. It cannot be combined
|
|
146
|
+
* with `imageDetail`.
|
|
147
|
+
*/
|
|
148
|
+
fileData: z2.literal(true).optional()
|
|
149
|
+
})
|
|
150
|
+
)
|
|
151
|
+
);
|
|
113
152
|
|
|
114
153
|
// src/chat/is-deepseek-v4-model.ts
|
|
115
154
|
function isDeepSeekV4Model(modelId) {
|
|
116
|
-
return
|
|
155
|
+
return !/(^|[/.])deepseek-(?:chat|reasoner|v[1-3](?:\.\d+)?)(?=[-/:.]|$)/.test(
|
|
156
|
+
modelId
|
|
157
|
+
);
|
|
117
158
|
}
|
|
118
159
|
|
|
119
160
|
// src/chat/convert-to-deepseek-chat-messages.ts
|
|
@@ -391,77 +432,105 @@ async function convertToDeepSeekChatMessages({
|
|
|
391
432
|
}
|
|
392
433
|
|
|
393
434
|
// src/chat/deepseek-chat-api-types.ts
|
|
394
|
-
import {
|
|
435
|
+
import {
|
|
436
|
+
lazySchema as lazySchema3,
|
|
437
|
+
zodSchema as zodSchema3
|
|
438
|
+
} from "@ai-sdk/provider-utils";
|
|
395
439
|
import { z as z3 } from "zod/v4";
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}).nullish()
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
z3.object({
|
|
423
|
-
token: z3.string(),
|
|
424
|
-
logprob: z3.number(),
|
|
425
|
-
bytes: z3.array(z3.number()).nullable()
|
|
440
|
+
function createTokenUsageSchema() {
|
|
441
|
+
return z3.object({
|
|
442
|
+
prompt_tokens: z3.number().nullish(),
|
|
443
|
+
completion_tokens: z3.number().nullish(),
|
|
444
|
+
prompt_cache_hit_tokens: z3.number().nullish(),
|
|
445
|
+
prompt_cache_miss_tokens: z3.number().nullish(),
|
|
446
|
+
total_tokens: z3.number().nullish(),
|
|
447
|
+
prompt_tokens_details: z3.object({
|
|
448
|
+
cached_tokens: z3.number().nullish()
|
|
449
|
+
}).nullish(),
|
|
450
|
+
completion_tokens_details: z3.object({
|
|
451
|
+
reasoning_tokens: z3.number().nullish()
|
|
452
|
+
}).nullish()
|
|
453
|
+
}).nullish();
|
|
454
|
+
}
|
|
455
|
+
var tokenUsageSchema;
|
|
456
|
+
function getTokenUsageSchema() {
|
|
457
|
+
return tokenUsageSchema != null ? tokenUsageSchema : tokenUsageSchema = createTokenUsageSchema();
|
|
458
|
+
}
|
|
459
|
+
function createDeepSeekErrorSchema() {
|
|
460
|
+
return z3.object({
|
|
461
|
+
error: z3.object({
|
|
462
|
+
message: z3.string(),
|
|
463
|
+
type: z3.string().nullish(),
|
|
464
|
+
param: z3.any().nullish(),
|
|
465
|
+
code: z3.union([z3.string(), z3.number()]).nullish()
|
|
426
466
|
})
|
|
427
|
-
)
|
|
428
|
-
}
|
|
429
|
-
var
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
var
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
var errorSchema;
|
|
470
|
+
function getDeepSeekErrorSchema() {
|
|
471
|
+
return errorSchema != null ? errorSchema : errorSchema = createDeepSeekErrorSchema();
|
|
472
|
+
}
|
|
473
|
+
var deepSeekErrorSchema = lazySchema3(
|
|
474
|
+
() => zodSchema3(getDeepSeekErrorSchema())
|
|
475
|
+
);
|
|
476
|
+
function createDeepseekChatLogprobsSchema() {
|
|
477
|
+
const deepseekChatLogprobSchema = z3.object({
|
|
478
|
+
token: z3.string(),
|
|
479
|
+
logprob: z3.number(),
|
|
480
|
+
bytes: z3.array(z3.number()).nullable(),
|
|
481
|
+
top_logprobs: z3.array(
|
|
482
|
+
z3.object({
|
|
483
|
+
token: z3.string(),
|
|
484
|
+
logprob: z3.number(),
|
|
485
|
+
bytes: z3.array(z3.number()).nullable()
|
|
486
|
+
})
|
|
487
|
+
)
|
|
488
|
+
});
|
|
489
|
+
return z3.object({
|
|
490
|
+
content: z3.array(deepseekChatLogprobSchema).nullish(),
|
|
491
|
+
reasoning_content: z3.array(deepseekChatLogprobSchema).nullish()
|
|
492
|
+
}).nullish();
|
|
493
|
+
}
|
|
494
|
+
var logprobsSchema;
|
|
495
|
+
function getDeepseekChatLogprobsSchema() {
|
|
496
|
+
return logprobsSchema != null ? logprobsSchema : logprobsSchema = createDeepseekChatLogprobsSchema();
|
|
497
|
+
}
|
|
498
|
+
var deepseekChatResponseSchema = lazySchema3(
|
|
499
|
+
() => zodSchema3(
|
|
440
500
|
z3.object({
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
501
|
+
id: z3.string().nullish(),
|
|
502
|
+
created: z3.number().nullish(),
|
|
503
|
+
model: z3.string().nullish(),
|
|
504
|
+
object: z3.literal("chat.completion").nullish(),
|
|
505
|
+
system_fingerprint: z3.string().nullish(),
|
|
506
|
+
choices: z3.array(
|
|
507
|
+
z3.object({
|
|
508
|
+
index: z3.number().nullish(),
|
|
509
|
+
message: z3.object({
|
|
510
|
+
role: z3.literal("assistant").nullish(),
|
|
511
|
+
content: z3.string().nullish(),
|
|
512
|
+
reasoning_content: z3.string().nullish(),
|
|
513
|
+
tool_calls: z3.array(
|
|
514
|
+
z3.object({
|
|
515
|
+
id: z3.string().nullish(),
|
|
516
|
+
type: z3.literal("function").nullish(),
|
|
517
|
+
function: z3.object({
|
|
518
|
+
name: z3.string(),
|
|
519
|
+
arguments: z3.string()
|
|
520
|
+
})
|
|
521
|
+
})
|
|
522
|
+
).nullish()
|
|
523
|
+
}),
|
|
524
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
525
|
+
finish_reason: z3.string().nullish()
|
|
526
|
+
})
|
|
527
|
+
),
|
|
528
|
+
usage: getTokenUsageSchema()
|
|
459
529
|
})
|
|
460
|
-
)
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
() => zodSchema(
|
|
530
|
+
)
|
|
531
|
+
);
|
|
532
|
+
var deepseekChatChunkSchema = lazySchema3(
|
|
533
|
+
() => zodSchema3(
|
|
465
534
|
z3.union([
|
|
466
535
|
z3.object({
|
|
467
536
|
id: z3.string().nullish(),
|
|
@@ -488,13 +557,13 @@ var deepseekChatChunkSchema = lazySchema(
|
|
|
488
557
|
})
|
|
489
558
|
).nullish()
|
|
490
559
|
}).nullish(),
|
|
491
|
-
logprobs:
|
|
560
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
492
561
|
finish_reason: z3.string().nullish()
|
|
493
562
|
})
|
|
494
563
|
),
|
|
495
|
-
usage:
|
|
564
|
+
usage: getTokenUsageSchema()
|
|
496
565
|
}),
|
|
497
|
-
|
|
566
|
+
getDeepSeekErrorSchema()
|
|
498
567
|
])
|
|
499
568
|
)
|
|
500
569
|
);
|
|
@@ -1117,7 +1186,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1117
1186
|
};
|
|
1118
1187
|
|
|
1119
1188
|
// src/version.ts
|
|
1120
|
-
var VERSION = true ? "1.0.
|
|
1189
|
+
var VERSION = true ? "1.0.64" : "0.0.0-test";
|
|
1121
1190
|
|
|
1122
1191
|
// src/deepseek-provider.ts
|
|
1123
1192
|
function createDeepSeek(options = {}) {
|