@ai-sdk/deepseek 3.0.0-beta.3 → 3.0.0-beta.31

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/dist/index.mjs DELETED
@@ -1,819 +0,0 @@
1
- // src/deepseek-provider.ts
2
- import {
3
- NoSuchModelError
4
- } from "@ai-sdk/provider";
5
- import {
6
- loadApiKey,
7
- withoutTrailingSlash,
8
- withUserAgentSuffix
9
- } from "@ai-sdk/provider-utils";
10
-
11
- // src/chat/deepseek-chat-language-model.ts
12
- import {
13
- InvalidResponseDataError
14
- } from "@ai-sdk/provider";
15
- import {
16
- combineHeaders,
17
- createEventSourceResponseHandler,
18
- createJsonErrorResponseHandler,
19
- createJsonResponseHandler,
20
- generateId,
21
- isParsableJson,
22
- parseProviderOptions,
23
- postJsonToApi
24
- } from "@ai-sdk/provider-utils";
25
-
26
- // src/chat/convert-to-deepseek-chat-messages.ts
27
- function convertToDeepSeekChatMessages({
28
- prompt,
29
- responseFormat
30
- }) {
31
- var _a;
32
- const messages = [];
33
- const warnings = [];
34
- if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
35
- if (responseFormat.schema == null) {
36
- messages.push({
37
- role: "system",
38
- content: "Return JSON."
39
- });
40
- } else {
41
- messages.push({
42
- role: "system",
43
- content: "Return JSON that conforms to the following schema: " + JSON.stringify(responseFormat.schema)
44
- });
45
- warnings.push({
46
- type: "compatibility",
47
- feature: "responseFormat JSON schema",
48
- details: "JSON response schema is injected into the system message."
49
- });
50
- }
51
- }
52
- let lastUserMessageIndex = -1;
53
- for (let i = prompt.length - 1; i >= 0; i--) {
54
- if (prompt[i].role === "user") {
55
- lastUserMessageIndex = i;
56
- break;
57
- }
58
- }
59
- let index = -1;
60
- for (const { role, content } of prompt) {
61
- index++;
62
- switch (role) {
63
- case "system": {
64
- messages.push({ role: "system", content });
65
- break;
66
- }
67
- case "user": {
68
- let userContent = "";
69
- for (const part of content) {
70
- if (part.type === "text") {
71
- userContent += part.text;
72
- } else {
73
- warnings.push({
74
- type: "unsupported",
75
- feature: `user message part type: ${part.type}`
76
- });
77
- }
78
- }
79
- messages.push({
80
- role: "user",
81
- content: userContent
82
- });
83
- break;
84
- }
85
- case "assistant": {
86
- let text = "";
87
- let reasoning;
88
- const toolCalls = [];
89
- for (const part of content) {
90
- switch (part.type) {
91
- case "text": {
92
- text += part.text;
93
- break;
94
- }
95
- case "reasoning": {
96
- if (index <= lastUserMessageIndex) {
97
- break;
98
- }
99
- if (reasoning == null) {
100
- reasoning = part.text;
101
- } else {
102
- reasoning += part.text;
103
- }
104
- break;
105
- }
106
- case "tool-call": {
107
- toolCalls.push({
108
- id: part.toolCallId,
109
- type: "function",
110
- function: {
111
- name: part.toolName,
112
- arguments: JSON.stringify(part.input)
113
- }
114
- });
115
- break;
116
- }
117
- }
118
- }
119
- messages.push({
120
- role: "assistant",
121
- content: text,
122
- reasoning_content: reasoning,
123
- tool_calls: toolCalls.length > 0 ? toolCalls : void 0
124
- });
125
- break;
126
- }
127
- case "tool": {
128
- for (const toolResponse of content) {
129
- if (toolResponse.type === "tool-approval-response") {
130
- continue;
131
- }
132
- const output = toolResponse.output;
133
- let contentValue;
134
- switch (output.type) {
135
- case "text":
136
- case "error-text":
137
- contentValue = output.value;
138
- break;
139
- case "execution-denied":
140
- contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
141
- break;
142
- case "content":
143
- case "json":
144
- case "error-json":
145
- contentValue = JSON.stringify(output.value);
146
- break;
147
- }
148
- messages.push({
149
- role: "tool",
150
- tool_call_id: toolResponse.toolCallId,
151
- content: contentValue
152
- });
153
- }
154
- break;
155
- }
156
- default: {
157
- warnings.push({
158
- type: "unsupported",
159
- feature: `message role: ${role}`
160
- });
161
- break;
162
- }
163
- }
164
- }
165
- return { messages, warnings };
166
- }
167
-
168
- // src/chat/convert-to-deepseek-usage.ts
169
- function convertDeepSeekUsage(usage) {
170
- var _a, _b, _c, _d, _e;
171
- if (usage == null) {
172
- return {
173
- inputTokens: {
174
- total: void 0,
175
- noCache: void 0,
176
- cacheRead: void 0,
177
- cacheWrite: void 0
178
- },
179
- outputTokens: {
180
- total: void 0,
181
- text: void 0,
182
- reasoning: void 0
183
- },
184
- raw: void 0
185
- };
186
- }
187
- const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
188
- const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
189
- const cacheReadTokens = (_c = usage.prompt_cache_hit_tokens) != null ? _c : 0;
190
- const reasoningTokens = (_e = (_d = usage.completion_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : 0;
191
- return {
192
- inputTokens: {
193
- total: promptTokens,
194
- noCache: promptTokens - cacheReadTokens,
195
- cacheRead: cacheReadTokens,
196
- cacheWrite: void 0
197
- },
198
- outputTokens: {
199
- total: completionTokens,
200
- text: completionTokens - reasoningTokens,
201
- reasoning: reasoningTokens
202
- },
203
- raw: usage
204
- };
205
- }
206
-
207
- // src/chat/deepseek-chat-api-types.ts
208
- import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
209
- import { z } from "zod/v4";
210
- var tokenUsageSchema = z.object({
211
- prompt_tokens: z.number().nullish(),
212
- completion_tokens: z.number().nullish(),
213
- prompt_cache_hit_tokens: z.number().nullish(),
214
- prompt_cache_miss_tokens: z.number().nullish(),
215
- total_tokens: z.number().nullish(),
216
- completion_tokens_details: z.object({
217
- reasoning_tokens: z.number().nullish()
218
- }).nullish()
219
- }).nullish();
220
- var deepSeekErrorSchema = z.object({
221
- error: z.object({
222
- message: z.string(),
223
- type: z.string().nullish(),
224
- param: z.any().nullish(),
225
- code: z.union([z.string(), z.number()]).nullish()
226
- })
227
- });
228
- var deepseekChatResponseSchema = z.object({
229
- id: z.string().nullish(),
230
- created: z.number().nullish(),
231
- model: z.string().nullish(),
232
- choices: z.array(
233
- z.object({
234
- message: z.object({
235
- role: z.literal("assistant").nullish(),
236
- content: z.string().nullish(),
237
- reasoning_content: z.string().nullish(),
238
- tool_calls: z.array(
239
- z.object({
240
- id: z.string().nullish(),
241
- function: z.object({
242
- name: z.string(),
243
- arguments: z.string()
244
- })
245
- })
246
- ).nullish()
247
- }),
248
- finish_reason: z.string().nullish()
249
- })
250
- ),
251
- usage: tokenUsageSchema
252
- });
253
- var deepseekChatChunkSchema = lazySchema(
254
- () => zodSchema(
255
- z.union([
256
- z.object({
257
- id: z.string().nullish(),
258
- created: z.number().nullish(),
259
- model: z.string().nullish(),
260
- choices: z.array(
261
- z.object({
262
- delta: z.object({
263
- role: z.enum(["assistant"]).nullish(),
264
- content: z.string().nullish(),
265
- reasoning_content: z.string().nullish(),
266
- tool_calls: z.array(
267
- z.object({
268
- index: z.number(),
269
- id: z.string().nullish(),
270
- function: z.object({
271
- name: z.string().nullish(),
272
- arguments: z.string().nullish()
273
- })
274
- })
275
- ).nullish()
276
- }).nullish(),
277
- finish_reason: z.string().nullish()
278
- })
279
- ),
280
- usage: tokenUsageSchema
281
- }),
282
- deepSeekErrorSchema
283
- ])
284
- )
285
- );
286
-
287
- // src/chat/deepseek-chat-options.ts
288
- import { z as z2 } from "zod/v4";
289
- var deepseekLanguageModelOptions = z2.object({
290
- /**
291
- * Type of thinking to use. Defaults to `enabled`.
292
- */
293
- thinking: z2.object({
294
- type: z2.enum(["enabled", "disabled"]).optional()
295
- }).optional()
296
- });
297
-
298
- // src/chat/deepseek-prepare-tools.ts
299
- function prepareTools({
300
- tools,
301
- toolChoice
302
- }) {
303
- tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
304
- const toolWarnings = [];
305
- if (tools == null) {
306
- return { tools: void 0, toolChoice: void 0, toolWarnings };
307
- }
308
- const deepseekTools = [];
309
- for (const tool of tools) {
310
- if (tool.type === "provider") {
311
- toolWarnings.push({
312
- type: "unsupported",
313
- feature: `provider-defined tool ${tool.id}`
314
- });
315
- } else {
316
- deepseekTools.push({
317
- type: "function",
318
- function: {
319
- name: tool.name,
320
- description: tool.description,
321
- parameters: tool.inputSchema,
322
- ...tool.strict != null ? { strict: tool.strict } : {}
323
- }
324
- });
325
- }
326
- }
327
- if (toolChoice == null) {
328
- return { tools: deepseekTools, toolChoice: void 0, toolWarnings };
329
- }
330
- const type = toolChoice == null ? void 0 : toolChoice.type;
331
- switch (type) {
332
- case "auto":
333
- case "none":
334
- case "required":
335
- return { tools: deepseekTools, toolChoice: type, toolWarnings };
336
- case "tool":
337
- return {
338
- tools: deepseekTools,
339
- toolChoice: {
340
- type: "function",
341
- function: { name: toolChoice.toolName }
342
- },
343
- toolWarnings
344
- };
345
- default: {
346
- return {
347
- tools: deepseekTools,
348
- toolChoice: void 0,
349
- toolWarnings: [
350
- ...toolWarnings,
351
- {
352
- type: "unsupported",
353
- feature: `tool choice type: ${type}`
354
- }
355
- ]
356
- };
357
- }
358
- }
359
- }
360
-
361
- // src/chat/get-response-metadata.ts
362
- function getResponseMetadata({
363
- id,
364
- model,
365
- created
366
- }) {
367
- return {
368
- id: id != null ? id : void 0,
369
- modelId: model != null ? model : void 0,
370
- timestamp: created != null ? new Date(created * 1e3) : void 0
371
- };
372
- }
373
-
374
- // src/chat/map-deepseek-finish-reason.ts
375
- function mapDeepSeekFinishReason(finishReason) {
376
- switch (finishReason) {
377
- case "stop":
378
- return "stop";
379
- case "length":
380
- return "length";
381
- case "content_filter":
382
- return "content-filter";
383
- case "tool_calls":
384
- return "tool-calls";
385
- case "insufficient_system_resource":
386
- return "error";
387
- default:
388
- return "other";
389
- }
390
- }
391
-
392
- // src/chat/deepseek-chat-language-model.ts
393
- var DeepSeekChatLanguageModel = class {
394
- constructor(modelId, config) {
395
- this.specificationVersion = "v3";
396
- this.supportedUrls = {};
397
- this.modelId = modelId;
398
- this.config = config;
399
- this.failedResponseHandler = createJsonErrorResponseHandler({
400
- errorSchema: deepSeekErrorSchema,
401
- errorToMessage: (error) => error.error.message
402
- });
403
- }
404
- get provider() {
405
- return this.config.provider;
406
- }
407
- get providerOptionsName() {
408
- return this.config.provider.split(".")[0].trim();
409
- }
410
- async getArgs({
411
- prompt,
412
- maxOutputTokens,
413
- temperature,
414
- topP,
415
- topK,
416
- frequencyPenalty,
417
- presencePenalty,
418
- providerOptions,
419
- stopSequences,
420
- responseFormat,
421
- seed,
422
- toolChoice,
423
- tools
424
- }) {
425
- var _a, _b;
426
- const deepseekOptions = (_a = await parseProviderOptions({
427
- provider: this.providerOptionsName,
428
- providerOptions,
429
- schema: deepseekLanguageModelOptions
430
- })) != null ? _a : {};
431
- const { messages, warnings } = convertToDeepSeekChatMessages({
432
- prompt,
433
- responseFormat
434
- });
435
- if (topK != null) {
436
- warnings.push({ type: "unsupported", feature: "topK" });
437
- }
438
- if (seed != null) {
439
- warnings.push({ type: "unsupported", feature: "seed" });
440
- }
441
- const {
442
- tools: deepseekTools,
443
- toolChoice: deepseekToolChoices,
444
- toolWarnings
445
- } = prepareTools({
446
- tools,
447
- toolChoice
448
- });
449
- return {
450
- args: {
451
- model: this.modelId,
452
- max_tokens: maxOutputTokens,
453
- temperature,
454
- top_p: topP,
455
- frequency_penalty: frequencyPenalty,
456
- presence_penalty: presencePenalty,
457
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? { type: "json_object" } : void 0,
458
- stop: stopSequences,
459
- messages,
460
- tools: deepseekTools,
461
- tool_choice: deepseekToolChoices,
462
- thinking: ((_b = deepseekOptions.thinking) == null ? void 0 : _b.type) != null ? { type: deepseekOptions.thinking.type } : void 0
463
- },
464
- warnings: [...warnings, ...toolWarnings]
465
- };
466
- }
467
- async doGenerate(options) {
468
- var _a, _b, _c, _d;
469
- const { args, warnings } = await this.getArgs({ ...options });
470
- const {
471
- responseHeaders,
472
- value: responseBody,
473
- rawValue: rawResponse
474
- } = await postJsonToApi({
475
- url: this.config.url({
476
- path: "/chat/completions",
477
- modelId: this.modelId
478
- }),
479
- headers: combineHeaders(this.config.headers(), options.headers),
480
- body: args,
481
- failedResponseHandler: this.failedResponseHandler,
482
- successfulResponseHandler: createJsonResponseHandler(
483
- deepseekChatResponseSchema
484
- ),
485
- abortSignal: options.abortSignal,
486
- fetch: this.config.fetch
487
- });
488
- const choice = responseBody.choices[0];
489
- const content = [];
490
- const reasoning = choice.message.reasoning_content;
491
- if (reasoning != null && reasoning.length > 0) {
492
- content.push({
493
- type: "reasoning",
494
- text: reasoning
495
- });
496
- }
497
- if (choice.message.tool_calls != null) {
498
- for (const toolCall of choice.message.tool_calls) {
499
- content.push({
500
- type: "tool-call",
501
- toolCallId: (_a = toolCall.id) != null ? _a : generateId(),
502
- toolName: toolCall.function.name,
503
- input: toolCall.function.arguments
504
- });
505
- }
506
- }
507
- const text = choice.message.content;
508
- if (text != null && text.length > 0) {
509
- content.push({ type: "text", text });
510
- }
511
- return {
512
- content,
513
- finishReason: {
514
- unified: mapDeepSeekFinishReason(choice.finish_reason),
515
- raw: (_b = choice.finish_reason) != null ? _b : void 0
516
- },
517
- usage: convertDeepSeekUsage(responseBody.usage),
518
- providerMetadata: {
519
- [this.providerOptionsName]: {
520
- promptCacheHitTokens: (_c = responseBody.usage) == null ? void 0 : _c.prompt_cache_hit_tokens,
521
- promptCacheMissTokens: (_d = responseBody.usage) == null ? void 0 : _d.prompt_cache_miss_tokens
522
- }
523
- },
524
- request: { body: args },
525
- response: {
526
- ...getResponseMetadata(responseBody),
527
- headers: responseHeaders,
528
- body: rawResponse
529
- },
530
- warnings
531
- };
532
- }
533
- async doStream(options) {
534
- const { args, warnings } = await this.getArgs({ ...options });
535
- const body = {
536
- ...args,
537
- stream: true,
538
- stream_options: { include_usage: true }
539
- };
540
- const { responseHeaders, value: response } = await postJsonToApi({
541
- url: this.config.url({
542
- path: "/chat/completions",
543
- modelId: this.modelId
544
- }),
545
- headers: combineHeaders(this.config.headers(), options.headers),
546
- body,
547
- failedResponseHandler: this.failedResponseHandler,
548
- successfulResponseHandler: createEventSourceResponseHandler(
549
- deepseekChatChunkSchema
550
- ),
551
- abortSignal: options.abortSignal,
552
- fetch: this.config.fetch
553
- });
554
- const toolCalls = [];
555
- let finishReason = {
556
- unified: "other",
557
- raw: void 0
558
- };
559
- let usage = void 0;
560
- let isFirstChunk = true;
561
- const providerOptionsName = this.providerOptionsName;
562
- let isActiveReasoning = false;
563
- let isActiveText = false;
564
- return {
565
- stream: response.pipeThrough(
566
- new TransformStream({
567
- start(controller) {
568
- controller.enqueue({ type: "stream-start", warnings });
569
- },
570
- transform(chunk, controller) {
571
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
572
- if (options.includeRawChunks) {
573
- controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
574
- }
575
- if (!chunk.success) {
576
- finishReason = { unified: "error", raw: void 0 };
577
- controller.enqueue({ type: "error", error: chunk.error });
578
- return;
579
- }
580
- const value = chunk.value;
581
- if ("error" in value) {
582
- finishReason = { unified: "error", raw: void 0 };
583
- controller.enqueue({ type: "error", error: value.error.message });
584
- return;
585
- }
586
- if (isFirstChunk) {
587
- isFirstChunk = false;
588
- controller.enqueue({
589
- type: "response-metadata",
590
- ...getResponseMetadata(value)
591
- });
592
- }
593
- if (value.usage != null) {
594
- usage = value.usage;
595
- }
596
- const choice = value.choices[0];
597
- if ((choice == null ? void 0 : choice.finish_reason) != null) {
598
- finishReason = {
599
- unified: mapDeepSeekFinishReason(choice.finish_reason),
600
- raw: choice.finish_reason
601
- };
602
- }
603
- if ((choice == null ? void 0 : choice.delta) == null) {
604
- return;
605
- }
606
- const delta = choice.delta;
607
- const reasoningContent = delta.reasoning_content;
608
- if (reasoningContent) {
609
- if (!isActiveReasoning) {
610
- controller.enqueue({
611
- type: "reasoning-start",
612
- id: "reasoning-0"
613
- });
614
- isActiveReasoning = true;
615
- }
616
- controller.enqueue({
617
- type: "reasoning-delta",
618
- id: "reasoning-0",
619
- delta: reasoningContent
620
- });
621
- }
622
- if (delta.content) {
623
- if (!isActiveText) {
624
- controller.enqueue({ type: "text-start", id: "txt-0" });
625
- isActiveText = true;
626
- }
627
- if (isActiveReasoning) {
628
- controller.enqueue({
629
- type: "reasoning-end",
630
- id: "reasoning-0"
631
- });
632
- isActiveReasoning = false;
633
- }
634
- controller.enqueue({
635
- type: "text-delta",
636
- id: "txt-0",
637
- delta: delta.content
638
- });
639
- }
640
- if (delta.tool_calls != null) {
641
- if (isActiveReasoning) {
642
- controller.enqueue({
643
- type: "reasoning-end",
644
- id: "reasoning-0"
645
- });
646
- isActiveReasoning = false;
647
- }
648
- for (const toolCallDelta of delta.tool_calls) {
649
- const index = toolCallDelta.index;
650
- if (toolCalls[index] == null) {
651
- if (toolCallDelta.id == null) {
652
- throw new InvalidResponseDataError({
653
- data: toolCallDelta,
654
- message: `Expected 'id' to be a string.`
655
- });
656
- }
657
- if (((_a = toolCallDelta.function) == null ? void 0 : _a.name) == null) {
658
- throw new InvalidResponseDataError({
659
- data: toolCallDelta,
660
- message: `Expected 'function.name' to be a string.`
661
- });
662
- }
663
- controller.enqueue({
664
- type: "tool-input-start",
665
- id: toolCallDelta.id,
666
- toolName: toolCallDelta.function.name
667
- });
668
- toolCalls[index] = {
669
- id: toolCallDelta.id,
670
- type: "function",
671
- function: {
672
- name: toolCallDelta.function.name,
673
- arguments: (_b = toolCallDelta.function.arguments) != null ? _b : ""
674
- },
675
- hasFinished: false
676
- };
677
- const toolCall2 = toolCalls[index];
678
- if (((_c = toolCall2.function) == null ? void 0 : _c.name) != null && ((_d = toolCall2.function) == null ? void 0 : _d.arguments) != null) {
679
- if (toolCall2.function.arguments.length > 0) {
680
- controller.enqueue({
681
- type: "tool-input-delta",
682
- id: toolCall2.id,
683
- delta: toolCall2.function.arguments
684
- });
685
- }
686
- if (isParsableJson(toolCall2.function.arguments)) {
687
- controller.enqueue({
688
- type: "tool-input-end",
689
- id: toolCall2.id
690
- });
691
- controller.enqueue({
692
- type: "tool-call",
693
- toolCallId: (_e = toolCall2.id) != null ? _e : generateId(),
694
- toolName: toolCall2.function.name,
695
- input: toolCall2.function.arguments
696
- });
697
- toolCall2.hasFinished = true;
698
- }
699
- }
700
- continue;
701
- }
702
- const toolCall = toolCalls[index];
703
- if (toolCall.hasFinished) {
704
- continue;
705
- }
706
- if (((_f = toolCallDelta.function) == null ? void 0 : _f.arguments) != null) {
707
- toolCall.function.arguments += (_h = (_g = toolCallDelta.function) == null ? void 0 : _g.arguments) != null ? _h : "";
708
- }
709
- controller.enqueue({
710
- type: "tool-input-delta",
711
- id: toolCall.id,
712
- delta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
713
- });
714
- if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && isParsableJson(toolCall.function.arguments)) {
715
- controller.enqueue({
716
- type: "tool-input-end",
717
- id: toolCall.id
718
- });
719
- controller.enqueue({
720
- type: "tool-call",
721
- toolCallId: (_l = toolCall.id) != null ? _l : generateId(),
722
- toolName: toolCall.function.name,
723
- input: toolCall.function.arguments
724
- });
725
- toolCall.hasFinished = true;
726
- }
727
- }
728
- }
729
- },
730
- flush(controller) {
731
- var _a, _b, _c;
732
- if (isActiveReasoning) {
733
- controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
734
- }
735
- if (isActiveText) {
736
- controller.enqueue({ type: "text-end", id: "txt-0" });
737
- }
738
- for (const toolCall of toolCalls.filter(
739
- (toolCall2) => !toolCall2.hasFinished
740
- )) {
741
- controller.enqueue({
742
- type: "tool-input-end",
743
- id: toolCall.id
744
- });
745
- controller.enqueue({
746
- type: "tool-call",
747
- toolCallId: (_a = toolCall.id) != null ? _a : generateId(),
748
- toolName: toolCall.function.name,
749
- input: toolCall.function.arguments
750
- });
751
- }
752
- controller.enqueue({
753
- type: "finish",
754
- finishReason,
755
- usage: convertDeepSeekUsage(usage),
756
- providerMetadata: {
757
- [providerOptionsName]: {
758
- promptCacheHitTokens: (_b = usage == null ? void 0 : usage.prompt_cache_hit_tokens) != null ? _b : void 0,
759
- promptCacheMissTokens: (_c = usage == null ? void 0 : usage.prompt_cache_miss_tokens) != null ? _c : void 0
760
- }
761
- }
762
- });
763
- }
764
- })
765
- ),
766
- request: { body },
767
- response: { headers: responseHeaders }
768
- };
769
- }
770
- };
771
-
772
- // src/version.ts
773
- var VERSION = true ? "3.0.0-beta.3" : "0.0.0-test";
774
-
775
- // src/deepseek-provider.ts
776
- function createDeepSeek(options = {}) {
777
- var _a;
778
- const baseURL = withoutTrailingSlash(
779
- (_a = options.baseURL) != null ? _a : "https://api.deepseek.com"
780
- );
781
- const getHeaders = () => withUserAgentSuffix(
782
- {
783
- Authorization: `Bearer ${loadApiKey({
784
- apiKey: options.apiKey,
785
- environmentVariableName: "DEEPSEEK_API_KEY",
786
- description: "DeepSeek API key"
787
- })}`,
788
- ...options.headers
789
- },
790
- `ai-sdk/deepseek/${VERSION}`
791
- );
792
- const createLanguageModel = (modelId) => {
793
- return new DeepSeekChatLanguageModel(modelId, {
794
- provider: `deepseek.chat`,
795
- url: ({ path }) => `${baseURL}${path}`,
796
- headers: getHeaders,
797
- fetch: options.fetch
798
- });
799
- };
800
- const provider = (modelId) => createLanguageModel(modelId);
801
- provider.specificationVersion = "v3";
802
- provider.languageModel = createLanguageModel;
803
- provider.chat = createLanguageModel;
804
- provider.embeddingModel = (modelId) => {
805
- throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
806
- };
807
- provider.textEmbeddingModel = provider.embeddingModel;
808
- provider.imageModel = (modelId) => {
809
- throw new NoSuchModelError({ modelId, modelType: "imageModel" });
810
- };
811
- return provider;
812
- }
813
- var deepseek = createDeepSeek();
814
- export {
815
- VERSION,
816
- createDeepSeek,
817
- deepseek
818
- };
819
- //# sourceMappingURL=index.mjs.map