@ai-sdk/deepseek 3.0.69 → 3.0.70

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ai-sdk/deepseek
2
2
 
3
+ ## 3.0.70
4
+
5
+ ### Patch Changes
6
+
7
+ - df6fe35: Defer DeepSeek validation schema creation until first use and cache shared schemas while preserving the internal Zod object exports.
8
+ - Updated dependencies [b089ce8]
9
+ - Updated dependencies [39a776b]
10
+ - @ai-sdk/provider-utils@5.0.65
11
+
3
12
  ## 3.0.69
4
13
 
5
14
  ### 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: z.ZodObject<{
43
- name: z.ZodOptional<z.ZodString>;
44
- }, z.core.$strip>;
45
- type DeepSeekMessageProviderOptions = z.infer<typeof deepseekMessageProviderOptions>;
46
- declare const deepseekAssistantMessageProviderOptions: z.ZodObject<{
47
- name: z.ZodOptional<z.ZodString>;
48
- prefix: z.ZodOptional<z.ZodLiteral<true>>;
49
- }, z.core.$strip>;
50
- type DeepSeekAssistantMessageProviderOptions = z.infer<typeof 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: z.ZodObject<{
102
- error: z.ZodObject<{
103
- message: z.ZodString;
104
- type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
- param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
106
- code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
107
- }, z.core.$strip>;
108
- }, z.core.$strip>;
109
- type DeepSeekErrorData = z.infer<typeof deepSeekErrorSchema>;
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: z.ZodObject<{
113
- imageDetail: z.ZodOptional<z.ZodEnum<{
114
- low: "low";
115
- high: "high";
116
- original: "original";
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<{
@@ -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":";;;;KAGY;KA+DA;;;;EAIV;;;;;;EAOA;;;;;;;;EASA;;;;EAKA;IACE;;;;;EAMF;;;;;;EAOA;;cAGW,gCAA8B,EAAA;;GAOzC,EAAA,KAAA;KAEU,iCAAiC,EAAE,aACtC;cAGI,yCAAuC,EAAA;;;GAQhD,EAAA,KAAA;KAEQ,0CAA0C,EAAE,aAC/C;;;UCnHQ;;;;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;;;cCkHA,qBAAmB,EAAA;;;;;;;GAO9B,EAAA,KAAA;KAEU,oBAAoB,EAAE,aAAa;;;cC3HlC,iCAA+B,EAAA;;;;;;;;GAiB1C,EAAA,KAAA;KAEU,kCAAkC,EAAE,aACvC;;;cCfI,6DAA0B;EAAA;;KAY3B,uBAAuB,mBAC1B"}
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
- const deepseekLanguageModelChatOptions = z.object({
30
- /**
31
- * Whether to return log probabilities for generated tokens.
32
- */
33
- logprobs: z.boolean().optional(),
34
- /**
35
- * Number of most likely tokens to return at each token position.
36
- *
37
- * Setting this option automatically enables `logprobs`.
38
- */
39
- topLogprobs: z.number().int().min(0).max(20).optional(),
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
- * An opaque identifier for the end user. DeepSeek uses this identifier for
42
- * content-safety tracing and request isolation.
83
+ * The name of the participant represented by the message.
43
84
  *
44
- * Must contain only ASCII letters, numbers, underscores, and hyphens, and
45
- * must be at most 512 characters long.
85
+ * Supported on system, user, and assistant messages.
46
86
  */
47
- 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(),
48
- /**
49
- * Type of thinking to use. Defaults to `enabled`.
50
- */
51
- thinking: z.object({ type: z.enum([
52
- "adaptive",
53
- "enabled",
54
- "disabled"
55
- ]).optional() }).optional(),
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 to use strict JSON schema validation for structured outputs.
68
- * Only applies when the serving endpoint supports JSON schema response
69
- * formats (e.g. Azure). Defaults to `true`.
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
- const tokenUsageSchema = z.looseObject({
410
- prompt_tokens: z.number().nullish(),
411
- completion_tokens: z.number().nullish(),
412
- prompt_cache_hit_tokens: z.number().nullish(),
413
- prompt_cache_miss_tokens: z.number().nullish(),
414
- total_tokens: z.number().nullish(),
415
- prompt_tokens_details: z.looseObject({ cached_tokens: z.number().nullish() }).nullish(),
416
- completion_tokens_details: z.looseObject({ reasoning_tokens: z.number().nullish() }).nullish()
417
- }).nullish();
418
- const deepSeekErrorSchema = z.object({ error: z.object({
419
- message: z.string(),
420
- type: z.string().nullish(),
421
- param: z.any().nullish(),
422
- code: z.union([z.string(), z.number()]).nullish()
423
- }) });
424
- const deepseekChatLogprobSchema = z.object({
425
- token: z.string(),
426
- logprob: z.number(),
427
- bytes: z.array(z.number()).nullable(),
428
- top_logprobs: z.array(z.object({
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
- const deepseekChatLogprobsSchema = z.object({
435
- content: z.array(deepseekChatLogprobSchema).nullish(),
436
- reasoning_content: z.array(deepseekChatLogprobSchema).nullish()
437
- }).nullish();
438
- const deepseekChatResponseSchema = z.object({
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: deepseekChatLogprobsSchema,
500
+ logprobs: getDeepseekChatLogprobsSchema(),
460
501
  finish_reason: z.string().nullish()
461
502
  })),
462
- usage: tokenUsageSchema
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: deepseekChatLogprobsSchema,
527
+ logprobs: getDeepseekChatLogprobsSchema(),
487
528
  finish_reason: z.string().nullish()
488
529
  })),
489
- usage: tokenUsageSchema
490
- }), deepSeekErrorSchema])));
530
+ usage: getTokenUsageSchema()
531
+ }), getDeepSeekErrorSchema()])));
491
532
  //#endregion
492
533
  //#region src/chat/deepseek-prepare-tools.ts
493
534
  function prepareTools({ tools, toolChoice, supportsStrictToolCalls }) {
@@ -1161,7 +1202,7 @@ function hasSupportedFilenameExtension(filename) {
1161
1202
  }
1162
1203
  //#endregion
1163
1204
  //#region src/version.ts
1164
- const VERSION = "3.0.69";
1205
+ const VERSION = "3.0.70";
1165
1206
  //#endregion
1166
1207
  //#region src/deepseek-provider.ts
1167
1208
  function createDeepSeek(options = {}) {