@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/index.mjs
CHANGED
|
@@ -30,85 +30,124 @@ import {
|
|
|
30
30
|
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
31
31
|
|
|
32
32
|
// src/chat/deepseek-chat-options.ts
|
|
33
|
+
import {
|
|
34
|
+
lazySchema,
|
|
35
|
+
zodSchema
|
|
36
|
+
} from "@ai-sdk/provider-utils";
|
|
33
37
|
import { z } from "zod/v4";
|
|
34
|
-
|
|
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
|
-
|
|
38
|
+
function createDeepseekChatOptionsSchema() {
|
|
39
|
+
return z.object({
|
|
40
|
+
/**
|
|
41
|
+
* Whether to return log probabilities for generated tokens.
|
|
42
|
+
*/
|
|
43
|
+
logprobs: z.boolean().optional(),
|
|
44
|
+
/**
|
|
45
|
+
* Number of most likely tokens to return at each token position.
|
|
46
|
+
*
|
|
47
|
+
* Setting this option automatically enables `logprobs`.
|
|
48
|
+
*/
|
|
49
|
+
topLogprobs: z.number().int().min(0).max(20).optional(),
|
|
50
|
+
/**
|
|
51
|
+
* An opaque identifier for the end user. DeepSeek uses this identifier for
|
|
52
|
+
* content-safety tracing and request isolation.
|
|
53
|
+
*
|
|
54
|
+
* Must contain only ASCII letters, numbers, underscores, and hyphens, and
|
|
55
|
+
* must be at most 512 characters long.
|
|
56
|
+
*/
|
|
57
|
+
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(),
|
|
58
|
+
/**
|
|
59
|
+
* Type of thinking to use. Defaults to `enabled`.
|
|
60
|
+
*/
|
|
61
|
+
thinking: z.object({
|
|
62
|
+
// `adaptive` is accepted at runtime for backwards compatibility and
|
|
63
|
+
// mapped to `enabled`, but is intentionally excluded from the exported
|
|
64
|
+
// provider options type.
|
|
65
|
+
type: z.enum(["adaptive", "enabled", "disabled"]).optional()
|
|
66
|
+
}).optional(),
|
|
67
|
+
/**
|
|
68
|
+
* Controls the thinking strength for DeepSeek V4 reasoning models.
|
|
69
|
+
*/
|
|
70
|
+
// `medium` and `xhigh` are accepted at runtime for backwards compatibility
|
|
71
|
+
// and mapped to canonical DeepSeek values, but are intentionally excluded
|
|
72
|
+
// from the exported provider options type.
|
|
73
|
+
reasoningEffort: z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
74
|
+
/**
|
|
75
|
+
* Whether to use strict JSON schema validation for structured outputs.
|
|
76
|
+
* Only applies when the serving endpoint supports JSON schema response
|
|
77
|
+
* formats (e.g. Azure). Defaults to `true`.
|
|
78
|
+
*/
|
|
79
|
+
strictJsonSchema: z.boolean().optional()
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
var chatOptionsSchema;
|
|
83
|
+
function getDeepseekChatOptionsSchema() {
|
|
84
|
+
return chatOptionsSchema != null ? chatOptionsSchema : chatOptionsSchema = createDeepseekChatOptionsSchema();
|
|
85
|
+
}
|
|
86
|
+
var deepseekLanguageModelOptions = lazySchema(
|
|
87
|
+
() => zodSchema(getDeepseekChatOptionsSchema())
|
|
88
|
+
);
|
|
89
|
+
function createDeepseekMessageOptionsSchema() {
|
|
90
|
+
return z.object({
|
|
91
|
+
/**
|
|
92
|
+
* The name of the participant represented by the message.
|
|
93
|
+
*
|
|
94
|
+
* Supported on system, user, and assistant messages.
|
|
95
|
+
*/
|
|
96
|
+
name: z.string().optional()
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
var messageOptionsSchema;
|
|
100
|
+
function getDeepseekMessageOptionsSchema() {
|
|
101
|
+
return messageOptionsSchema != null ? messageOptionsSchema : messageOptionsSchema = createDeepseekMessageOptionsSchema();
|
|
102
|
+
}
|
|
103
|
+
var deepseekMessageProviderOptions = lazySchema(
|
|
104
|
+
() => zodSchema(getDeepseekMessageOptionsSchema())
|
|
105
|
+
);
|
|
106
|
+
function createDeepseekAssistantMessageOptionsSchema() {
|
|
107
|
+
return getDeepseekMessageOptionsSchema().extend({
|
|
108
|
+
/**
|
|
109
|
+
* Whether the assistant message content is a prefix that DeepSeek should
|
|
110
|
+
* continue. This beta feature is only supported on the final assistant
|
|
111
|
+
* message when using a beta base URL.
|
|
112
|
+
*/
|
|
113
|
+
prefix: z.literal(true).optional()
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
var assistantMessageOptionsSchema;
|
|
117
|
+
function getDeepseekAssistantMessageOptionsSchema() {
|
|
118
|
+
return assistantMessageOptionsSchema != null ? assistantMessageOptionsSchema : assistantMessageOptionsSchema = createDeepseekAssistantMessageOptionsSchema();
|
|
119
|
+
}
|
|
120
|
+
var deepseekAssistantMessageProviderOptions = lazySchema(
|
|
121
|
+
() => zodSchema(getDeepseekAssistantMessageOptionsSchema())
|
|
122
|
+
);
|
|
92
123
|
|
|
93
124
|
// src/chat/deepseek-file-part-options.ts
|
|
125
|
+
import {
|
|
126
|
+
lazySchema as lazySchema2,
|
|
127
|
+
zodSchema as zodSchema2
|
|
128
|
+
} from "@ai-sdk/provider-utils";
|
|
94
129
|
import { z as z2 } from "zod/v4";
|
|
95
|
-
var deepseekFilePartProviderOptions =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
130
|
+
var deepseekFilePartProviderOptions = lazySchema2(
|
|
131
|
+
() => zodSchema2(
|
|
132
|
+
z2.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: z2.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: z2.literal(true).optional()
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
);
|
|
112
151
|
|
|
113
152
|
// src/chat/is-deepseek-v4-model.ts
|
|
114
153
|
function isDeepSeekV4Model(modelId) {
|
|
@@ -443,77 +482,105 @@ function convertDeepSeekUsage(usage) {
|
|
|
443
482
|
}
|
|
444
483
|
|
|
445
484
|
// src/chat/deepseek-chat-api-types.ts
|
|
446
|
-
import {
|
|
485
|
+
import {
|
|
486
|
+
lazySchema as lazySchema3,
|
|
487
|
+
zodSchema as zodSchema3
|
|
488
|
+
} from "@ai-sdk/provider-utils";
|
|
447
489
|
import { z as z3 } from "zod/v4";
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}).nullish()
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
z3.object({
|
|
475
|
-
token: z3.string(),
|
|
476
|
-
logprob: z3.number(),
|
|
477
|
-
bytes: z3.array(z3.number()).nullable()
|
|
490
|
+
function createTokenUsageSchema() {
|
|
491
|
+
return z3.looseObject({
|
|
492
|
+
prompt_tokens: z3.number().nullish(),
|
|
493
|
+
completion_tokens: z3.number().nullish(),
|
|
494
|
+
prompt_cache_hit_tokens: z3.number().nullish(),
|
|
495
|
+
prompt_cache_miss_tokens: z3.number().nullish(),
|
|
496
|
+
total_tokens: z3.number().nullish(),
|
|
497
|
+
prompt_tokens_details: z3.looseObject({
|
|
498
|
+
cached_tokens: z3.number().nullish()
|
|
499
|
+
}).nullish(),
|
|
500
|
+
completion_tokens_details: z3.looseObject({
|
|
501
|
+
reasoning_tokens: z3.number().nullish()
|
|
502
|
+
}).nullish()
|
|
503
|
+
}).nullish();
|
|
504
|
+
}
|
|
505
|
+
var tokenUsageSchema;
|
|
506
|
+
function getTokenUsageSchema() {
|
|
507
|
+
return tokenUsageSchema != null ? tokenUsageSchema : tokenUsageSchema = createTokenUsageSchema();
|
|
508
|
+
}
|
|
509
|
+
function createDeepSeekErrorSchema() {
|
|
510
|
+
return z3.object({
|
|
511
|
+
error: z3.object({
|
|
512
|
+
message: z3.string(),
|
|
513
|
+
type: z3.string().nullish(),
|
|
514
|
+
param: z3.any().nullish(),
|
|
515
|
+
code: z3.union([z3.string(), z3.number()]).nullish()
|
|
478
516
|
})
|
|
479
|
-
)
|
|
480
|
-
}
|
|
481
|
-
var
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
var
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
var errorSchema;
|
|
520
|
+
function getDeepSeekErrorSchema() {
|
|
521
|
+
return errorSchema != null ? errorSchema : errorSchema = createDeepSeekErrorSchema();
|
|
522
|
+
}
|
|
523
|
+
var deepSeekErrorSchema = lazySchema3(
|
|
524
|
+
() => zodSchema3(getDeepSeekErrorSchema())
|
|
525
|
+
);
|
|
526
|
+
function createDeepseekChatLogprobsSchema() {
|
|
527
|
+
const deepseekChatLogprobSchema = z3.object({
|
|
528
|
+
token: z3.string(),
|
|
529
|
+
logprob: z3.number(),
|
|
530
|
+
bytes: z3.array(z3.number()).nullable(),
|
|
531
|
+
top_logprobs: z3.array(
|
|
532
|
+
z3.object({
|
|
533
|
+
token: z3.string(),
|
|
534
|
+
logprob: z3.number(),
|
|
535
|
+
bytes: z3.array(z3.number()).nullable()
|
|
536
|
+
})
|
|
537
|
+
)
|
|
538
|
+
});
|
|
539
|
+
return z3.object({
|
|
540
|
+
content: z3.array(deepseekChatLogprobSchema).nullish(),
|
|
541
|
+
reasoning_content: z3.array(deepseekChatLogprobSchema).nullish()
|
|
542
|
+
}).nullish();
|
|
543
|
+
}
|
|
544
|
+
var logprobsSchema;
|
|
545
|
+
function getDeepseekChatLogprobsSchema() {
|
|
546
|
+
return logprobsSchema != null ? logprobsSchema : logprobsSchema = createDeepseekChatLogprobsSchema();
|
|
547
|
+
}
|
|
548
|
+
var deepseekChatResponseSchema = lazySchema3(
|
|
549
|
+
() => zodSchema3(
|
|
492
550
|
z3.object({
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
551
|
+
id: z3.string().nullish(),
|
|
552
|
+
created: z3.number().nullish(),
|
|
553
|
+
model: z3.string().nullish(),
|
|
554
|
+
object: z3.literal("chat.completion").nullish(),
|
|
555
|
+
system_fingerprint: z3.string().nullish(),
|
|
556
|
+
choices: z3.array(
|
|
557
|
+
z3.object({
|
|
558
|
+
index: z3.number().nullish(),
|
|
559
|
+
message: z3.object({
|
|
560
|
+
role: z3.literal("assistant").nullish(),
|
|
561
|
+
content: z3.string().nullish(),
|
|
562
|
+
reasoning_content: z3.string().nullish(),
|
|
563
|
+
tool_calls: z3.array(
|
|
564
|
+
z3.object({
|
|
565
|
+
id: z3.string().nullish(),
|
|
566
|
+
type: z3.literal("function").nullish(),
|
|
567
|
+
function: z3.object({
|
|
568
|
+
name: z3.string(),
|
|
569
|
+
arguments: z3.string()
|
|
570
|
+
})
|
|
571
|
+
})
|
|
572
|
+
).nullish()
|
|
573
|
+
}),
|
|
574
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
575
|
+
finish_reason: z3.string().nullish()
|
|
576
|
+
})
|
|
577
|
+
),
|
|
578
|
+
usage: getTokenUsageSchema()
|
|
511
579
|
})
|
|
512
|
-
)
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
() => zodSchema(
|
|
580
|
+
)
|
|
581
|
+
);
|
|
582
|
+
var deepseekChatChunkSchema = lazySchema3(
|
|
583
|
+
() => zodSchema3(
|
|
517
584
|
z3.union([
|
|
518
585
|
z3.object({
|
|
519
586
|
id: z3.string().nullish(),
|
|
@@ -540,13 +607,13 @@ var deepseekChatChunkSchema = lazySchema(
|
|
|
540
607
|
})
|
|
541
608
|
).nullish()
|
|
542
609
|
}).nullish(),
|
|
543
|
-
logprobs:
|
|
610
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
544
611
|
finish_reason: z3.string().nullish()
|
|
545
612
|
})
|
|
546
613
|
),
|
|
547
|
-
usage:
|
|
614
|
+
usage: getTokenUsageSchema()
|
|
548
615
|
}),
|
|
549
|
-
|
|
616
|
+
getDeepSeekErrorSchema()
|
|
550
617
|
])
|
|
551
618
|
)
|
|
552
619
|
);
|
|
@@ -1160,7 +1227,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
1160
1227
|
};
|
|
1161
1228
|
|
|
1162
1229
|
// src/version.ts
|
|
1163
|
-
var VERSION = true ? "2.0.
|
|
1230
|
+
var VERSION = true ? "2.0.78" : "0.0.0-test";
|
|
1164
1231
|
|
|
1165
1232
|
// src/deepseek-provider.ts
|
|
1166
1233
|
function createDeepSeek(options = {}) {
|