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