@ai-sdk/deepseek 3.0.0-beta.21 → 3.0.0-beta.22

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,17 @@
1
1
  # @ai-sdk/deepseek
2
2
 
3
+ ## 3.0.0-beta.22
4
+
5
+ ### Major Changes
6
+
7
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ef992f8]
12
+ - @ai-sdk/provider@4.0.0-beta.11
13
+ - @ai-sdk/provider-utils@5.0.0-beta.19
14
+
3
15
  ## 3.0.0-beta.21
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,38 +1,28 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- createDeepSeek: () => createDeepSeek,
25
- deepseek: () => deepseek
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
1
  // src/deepseek-provider.ts
30
- var import_provider2 = require("@ai-sdk/provider");
31
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ loadApiKey,
7
+ withoutTrailingSlash,
8
+ withUserAgentSuffix
9
+ } from "@ai-sdk/provider-utils";
32
10
 
33
11
  // src/chat/deepseek-chat-language-model.ts
34
- var import_provider = require("@ai-sdk/provider");
35
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
12
+ import {
13
+ InvalidResponseDataError
14
+ } from "@ai-sdk/provider";
15
+ import {
16
+ combineHeaders,
17
+ createEventSourceResponseHandler,
18
+ createJsonErrorResponseHandler,
19
+ createJsonResponseHandler,
20
+ generateId,
21
+ isCustomReasoning,
22
+ isParsableJson,
23
+ parseProviderOptions,
24
+ postJsonToApi
25
+ } from "@ai-sdk/provider-utils";
36
26
 
37
27
  // src/chat/convert-to-deepseek-chat-messages.ts
38
28
  function convertToDeepSeekChatMessages({
@@ -216,76 +206,76 @@ function convertDeepSeekUsage(usage) {
216
206
  }
217
207
 
218
208
  // src/chat/deepseek-chat-api-types.ts
219
- var import_provider_utils = require("@ai-sdk/provider-utils");
220
- var import_v4 = require("zod/v4");
221
- var tokenUsageSchema = import_v4.z.object({
222
- prompt_tokens: import_v4.z.number().nullish(),
223
- completion_tokens: import_v4.z.number().nullish(),
224
- prompt_cache_hit_tokens: import_v4.z.number().nullish(),
225
- prompt_cache_miss_tokens: import_v4.z.number().nullish(),
226
- total_tokens: import_v4.z.number().nullish(),
227
- completion_tokens_details: import_v4.z.object({
228
- reasoning_tokens: import_v4.z.number().nullish()
209
+ import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
210
+ import { z } from "zod/v4";
211
+ var tokenUsageSchema = z.object({
212
+ prompt_tokens: z.number().nullish(),
213
+ completion_tokens: z.number().nullish(),
214
+ prompt_cache_hit_tokens: z.number().nullish(),
215
+ prompt_cache_miss_tokens: z.number().nullish(),
216
+ total_tokens: z.number().nullish(),
217
+ completion_tokens_details: z.object({
218
+ reasoning_tokens: z.number().nullish()
229
219
  }).nullish()
230
220
  }).nullish();
231
- var deepSeekErrorSchema = import_v4.z.object({
232
- error: import_v4.z.object({
233
- message: import_v4.z.string(),
234
- type: import_v4.z.string().nullish(),
235
- param: import_v4.z.any().nullish(),
236
- code: import_v4.z.union([import_v4.z.string(), import_v4.z.number()]).nullish()
221
+ var deepSeekErrorSchema = z.object({
222
+ error: z.object({
223
+ message: z.string(),
224
+ type: z.string().nullish(),
225
+ param: z.any().nullish(),
226
+ code: z.union([z.string(), z.number()]).nullish()
237
227
  })
238
228
  });
239
- var deepseekChatResponseSchema = import_v4.z.object({
240
- id: import_v4.z.string().nullish(),
241
- created: import_v4.z.number().nullish(),
242
- model: import_v4.z.string().nullish(),
243
- choices: import_v4.z.array(
244
- import_v4.z.object({
245
- message: import_v4.z.object({
246
- role: import_v4.z.literal("assistant").nullish(),
247
- content: import_v4.z.string().nullish(),
248
- reasoning_content: import_v4.z.string().nullish(),
249
- tool_calls: import_v4.z.array(
250
- import_v4.z.object({
251
- id: import_v4.z.string().nullish(),
252
- function: import_v4.z.object({
253
- name: import_v4.z.string(),
254
- arguments: import_v4.z.string()
229
+ var deepseekChatResponseSchema = z.object({
230
+ id: z.string().nullish(),
231
+ created: z.number().nullish(),
232
+ model: z.string().nullish(),
233
+ choices: z.array(
234
+ z.object({
235
+ message: z.object({
236
+ role: z.literal("assistant").nullish(),
237
+ content: z.string().nullish(),
238
+ reasoning_content: z.string().nullish(),
239
+ tool_calls: z.array(
240
+ z.object({
241
+ id: z.string().nullish(),
242
+ function: z.object({
243
+ name: z.string(),
244
+ arguments: z.string()
255
245
  })
256
246
  })
257
247
  ).nullish()
258
248
  }),
259
- finish_reason: import_v4.z.string().nullish()
249
+ finish_reason: z.string().nullish()
260
250
  })
261
251
  ),
262
252
  usage: tokenUsageSchema
263
253
  });
264
- var deepseekChatChunkSchema = (0, import_provider_utils.lazySchema)(
265
- () => (0, import_provider_utils.zodSchema)(
266
- import_v4.z.union([
267
- import_v4.z.object({
268
- id: import_v4.z.string().nullish(),
269
- created: import_v4.z.number().nullish(),
270
- model: import_v4.z.string().nullish(),
271
- choices: import_v4.z.array(
272
- import_v4.z.object({
273
- delta: import_v4.z.object({
274
- role: import_v4.z.enum(["assistant"]).nullish(),
275
- content: import_v4.z.string().nullish(),
276
- reasoning_content: import_v4.z.string().nullish(),
277
- tool_calls: import_v4.z.array(
278
- import_v4.z.object({
279
- index: import_v4.z.number(),
280
- id: import_v4.z.string().nullish(),
281
- function: import_v4.z.object({
282
- name: import_v4.z.string().nullish(),
283
- arguments: import_v4.z.string().nullish()
254
+ var deepseekChatChunkSchema = lazySchema(
255
+ () => zodSchema(
256
+ z.union([
257
+ z.object({
258
+ id: z.string().nullish(),
259
+ created: z.number().nullish(),
260
+ model: z.string().nullish(),
261
+ choices: z.array(
262
+ z.object({
263
+ delta: z.object({
264
+ role: z.enum(["assistant"]).nullish(),
265
+ content: z.string().nullish(),
266
+ reasoning_content: z.string().nullish(),
267
+ tool_calls: z.array(
268
+ z.object({
269
+ index: z.number(),
270
+ id: z.string().nullish(),
271
+ function: z.object({
272
+ name: z.string().nullish(),
273
+ arguments: z.string().nullish()
284
274
  })
285
275
  })
286
276
  ).nullish()
287
277
  }).nullish(),
288
- finish_reason: import_v4.z.string().nullish()
278
+ finish_reason: z.string().nullish()
289
279
  })
290
280
  ),
291
281
  usage: tokenUsageSchema
@@ -296,13 +286,13 @@ var deepseekChatChunkSchema = (0, import_provider_utils.lazySchema)(
296
286
  );
297
287
 
298
288
  // src/chat/deepseek-chat-options.ts
299
- var import_v42 = require("zod/v4");
300
- var deepseekLanguageModelOptions = import_v42.z.object({
289
+ import { z as z2 } from "zod/v4";
290
+ var deepseekLanguageModelOptions = z2.object({
301
291
  /**
302
292
  * Type of thinking to use. Defaults to `enabled`.
303
293
  */
304
- thinking: import_v42.z.object({
305
- type: import_v42.z.enum(["enabled", "disabled"]).optional()
294
+ thinking: z2.object({
295
+ type: z2.enum(["enabled", "disabled"]).optional()
306
296
  }).optional()
307
297
  });
308
298
 
@@ -407,7 +397,7 @@ var DeepSeekChatLanguageModel = class {
407
397
  this.supportedUrls = {};
408
398
  this.modelId = modelId;
409
399
  this.config = config;
410
- this.failedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
400
+ this.failedResponseHandler = createJsonErrorResponseHandler({
411
401
  errorSchema: deepSeekErrorSchema,
412
402
  errorToMessage: (error) => error.error.message
413
403
  });
@@ -435,7 +425,7 @@ var DeepSeekChatLanguageModel = class {
435
425
  tools
436
426
  }) {
437
427
  var _a, _b;
438
- const deepseekOptions = (_a = await (0, import_provider_utils2.parseProviderOptions)({
428
+ const deepseekOptions = (_a = await parseProviderOptions({
439
429
  provider: this.providerOptionsName,
440
430
  providerOptions,
441
431
  schema: deepseekLanguageModelOptions
@@ -471,7 +461,7 @@ var DeepSeekChatLanguageModel = class {
471
461
  messages,
472
462
  tools: deepseekTools,
473
463
  tool_choice: deepseekToolChoices,
474
- thinking: ((_b = deepseekOptions.thinking) == null ? void 0 : _b.type) != null ? { type: deepseekOptions.thinking.type } : (0, import_provider_utils2.isCustomReasoning)(reasoning) ? { type: reasoning === "none" ? "disabled" : "enabled" } : void 0
464
+ thinking: ((_b = deepseekOptions.thinking) == null ? void 0 : _b.type) != null ? { type: deepseekOptions.thinking.type } : isCustomReasoning(reasoning) ? { type: reasoning === "none" ? "disabled" : "enabled" } : void 0
475
465
  },
476
466
  warnings: [...warnings, ...toolWarnings]
477
467
  };
@@ -483,15 +473,15 @@ var DeepSeekChatLanguageModel = class {
483
473
  responseHeaders,
484
474
  value: responseBody,
485
475
  rawValue: rawResponse
486
- } = await (0, import_provider_utils2.postJsonToApi)({
476
+ } = await postJsonToApi({
487
477
  url: this.config.url({
488
478
  path: "/chat/completions",
489
479
  modelId: this.modelId
490
480
  }),
491
- headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
481
+ headers: combineHeaders(this.config.headers(), options.headers),
492
482
  body: args,
493
483
  failedResponseHandler: this.failedResponseHandler,
494
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
484
+ successfulResponseHandler: createJsonResponseHandler(
495
485
  deepseekChatResponseSchema
496
486
  ),
497
487
  abortSignal: options.abortSignal,
@@ -510,7 +500,7 @@ var DeepSeekChatLanguageModel = class {
510
500
  for (const toolCall of choice.message.tool_calls) {
511
501
  content.push({
512
502
  type: "tool-call",
513
- toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils2.generateId)(),
503
+ toolCallId: (_a = toolCall.id) != null ? _a : generateId(),
514
504
  toolName: toolCall.function.name,
515
505
  input: toolCall.function.arguments
516
506
  });
@@ -549,15 +539,15 @@ var DeepSeekChatLanguageModel = class {
549
539
  stream: true,
550
540
  stream_options: { include_usage: true }
551
541
  };
552
- const { responseHeaders, value: response } = await (0, import_provider_utils2.postJsonToApi)({
542
+ const { responseHeaders, value: response } = await postJsonToApi({
553
543
  url: this.config.url({
554
544
  path: "/chat/completions",
555
545
  modelId: this.modelId
556
546
  }),
557
- headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
547
+ headers: combineHeaders(this.config.headers(), options.headers),
558
548
  body,
559
549
  failedResponseHandler: this.failedResponseHandler,
560
- successfulResponseHandler: (0, import_provider_utils2.createEventSourceResponseHandler)(
550
+ successfulResponseHandler: createEventSourceResponseHandler(
561
551
  deepseekChatChunkSchema
562
552
  ),
563
553
  abortSignal: options.abortSignal,
@@ -661,13 +651,13 @@ var DeepSeekChatLanguageModel = class {
661
651
  const index = toolCallDelta.index;
662
652
  if (toolCalls[index] == null) {
663
653
  if (toolCallDelta.id == null) {
664
- throw new import_provider.InvalidResponseDataError({
654
+ throw new InvalidResponseDataError({
665
655
  data: toolCallDelta,
666
656
  message: `Expected 'id' to be a string.`
667
657
  });
668
658
  }
669
659
  if (((_a = toolCallDelta.function) == null ? void 0 : _a.name) == null) {
670
- throw new import_provider.InvalidResponseDataError({
660
+ throw new InvalidResponseDataError({
671
661
  data: toolCallDelta,
672
662
  message: `Expected 'function.name' to be a string.`
673
663
  });
@@ -695,14 +685,14 @@ var DeepSeekChatLanguageModel = class {
695
685
  delta: toolCall2.function.arguments
696
686
  });
697
687
  }
698
- if ((0, import_provider_utils2.isParsableJson)(toolCall2.function.arguments)) {
688
+ if (isParsableJson(toolCall2.function.arguments)) {
699
689
  controller.enqueue({
700
690
  type: "tool-input-end",
701
691
  id: toolCall2.id
702
692
  });
703
693
  controller.enqueue({
704
694
  type: "tool-call",
705
- toolCallId: (_e = toolCall2.id) != null ? _e : (0, import_provider_utils2.generateId)(),
695
+ toolCallId: (_e = toolCall2.id) != null ? _e : generateId(),
706
696
  toolName: toolCall2.function.name,
707
697
  input: toolCall2.function.arguments
708
698
  });
@@ -723,14 +713,14 @@ var DeepSeekChatLanguageModel = class {
723
713
  id: toolCall.id,
724
714
  delta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
725
715
  });
726
- if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && (0, import_provider_utils2.isParsableJson)(toolCall.function.arguments)) {
716
+ if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && isParsableJson(toolCall.function.arguments)) {
727
717
  controller.enqueue({
728
718
  type: "tool-input-end",
729
719
  id: toolCall.id
730
720
  });
731
721
  controller.enqueue({
732
722
  type: "tool-call",
733
- toolCallId: (_l = toolCall.id) != null ? _l : (0, import_provider_utils2.generateId)(),
723
+ toolCallId: (_l = toolCall.id) != null ? _l : generateId(),
734
724
  toolName: toolCall.function.name,
735
725
  input: toolCall.function.arguments
736
726
  });
@@ -756,7 +746,7 @@ var DeepSeekChatLanguageModel = class {
756
746
  });
757
747
  controller.enqueue({
758
748
  type: "tool-call",
759
- toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils2.generateId)(),
749
+ toolCallId: (_a = toolCall.id) != null ? _a : generateId(),
760
750
  toolName: toolCall.function.name,
761
751
  input: toolCall.function.arguments
762
752
  });
@@ -782,17 +772,17 @@ var DeepSeekChatLanguageModel = class {
782
772
  };
783
773
 
784
774
  // src/version.ts
785
- var VERSION = true ? "3.0.0-beta.21" : "0.0.0-test";
775
+ var VERSION = true ? "3.0.0-beta.22" : "0.0.0-test";
786
776
 
787
777
  // src/deepseek-provider.ts
788
778
  function createDeepSeek(options = {}) {
789
779
  var _a;
790
- const baseURL = (0, import_provider_utils3.withoutTrailingSlash)(
780
+ const baseURL = withoutTrailingSlash(
791
781
  (_a = options.baseURL) != null ? _a : "https://api.deepseek.com"
792
782
  );
793
- const getHeaders = () => (0, import_provider_utils3.withUserAgentSuffix)(
783
+ const getHeaders = () => withUserAgentSuffix(
794
784
  {
795
- Authorization: `Bearer ${(0, import_provider_utils3.loadApiKey)({
785
+ Authorization: `Bearer ${loadApiKey({
796
786
  apiKey: options.apiKey,
797
787
  environmentVariableName: "DEEPSEEK_API_KEY",
798
788
  description: "DeepSeek API key"
@@ -814,19 +804,18 @@ function createDeepSeek(options = {}) {
814
804
  provider.languageModel = createLanguageModel;
815
805
  provider.chat = createLanguageModel;
816
806
  provider.embeddingModel = (modelId) => {
817
- throw new import_provider2.NoSuchModelError({ modelId, modelType: "embeddingModel" });
807
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
818
808
  };
819
809
  provider.textEmbeddingModel = provider.embeddingModel;
820
810
  provider.imageModel = (modelId) => {
821
- throw new import_provider2.NoSuchModelError({ modelId, modelType: "imageModel" });
811
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
822
812
  };
823
813
  return provider;
824
814
  }
825
815
  var deepseek = createDeepSeek();
826
- // Annotate the CommonJS export names for ESM import in node:
827
- 0 && (module.exports = {
816
+ export {
828
817
  VERSION,
829
818
  createDeepSeek,
830
819
  deepseek
831
- });
820
+ };
832
821
  //# sourceMappingURL=index.js.map