@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.
@@ -1,8 +1,89 @@
1
- import { InvalidPromptError, InvalidResponseDataError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
2
1
  import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderStreamError, generateId, getTopLevelMediaType, isCustomReasoning, lazySchema, mapReasoningToProviderEffort, parseProviderOptions, postJsonToApi, resolveFullMediaType, resolveProviderReference, serializeModelOptions, zodSchema } from "@ai-sdk/provider-utils";
3
2
  import { z } from "zod/v4";
3
+ import { InvalidPromptError, InvalidResponseDataError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
4
+ //#region src/chat/deepseek-chat-language-model-options.ts
5
+ function createDeepseekChatOptionsSchema() {
6
+ return z.object({
7
+ /**
8
+ * Whether to return log probabilities for generated tokens.
9
+ */
10
+ logprobs: z.boolean().optional(),
11
+ /**
12
+ * Number of most likely tokens to return at each token position.
13
+ *
14
+ * Setting this option automatically enables `logprobs`.
15
+ */
16
+ topLogprobs: z.number().int().min(0).max(20).optional(),
17
+ /**
18
+ * An opaque identifier for the end user. DeepSeek uses this identifier for
19
+ * content-safety tracing and request isolation.
20
+ *
21
+ * Must contain only ASCII letters, numbers, underscores, and hyphens, and
22
+ * must be at most 512 characters long.
23
+ */
24
+ 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(),
25
+ /**
26
+ * Type of thinking to use. Defaults to `enabled`.
27
+ */
28
+ thinking: z.object({ type: z.enum([
29
+ "adaptive",
30
+ "enabled",
31
+ "disabled"
32
+ ]).optional() }).optional(),
33
+ /**
34
+ * Controls the thinking strength for DeepSeek V4 reasoning models.
35
+ */
36
+ reasoningEffort: z.enum([
37
+ "low",
38
+ "medium",
39
+ "high",
40
+ "xhigh",
41
+ "max"
42
+ ]).optional(),
43
+ /**
44
+ * Whether to use strict JSON schema validation for structured outputs.
45
+ * Only applies when the serving endpoint supports JSON schema response
46
+ * formats (e.g. Azure). Defaults to `true`.
47
+ */
48
+ strictJsonSchema: z.boolean().optional()
49
+ });
50
+ }
51
+ let chatOptionsSchema;
52
+ function getDeepseekChatOptionsSchema() {
53
+ return chatOptionsSchema ??= createDeepseekChatOptionsSchema();
54
+ }
55
+ const deepseekLanguageModelChatOptions$1 = lazySchema(() => zodSchema(getDeepseekChatOptionsSchema()));
56
+ function createDeepseekMessageOptionsSchema() {
57
+ return z.object({
58
+ /**
59
+ * The name of the participant represented by the message.
60
+ *
61
+ * Supported on system, user, and assistant messages.
62
+ */
63
+ name: z.string().optional() });
64
+ }
65
+ let messageOptionsSchema;
66
+ function getDeepseekMessageOptionsSchema() {
67
+ return messageOptionsSchema ??= createDeepseekMessageOptionsSchema();
68
+ }
69
+ lazySchema(() => zodSchema(getDeepseekMessageOptionsSchema()));
70
+ function createDeepseekAssistantMessageOptionsSchema() {
71
+ return getDeepseekMessageOptionsSchema().extend({
72
+ /**
73
+ * Whether the assistant message content is a prefix that DeepSeek should
74
+ * continue. This beta feature is only supported on the final assistant
75
+ * message when using a beta base URL.
76
+ */
77
+ prefix: z.literal(true).optional() });
78
+ }
79
+ let assistantMessageOptionsSchema;
80
+ function getDeepseekAssistantMessageOptionsSchema() {
81
+ return assistantMessageOptionsSchema ??= createDeepseekAssistantMessageOptionsSchema();
82
+ }
83
+ const deepseekAssistantMessageProviderOptions$1 = lazySchema(() => zodSchema(getDeepseekAssistantMessageOptionsSchema()));
84
+ //#endregion
4
85
  //#region src/chat/deepseek-file-part-options.ts
5
- const deepseekFilePartProviderOptions = z.object({
86
+ const deepseekFilePartProviderOptions = lazySchema(() => zodSchema(z.object({
6
87
  /**
7
88
  * Controls how DeepSeek processes an image sent as an `image_url` part.
8
89
  *
@@ -23,67 +104,7 @@ const deepseekFilePartProviderOptions = z.object({
23
104
  * with `imageDetail`.
24
105
  */
25
106
  fileData: z.literal(true).optional()
26
- });
27
- //#endregion
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(),
40
- /**
41
- * An opaque identifier for the end user. DeepSeek uses this identifier for
42
- * content-safety tracing and request isolation.
43
- *
44
- * Must contain only ASCII letters, numbers, underscores, and hyphens, and
45
- * must be at most 512 characters long.
46
- */
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(),
66
- /**
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`.
70
- */
71
- strictJsonSchema: z.boolean().optional()
72
- });
73
- const deepseekMessageProviderOptions = 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() });
80
- const deepseekAssistantMessageProviderOptions = deepseekMessageProviderOptions.extend({
81
- /**
82
- * Whether the assistant message content is a prefix that DeepSeek should
83
- * continue. This beta feature is only supported on the final assistant
84
- * message when using a beta base URL.
85
- */
86
- prefix: z.literal(true).optional() });
107
+ })));
87
108
  //#endregion
88
109
  //#region src/chat/is-deepseek-v4-model.ts
89
110
  /**
@@ -153,7 +174,7 @@ async function convertToDeepSeekChatMessages({ prompt, responseFormat, modelId,
153
174
  const deepseekMessageOptions = await parseProviderOptions({
154
175
  provider: providerOptionsName,
155
176
  providerOptions,
156
- schema: deepseekAssistantMessageProviderOptions
177
+ schema: deepseekAssistantMessageProviderOptions$1
157
178
  });
158
179
  if (deepseekMessageOptions?.prefix === true && role !== "assistant") throw new InvalidPromptError({
159
180
  prompt,
@@ -407,36 +428,55 @@ function convertDeepSeekUsage(usage) {
407
428
  }
408
429
  //#endregion
409
430
  //#region src/chat/deepseek-chat-api-types.ts
410
- const tokenUsageSchema = z.looseObject({
411
- prompt_tokens: z.number().nullish(),
412
- completion_tokens: z.number().nullish(),
413
- prompt_cache_hit_tokens: z.number().nullish(),
414
- prompt_cache_miss_tokens: z.number().nullish(),
415
- total_tokens: z.number().nullish(),
416
- prompt_tokens_details: z.looseObject({ cached_tokens: z.number().nullish() }).nullish(),
417
- completion_tokens_details: z.looseObject({ reasoning_tokens: z.number().nullish() }).nullish()
418
- }).nullish();
419
- const deepSeekErrorSchema = z.object({ error: z.object({
420
- message: z.string(),
421
- type: z.string().nullish(),
422
- param: z.any().nullish(),
423
- code: z.union([z.string(), z.number()]).nullish()
424
- }) });
425
- const deepseekChatLogprobSchema = z.object({
426
- token: z.string(),
427
- logprob: z.number(),
428
- bytes: z.array(z.number()).nullable(),
429
- 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({
430
461
  token: z.string(),
431
462
  logprob: z.number(),
432
- bytes: z.array(z.number()).nullable()
433
- }))
434
- });
435
- const deepseekChatLogprobsSchema = z.object({
436
- content: z.array(deepseekChatLogprobSchema).nullish(),
437
- reasoning_content: z.array(deepseekChatLogprobSchema).nullish()
438
- }).nullish();
439
- 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({
440
480
  id: z.string().nullish(),
441
481
  created: z.number().nullish(),
442
482
  model: z.string().nullish(),
@@ -457,11 +497,11 @@ const deepseekChatResponseSchema = z.object({
457
497
  })
458
498
  })).nullish()
459
499
  }),
460
- logprobs: deepseekChatLogprobsSchema,
500
+ logprobs: getDeepseekChatLogprobsSchema(),
461
501
  finish_reason: z.string().nullish()
462
502
  })),
463
- usage: tokenUsageSchema
464
- });
503
+ usage: getTokenUsageSchema()
504
+ })));
465
505
  const deepseekChatChunkSchema = lazySchema(() => zodSchema(z.union([z.object({
466
506
  id: z.string().nullish(),
467
507
  created: z.number().nullish(),
@@ -484,11 +524,11 @@ const deepseekChatChunkSchema = lazySchema(() => zodSchema(z.union([z.object({
484
524
  })
485
525
  })).nullish()
486
526
  }).nullish(),
487
- logprobs: deepseekChatLogprobsSchema,
527
+ logprobs: getDeepseekChatLogprobsSchema(),
488
528
  finish_reason: z.string().nullish()
489
529
  })),
490
- usage: tokenUsageSchema
491
- }), deepSeekErrorSchema])));
530
+ usage: getTokenUsageSchema()
531
+ }), getDeepSeekErrorSchema()])));
492
532
  //#endregion
493
533
  //#region src/chat/deepseek-prepare-tools.ts
494
534
  function prepareTools({ tools, toolChoice, supportsStrictToolCalls }) {
@@ -680,7 +720,7 @@ var DeepSeekChatLanguageModel = class DeepSeekChatLanguageModel {
680
720
  const deepseekOptions = await parseProviderOptions({
681
721
  provider: this.providerOptionsName,
682
722
  providerOptions,
683
- schema: deepseekLanguageModelChatOptions
723
+ schema: deepseekLanguageModelChatOptions$1
684
724
  }) ?? {};
685
725
  const supportsStructuredOutputs = this.config.supportsStructuredOutputs === true;
686
726
  const supportsPenaltySampling = this.config.supportsPenaltySampling === true;
@@ -862,7 +902,7 @@ var DeepSeekChatLanguageModel = class DeepSeekChatLanguageModel {
862
902
  });
863
903
  let toolCallTracker;
864
904
  let finishReason = {
865
- unified: "other",
905
+ unified: "interrupted",
866
906
  raw: void 0
867
907
  };
868
908
  let usage = void 0;
@@ -1021,6 +1061,11 @@ var DeepSeekChatLanguageModel = class DeepSeekChatLanguageModel {
1021
1061
  }
1022
1062
  };
1023
1063
  //#endregion
1064
+ //#region src/internal/index.ts
1065
+ const deepseekLanguageModelChatOptions = getDeepseekChatOptionsSchema();
1066
+ const deepseekMessageProviderOptions = getDeepseekMessageOptionsSchema();
1067
+ const deepseekAssistantMessageProviderOptions = getDeepseekAssistantMessageOptionsSchema();
1068
+ //#endregion
1024
1069
  export { DeepSeekChatLanguageModel, deepseekAssistantMessageProviderOptions, deepseekLanguageModelChatOptions, deepseekMessageProviderOptions };
1025
1070
 
1026
1071
  //# sourceMappingURL=index.js.map