@ai-sdk/deepseek 3.0.69 → 3.0.71
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 +25 -0
- package/dist/index.d.ts +23 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -89
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +43 -33
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +145 -100
- package/dist/internal/index.js.map +1 -1
- package/docs/30-deepseek.mdx +49 -5
- package/package.json +3 -3
- package/src/chat/deepseek-chat-api-types.ts +128 -84
- package/src/chat/deepseek-chat-language-model-options.ts +109 -60
- package/src/chat/deepseek-chat-language-model.ts +2 -1
- package/src/chat/deepseek-file-part-options.ts +27 -18
- package/src/internal/index.ts +18 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @ai-sdk/deepseek
|
|
2
2
|
|
|
3
|
+
## 3.0.71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 43ad966: Report `interrupted` when a stream ends cleanly without its provider completion signal, preserving partial output without emitting an error solely for the interruption.
|
|
8
|
+
|
|
9
|
+
This applies to OpenAI (Chat, Responses, and Completions), Anthropic, Google (Generate Content and Interactions), Alibaba, Amazon Bedrock Converse, Cohere, DeepSeek, Groq, Hugging Face Responses, Mistral Chat, Moonshot AI, Open Responses, Perplexity, and xAI Responses. It also covers cutoffs in later Anthropic messages and Google automatic continuations.
|
|
10
|
+
|
|
11
|
+
**Compatibility notice:** These streams previously fell back to `other` or omitted the finish part. Applications must now handle `interrupted` in finish-reason switches, mappings, and custom validation. Check `finishReason === 'interrupted'` to detect incomplete responses; interruption alone does not trigger error handling.
|
|
12
|
+
|
|
13
|
+
Explicit unknown completion reasons still map to `other`. Actual provider, parsing, and transport errors retain their error paths; affected error paths that previously left the finish reason as `other` now report `error`. OpenAI-compatible remains unchanged.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [10026d1]
|
|
16
|
+
- @ai-sdk/provider@4.0.32
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.66
|
|
18
|
+
|
|
19
|
+
## 3.0.70
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- df6fe35: Defer DeepSeek validation schema creation until first use and cache shared schemas while preserving the internal Zod object exports.
|
|
24
|
+
- Updated dependencies [b089ce8]
|
|
25
|
+
- Updated dependencies [39a776b]
|
|
26
|
+
- @ai-sdk/provider-utils@5.0.65
|
|
27
|
+
|
|
3
28
|
## 3.0.69
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -39,15 +39,15 @@ type DeepSeekLanguageModelChatOptions = {
|
|
|
39
39
|
*/
|
|
40
40
|
strictJsonSchema?: boolean;
|
|
41
41
|
};
|
|
42
|
-
declare const deepseekMessageProviderOptions:
|
|
43
|
-
name
|
|
44
|
-
}
|
|
45
|
-
type DeepSeekMessageProviderOptions =
|
|
46
|
-
declare const deepseekAssistantMessageProviderOptions:
|
|
47
|
-
name
|
|
48
|
-
prefix
|
|
49
|
-
}
|
|
50
|
-
type DeepSeekAssistantMessageProviderOptions =
|
|
42
|
+
declare const deepseekMessageProviderOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
43
|
+
name?: string | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
type DeepSeekMessageProviderOptions = InferSchema<typeof deepseekMessageProviderOptions>;
|
|
46
|
+
declare const deepseekAssistantMessageProviderOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
prefix?: true | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
type DeepSeekAssistantMessageProviderOptions = InferSchema<typeof deepseekAssistantMessageProviderOptions>;
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/deepseek-provider.d.ts
|
|
53
53
|
interface DeepSeekProviderSettings {
|
|
@@ -98,27 +98,22 @@ export declare const deepSeek: DeepSeekProvider;
|
|
|
98
98
|
export declare const VERSION: string;
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/chat/deepseek-chat-api-types.d.ts
|
|
101
|
-
declare const deepSeekErrorSchema:
|
|
102
|
-
error:
|
|
103
|
-
message:
|
|
104
|
-
type
|
|
105
|
-
param
|
|
106
|
-
code
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
type DeepSeekErrorData =
|
|
101
|
+
declare const deepSeekErrorSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
102
|
+
error: {
|
|
103
|
+
message: string;
|
|
104
|
+
type?: string | null | undefined;
|
|
105
|
+
param?: any;
|
|
106
|
+
code?: string | number | null | undefined;
|
|
107
|
+
};
|
|
108
|
+
}>;
|
|
109
|
+
type DeepSeekErrorData = InferSchema<typeof deepSeekErrorSchema>;
|
|
110
110
|
//#endregion
|
|
111
111
|
//#region src/chat/deepseek-file-part-options.d.ts
|
|
112
|
-
declare const deepseekFilePartProviderOptions:
|
|
113
|
-
imageDetail
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
auto: "auto";
|
|
118
|
-
}>>;
|
|
119
|
-
fileData: z.ZodOptional<z.ZodLiteral<true>>;
|
|
120
|
-
}, z.core.$strip>;
|
|
121
|
-
type DeepSeekFilePartProviderOptions = z.infer<typeof deepseekFilePartProviderOptions>;
|
|
112
|
+
declare const deepseekFilePartProviderOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
113
|
+
imageDetail?: "low" | "high" | "original" | "auto" | undefined;
|
|
114
|
+
fileData?: true | undefined;
|
|
115
|
+
}>;
|
|
116
|
+
type DeepSeekFilePartProviderOptions = InferSchema<typeof deepseekFilePartProviderOptions>;
|
|
122
117
|
//#endregion
|
|
123
118
|
//#region src/files/deepseek-files-options.d.ts
|
|
124
119
|
declare const deepSeekFilesOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/chat/deepseek-chat-language-model-options.ts","../src/deepseek-provider.ts","../src/version.ts","../src/chat/deepseek-chat-api-types.ts","../src/chat/deepseek-file-part-options.ts","../src/files/deepseek-files-options.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/chat/deepseek-chat-language-model-options.ts","../src/deepseek-provider.ts","../src/version.ts","../src/chat/deepseek-chat-api-types.ts","../src/chat/deepseek-file-part-options.ts","../src/files/deepseek-files-options.ts"],"mappings":";;;;KAQY;KA+EA;;;;EAIV;;;;;;EAOA;;;;;;;;EASA;;;;EAKA;IACE;;;;;EAMF;;;;;;EAOA;;cAsBW,iEAA8B;EAAA;;KAI/B,iCAAiC,mBACpC;cAuBI,0EAAuC;;;;KAIxC,0CAA0C,mBAC7C;;;UCpKQ;;;;EAIf;;;;EAKA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;UAGO,yBAAyB;;;;GAIvC,SAAS,sBAAsB;;;;EAKhC,cAAc,SAAS,sBAAsB;;;;EAK7C,KAAK,SAAS,sBAAsB;;;;EAKpC,SAAS;;;;EAKT,mBAAmB;;wBAGL,eACd,UAAS,2BACR;qBAwDU,UAAQ;;;qBC3HR;;;cCiJA,sDAAmB;;;;;;;;KAIpB,oBAAoB,mBAAmB;;;cChJtC,kEAA+B;;;;KAuBhC,kCAAkC,mBACrC;;;cCxBI,6DAA0B;EAAA;;KAY3B,uBAAuB,mBAC1B"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, NoS
|
|
|
2
2
|
import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertInlineFileDataToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderStreamError, detectMediaType, generateId, getTopLevelMediaType, isCustomReasoning, lazySchema, loadApiKey, mapReasoningToProviderEffort, parseProviderOptions, postFormDataToApi, postJsonToApi, resolveFullMediaType, resolveProviderReference, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/chat/deepseek-file-part-options.ts
|
|
5
|
-
const deepseekFilePartProviderOptions = z.object({
|
|
5
|
+
const deepseekFilePartProviderOptions = lazySchema(() => zodSchema(z.object({
|
|
6
6
|
/**
|
|
7
7
|
* Controls how DeepSeek processes an image sent as an `image_url` part.
|
|
8
8
|
*
|
|
@@ -23,66 +23,88 @@ const deepseekFilePartProviderOptions = z.object({
|
|
|
23
23
|
* with `imageDetail`.
|
|
24
24
|
*/
|
|
25
25
|
fileData: z.literal(true).optional()
|
|
26
|
-
});
|
|
26
|
+
})));
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/chat/deepseek-chat-language-model-options.ts
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
function createDeepseekChatOptionsSchema() {
|
|
30
|
+
return z.object({
|
|
31
|
+
/**
|
|
32
|
+
* Whether to return log probabilities for generated tokens.
|
|
33
|
+
*/
|
|
34
|
+
logprobs: z.boolean().optional(),
|
|
35
|
+
/**
|
|
36
|
+
* Number of most likely tokens to return at each token position.
|
|
37
|
+
*
|
|
38
|
+
* Setting this option automatically enables `logprobs`.
|
|
39
|
+
*/
|
|
40
|
+
topLogprobs: z.number().int().min(0).max(20).optional(),
|
|
41
|
+
/**
|
|
42
|
+
* An opaque identifier for the end user. DeepSeek uses this identifier for
|
|
43
|
+
* content-safety tracing and request isolation.
|
|
44
|
+
*
|
|
45
|
+
* Must contain only ASCII letters, numbers, underscores, and hyphens, and
|
|
46
|
+
* must be at most 512 characters long.
|
|
47
|
+
*/
|
|
48
|
+
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(),
|
|
49
|
+
/**
|
|
50
|
+
* Type of thinking to use. Defaults to `enabled`.
|
|
51
|
+
*/
|
|
52
|
+
thinking: z.object({ type: z.enum([
|
|
53
|
+
"adaptive",
|
|
54
|
+
"enabled",
|
|
55
|
+
"disabled"
|
|
56
|
+
]).optional() }).optional(),
|
|
57
|
+
/**
|
|
58
|
+
* Controls the thinking strength for DeepSeek V4 reasoning models.
|
|
59
|
+
*/
|
|
60
|
+
reasoningEffort: z.enum([
|
|
61
|
+
"low",
|
|
62
|
+
"medium",
|
|
63
|
+
"high",
|
|
64
|
+
"xhigh",
|
|
65
|
+
"max"
|
|
66
|
+
]).optional(),
|
|
67
|
+
/**
|
|
68
|
+
* Whether to use strict JSON schema validation for structured outputs.
|
|
69
|
+
* Only applies when the serving endpoint supports JSON schema response
|
|
70
|
+
* formats (e.g. Azure). Defaults to `true`.
|
|
71
|
+
*/
|
|
72
|
+
strictJsonSchema: z.boolean().optional()
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
let chatOptionsSchema;
|
|
76
|
+
function getDeepseekChatOptionsSchema() {
|
|
77
|
+
return chatOptionsSchema ??= createDeepseekChatOptionsSchema();
|
|
78
|
+
}
|
|
79
|
+
const deepseekLanguageModelChatOptions = lazySchema(() => zodSchema(getDeepseekChatOptionsSchema()));
|
|
80
|
+
function createDeepseekMessageOptionsSchema() {
|
|
81
|
+
return z.object({
|
|
40
82
|
/**
|
|
41
|
-
*
|
|
42
|
-
* content-safety tracing and request isolation.
|
|
83
|
+
* The name of the participant represented by the message.
|
|
43
84
|
*
|
|
44
|
-
*
|
|
45
|
-
* must be at most 512 characters long.
|
|
85
|
+
* Supported on system, user, and assistant messages.
|
|
46
86
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Controls the thinking strength for DeepSeek V4 reasoning models.
|
|
58
|
-
*/
|
|
59
|
-
reasoningEffort: z.enum([
|
|
60
|
-
"low",
|
|
61
|
-
"medium",
|
|
62
|
-
"high",
|
|
63
|
-
"xhigh",
|
|
64
|
-
"max"
|
|
65
|
-
]).optional(),
|
|
87
|
+
name: z.string().optional() });
|
|
88
|
+
}
|
|
89
|
+
let messageOptionsSchema;
|
|
90
|
+
function getDeepseekMessageOptionsSchema() {
|
|
91
|
+
return messageOptionsSchema ??= createDeepseekMessageOptionsSchema();
|
|
92
|
+
}
|
|
93
|
+
lazySchema(() => zodSchema(getDeepseekMessageOptionsSchema()));
|
|
94
|
+
function createDeepseekAssistantMessageOptionsSchema() {
|
|
95
|
+
return getDeepseekMessageOptionsSchema().extend({
|
|
66
96
|
/**
|
|
67
|
-
* Whether
|
|
68
|
-
*
|
|
69
|
-
*
|
|
97
|
+
* Whether the assistant message content is a prefix that DeepSeek should
|
|
98
|
+
* continue. This beta feature is only supported on the final assistant
|
|
99
|
+
* message when using a beta base URL.
|
|
70
100
|
*/
|
|
71
|
-
strictJsonSchema: z.boolean().optional()
|
|
72
|
-
});
|
|
73
|
-
const deepseekAssistantMessageProviderOptions = z.object({
|
|
74
|
-
/**
|
|
75
|
-
* The name of the participant represented by the message.
|
|
76
|
-
*
|
|
77
|
-
* Supported on system, user, and assistant messages.
|
|
78
|
-
*/
|
|
79
|
-
name: z.string().optional() }).extend({
|
|
80
|
-
/**
|
|
81
|
-
* Whether the assistant message content is a prefix that DeepSeek should
|
|
82
|
-
* continue. This beta feature is only supported on the final assistant
|
|
83
|
-
* message when using a beta base URL.
|
|
84
|
-
*/
|
|
85
101
|
prefix: z.literal(true).optional() });
|
|
102
|
+
}
|
|
103
|
+
let assistantMessageOptionsSchema;
|
|
104
|
+
function getDeepseekAssistantMessageOptionsSchema() {
|
|
105
|
+
return assistantMessageOptionsSchema ??= createDeepseekAssistantMessageOptionsSchema();
|
|
106
|
+
}
|
|
107
|
+
const deepseekAssistantMessageProviderOptions = lazySchema(() => zodSchema(getDeepseekAssistantMessageOptionsSchema()));
|
|
86
108
|
//#endregion
|
|
87
109
|
//#region src/chat/is-deepseek-v4-model.ts
|
|
88
110
|
/**
|
|
@@ -406,36 +428,55 @@ function convertDeepSeekUsage(usage) {
|
|
|
406
428
|
}
|
|
407
429
|
//#endregion
|
|
408
430
|
//#region src/chat/deepseek-chat-api-types.ts
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}).nullish()
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
431
|
+
function createTokenUsageSchema() {
|
|
432
|
+
return z.looseObject({
|
|
433
|
+
prompt_tokens: z.number().nullish(),
|
|
434
|
+
completion_tokens: z.number().nullish(),
|
|
435
|
+
prompt_cache_hit_tokens: z.number().nullish(),
|
|
436
|
+
prompt_cache_miss_tokens: z.number().nullish(),
|
|
437
|
+
total_tokens: z.number().nullish(),
|
|
438
|
+
prompt_tokens_details: z.looseObject({ cached_tokens: z.number().nullish() }).nullish(),
|
|
439
|
+
completion_tokens_details: z.looseObject({ reasoning_tokens: z.number().nullish() }).nullish()
|
|
440
|
+
}).nullish();
|
|
441
|
+
}
|
|
442
|
+
let tokenUsageSchema;
|
|
443
|
+
function getTokenUsageSchema() {
|
|
444
|
+
return tokenUsageSchema ??= createTokenUsageSchema();
|
|
445
|
+
}
|
|
446
|
+
function createDeepSeekErrorSchema() {
|
|
447
|
+
return z.object({ error: z.object({
|
|
448
|
+
message: z.string(),
|
|
449
|
+
type: z.string().nullish(),
|
|
450
|
+
param: z.any().nullish(),
|
|
451
|
+
code: z.union([z.string(), z.number()]).nullish()
|
|
452
|
+
}) });
|
|
453
|
+
}
|
|
454
|
+
let errorSchema;
|
|
455
|
+
function getDeepSeekErrorSchema() {
|
|
456
|
+
return errorSchema ??= createDeepSeekErrorSchema();
|
|
457
|
+
}
|
|
458
|
+
const deepSeekErrorSchema = lazySchema(() => zodSchema(getDeepSeekErrorSchema()));
|
|
459
|
+
function createDeepseekChatLogprobsSchema() {
|
|
460
|
+
const deepseekChatLogprobSchema = z.object({
|
|
429
461
|
token: z.string(),
|
|
430
462
|
logprob: z.number(),
|
|
431
|
-
bytes: z.array(z.number()).nullable()
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
})
|
|
438
|
-
|
|
463
|
+
bytes: z.array(z.number()).nullable(),
|
|
464
|
+
top_logprobs: z.array(z.object({
|
|
465
|
+
token: z.string(),
|
|
466
|
+
logprob: z.number(),
|
|
467
|
+
bytes: z.array(z.number()).nullable()
|
|
468
|
+
}))
|
|
469
|
+
});
|
|
470
|
+
return z.object({
|
|
471
|
+
content: z.array(deepseekChatLogprobSchema).nullish(),
|
|
472
|
+
reasoning_content: z.array(deepseekChatLogprobSchema).nullish()
|
|
473
|
+
}).nullish();
|
|
474
|
+
}
|
|
475
|
+
let logprobsSchema;
|
|
476
|
+
function getDeepseekChatLogprobsSchema() {
|
|
477
|
+
return logprobsSchema ??= createDeepseekChatLogprobsSchema();
|
|
478
|
+
}
|
|
479
|
+
const deepseekChatResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
439
480
|
id: z.string().nullish(),
|
|
440
481
|
created: z.number().nullish(),
|
|
441
482
|
model: z.string().nullish(),
|
|
@@ -456,11 +497,11 @@ const deepseekChatResponseSchema = z.object({
|
|
|
456
497
|
})
|
|
457
498
|
})).nullish()
|
|
458
499
|
}),
|
|
459
|
-
logprobs:
|
|
500
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
460
501
|
finish_reason: z.string().nullish()
|
|
461
502
|
})),
|
|
462
|
-
usage:
|
|
463
|
-
});
|
|
503
|
+
usage: getTokenUsageSchema()
|
|
504
|
+
})));
|
|
464
505
|
const deepseekChatChunkSchema = lazySchema(() => zodSchema(z.union([z.object({
|
|
465
506
|
id: z.string().nullish(),
|
|
466
507
|
created: z.number().nullish(),
|
|
@@ -483,11 +524,11 @@ const deepseekChatChunkSchema = lazySchema(() => zodSchema(z.union([z.object({
|
|
|
483
524
|
})
|
|
484
525
|
})).nullish()
|
|
485
526
|
}).nullish(),
|
|
486
|
-
logprobs:
|
|
527
|
+
logprobs: getDeepseekChatLogprobsSchema(),
|
|
487
528
|
finish_reason: z.string().nullish()
|
|
488
529
|
})),
|
|
489
|
-
usage:
|
|
490
|
-
}),
|
|
530
|
+
usage: getTokenUsageSchema()
|
|
531
|
+
}), getDeepSeekErrorSchema()])));
|
|
491
532
|
//#endregion
|
|
492
533
|
//#region src/chat/deepseek-prepare-tools.ts
|
|
493
534
|
function prepareTools({ tools, toolChoice, supportsStrictToolCalls }) {
|
|
@@ -861,7 +902,7 @@ var DeepSeekChatLanguageModel = class DeepSeekChatLanguageModel {
|
|
|
861
902
|
});
|
|
862
903
|
let toolCallTracker;
|
|
863
904
|
let finishReason = {
|
|
864
|
-
unified: "
|
|
905
|
+
unified: "interrupted",
|
|
865
906
|
raw: void 0
|
|
866
907
|
};
|
|
867
908
|
let usage = void 0;
|
|
@@ -1161,7 +1202,7 @@ function hasSupportedFilenameExtension(filename) {
|
|
|
1161
1202
|
}
|
|
1162
1203
|
//#endregion
|
|
1163
1204
|
//#region src/version.ts
|
|
1164
|
-
const VERSION = "3.0.
|
|
1205
|
+
const VERSION = "3.0.71";
|
|
1165
1206
|
//#endregion
|
|
1166
1207
|
//#region src/deepseek-provider.ts
|
|
1167
1208
|
function createDeepSeek(options = {}) {
|