@ai-sdk/deepseek 3.0.0-beta.8 → 3.0.0-canary.34
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 +228 -0
- package/README.md +2 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +135 -220
- package/dist/index.js.map +1 -1
- package/docs/30-deepseek.mdx +14 -14
- package/package.json +11 -9
- package/src/chat/convert-to-deepseek-chat-messages.ts +11 -5
- package/src/chat/convert-to-deepseek-usage.ts +1 -1
- package/src/chat/{deepseek-chat-options.ts → deepseek-chat-language-model-options.ts} +3 -3
- package/src/chat/deepseek-chat-language-model.ts +38 -147
- package/src/chat/deepseek-prepare-tools.ts +5 -2
- package/src/chat/map-deepseek-finish-reason.ts +1 -1
- package/src/deepseek-provider.ts +5 -5
- package/src/index.ts +12 -5
- package/dist/index.d.mts +0 -68
- package/dist/index.mjs +0 -821
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,45 +1,37 @@
|
|
|
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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
35
|
-
|
|
12
|
+
import {
|
|
13
|
+
combineHeaders,
|
|
14
|
+
createEventSourceResponseHandler,
|
|
15
|
+
createJsonErrorResponseHandler,
|
|
16
|
+
createJsonResponseHandler,
|
|
17
|
+
generateId,
|
|
18
|
+
isCustomReasoning,
|
|
19
|
+
parseProviderOptions,
|
|
20
|
+
postJsonToApi,
|
|
21
|
+
serializeModelOptions,
|
|
22
|
+
StreamingToolCallTracker,
|
|
23
|
+
WORKFLOW_SERIALIZE,
|
|
24
|
+
WORKFLOW_DESERIALIZE
|
|
25
|
+
} from "@ai-sdk/provider-utils";
|
|
36
26
|
|
|
37
27
|
// src/chat/convert-to-deepseek-chat-messages.ts
|
|
38
28
|
function convertToDeepSeekChatMessages({
|
|
39
29
|
prompt,
|
|
40
|
-
responseFormat
|
|
30
|
+
responseFormat,
|
|
31
|
+
modelId
|
|
41
32
|
}) {
|
|
42
33
|
var _a;
|
|
34
|
+
const isDeepSeekV4 = modelId.includes("deepseek-v4");
|
|
43
35
|
const messages = [];
|
|
44
36
|
const warnings = [];
|
|
45
37
|
if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
|
|
@@ -104,7 +96,7 @@ function convertToDeepSeekChatMessages({
|
|
|
104
96
|
break;
|
|
105
97
|
}
|
|
106
98
|
case "reasoning": {
|
|
107
|
-
if (index <= lastUserMessageIndex) {
|
|
99
|
+
if (index <= lastUserMessageIndex && !isDeepSeekV4) {
|
|
108
100
|
break;
|
|
109
101
|
}
|
|
110
102
|
if (reasoning == null) {
|
|
@@ -130,7 +122,7 @@ function convertToDeepSeekChatMessages({
|
|
|
130
122
|
messages.push({
|
|
131
123
|
role: "assistant",
|
|
132
124
|
content: text,
|
|
133
|
-
reasoning_content: reasoning,
|
|
125
|
+
reasoning_content: reasoning != null ? reasoning : isDeepSeekV4 ? "" : void 0,
|
|
134
126
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
135
127
|
});
|
|
136
128
|
break;
|
|
@@ -148,7 +140,7 @@ function convertToDeepSeekChatMessages({
|
|
|
148
140
|
contentValue = output.value;
|
|
149
141
|
break;
|
|
150
142
|
case "execution-denied":
|
|
151
|
-
contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
|
|
143
|
+
contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
|
|
152
144
|
break;
|
|
153
145
|
case "content":
|
|
154
146
|
case "json":
|
|
@@ -216,76 +208,76 @@ function convertDeepSeekUsage(usage) {
|
|
|
216
208
|
}
|
|
217
209
|
|
|
218
210
|
// src/chat/deepseek-chat-api-types.ts
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
var tokenUsageSchema =
|
|
222
|
-
prompt_tokens:
|
|
223
|
-
completion_tokens:
|
|
224
|
-
prompt_cache_hit_tokens:
|
|
225
|
-
prompt_cache_miss_tokens:
|
|
226
|
-
total_tokens:
|
|
227
|
-
completion_tokens_details:
|
|
228
|
-
reasoning_tokens:
|
|
211
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
212
|
+
import { z } from "zod/v4";
|
|
213
|
+
var tokenUsageSchema = z.object({
|
|
214
|
+
prompt_tokens: z.number().nullish(),
|
|
215
|
+
completion_tokens: z.number().nullish(),
|
|
216
|
+
prompt_cache_hit_tokens: z.number().nullish(),
|
|
217
|
+
prompt_cache_miss_tokens: z.number().nullish(),
|
|
218
|
+
total_tokens: z.number().nullish(),
|
|
219
|
+
completion_tokens_details: z.object({
|
|
220
|
+
reasoning_tokens: z.number().nullish()
|
|
229
221
|
}).nullish()
|
|
230
222
|
}).nullish();
|
|
231
|
-
var deepSeekErrorSchema =
|
|
232
|
-
error:
|
|
233
|
-
message:
|
|
234
|
-
type:
|
|
235
|
-
param:
|
|
236
|
-
code:
|
|
223
|
+
var deepSeekErrorSchema = z.object({
|
|
224
|
+
error: z.object({
|
|
225
|
+
message: z.string(),
|
|
226
|
+
type: z.string().nullish(),
|
|
227
|
+
param: z.any().nullish(),
|
|
228
|
+
code: z.union([z.string(), z.number()]).nullish()
|
|
237
229
|
})
|
|
238
230
|
});
|
|
239
|
-
var deepseekChatResponseSchema =
|
|
240
|
-
id:
|
|
241
|
-
created:
|
|
242
|
-
model:
|
|
243
|
-
choices:
|
|
244
|
-
|
|
245
|
-
message:
|
|
246
|
-
role:
|
|
247
|
-
content:
|
|
248
|
-
reasoning_content:
|
|
249
|
-
tool_calls:
|
|
250
|
-
|
|
251
|
-
id:
|
|
252
|
-
function:
|
|
253
|
-
name:
|
|
254
|
-
arguments:
|
|
231
|
+
var deepseekChatResponseSchema = z.object({
|
|
232
|
+
id: z.string().nullish(),
|
|
233
|
+
created: z.number().nullish(),
|
|
234
|
+
model: z.string().nullish(),
|
|
235
|
+
choices: z.array(
|
|
236
|
+
z.object({
|
|
237
|
+
message: z.object({
|
|
238
|
+
role: z.literal("assistant").nullish(),
|
|
239
|
+
content: z.string().nullish(),
|
|
240
|
+
reasoning_content: z.string().nullish(),
|
|
241
|
+
tool_calls: z.array(
|
|
242
|
+
z.object({
|
|
243
|
+
id: z.string().nullish(),
|
|
244
|
+
function: z.object({
|
|
245
|
+
name: z.string(),
|
|
246
|
+
arguments: z.string()
|
|
255
247
|
})
|
|
256
248
|
})
|
|
257
249
|
).nullish()
|
|
258
250
|
}),
|
|
259
|
-
finish_reason:
|
|
251
|
+
finish_reason: z.string().nullish()
|
|
260
252
|
})
|
|
261
253
|
),
|
|
262
254
|
usage: tokenUsageSchema
|
|
263
255
|
});
|
|
264
|
-
var deepseekChatChunkSchema =
|
|
265
|
-
() =>
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
id:
|
|
269
|
-
created:
|
|
270
|
-
model:
|
|
271
|
-
choices:
|
|
272
|
-
|
|
273
|
-
delta:
|
|
274
|
-
role:
|
|
275
|
-
content:
|
|
276
|
-
reasoning_content:
|
|
277
|
-
tool_calls:
|
|
278
|
-
|
|
279
|
-
index:
|
|
280
|
-
id:
|
|
281
|
-
function:
|
|
282
|
-
name:
|
|
283
|
-
arguments:
|
|
256
|
+
var deepseekChatChunkSchema = lazySchema(
|
|
257
|
+
() => zodSchema(
|
|
258
|
+
z.union([
|
|
259
|
+
z.object({
|
|
260
|
+
id: z.string().nullish(),
|
|
261
|
+
created: z.number().nullish(),
|
|
262
|
+
model: z.string().nullish(),
|
|
263
|
+
choices: z.array(
|
|
264
|
+
z.object({
|
|
265
|
+
delta: z.object({
|
|
266
|
+
role: z.enum(["assistant"]).nullish(),
|
|
267
|
+
content: z.string().nullish(),
|
|
268
|
+
reasoning_content: z.string().nullish(),
|
|
269
|
+
tool_calls: z.array(
|
|
270
|
+
z.object({
|
|
271
|
+
index: z.number(),
|
|
272
|
+
id: z.string().nullish(),
|
|
273
|
+
function: z.object({
|
|
274
|
+
name: z.string().nullish(),
|
|
275
|
+
arguments: z.string().nullish()
|
|
284
276
|
})
|
|
285
277
|
})
|
|
286
278
|
).nullish()
|
|
287
279
|
}).nullish(),
|
|
288
|
-
finish_reason:
|
|
280
|
+
finish_reason: z.string().nullish()
|
|
289
281
|
})
|
|
290
282
|
),
|
|
291
283
|
usage: tokenUsageSchema
|
|
@@ -295,14 +287,14 @@ var deepseekChatChunkSchema = (0, import_provider_utils.lazySchema)(
|
|
|
295
287
|
)
|
|
296
288
|
);
|
|
297
289
|
|
|
298
|
-
// src/chat/deepseek-chat-options.ts
|
|
299
|
-
|
|
300
|
-
var
|
|
290
|
+
// src/chat/deepseek-chat-language-model-options.ts
|
|
291
|
+
import { z as z2 } from "zod/v4";
|
|
292
|
+
var deepseekLanguageModelChatOptions = z2.object({
|
|
301
293
|
/**
|
|
302
294
|
* Type of thinking to use. Defaults to `enabled`.
|
|
303
295
|
*/
|
|
304
|
-
thinking:
|
|
305
|
-
type:
|
|
296
|
+
thinking: z2.object({
|
|
297
|
+
type: z2.enum(["enabled", "disabled"]).optional()
|
|
306
298
|
}).optional()
|
|
307
299
|
});
|
|
308
300
|
|
|
@@ -401,17 +393,26 @@ function mapDeepSeekFinishReason(finishReason) {
|
|
|
401
393
|
}
|
|
402
394
|
|
|
403
395
|
// src/chat/deepseek-chat-language-model.ts
|
|
404
|
-
var DeepSeekChatLanguageModel = class {
|
|
396
|
+
var DeepSeekChatLanguageModel = class _DeepSeekChatLanguageModel {
|
|
405
397
|
constructor(modelId, config) {
|
|
406
398
|
this.specificationVersion = "v4";
|
|
407
399
|
this.supportedUrls = {};
|
|
408
400
|
this.modelId = modelId;
|
|
409
401
|
this.config = config;
|
|
410
|
-
this.failedResponseHandler =
|
|
402
|
+
this.failedResponseHandler = createJsonErrorResponseHandler({
|
|
411
403
|
errorSchema: deepSeekErrorSchema,
|
|
412
404
|
errorToMessage: (error) => error.error.message
|
|
413
405
|
});
|
|
414
406
|
}
|
|
407
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
408
|
+
return serializeModelOptions({
|
|
409
|
+
modelId: model.modelId,
|
|
410
|
+
config: model.config
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
414
|
+
return new _DeepSeekChatLanguageModel(options.modelId, options.config);
|
|
415
|
+
}
|
|
415
416
|
get provider() {
|
|
416
417
|
return this.config.provider;
|
|
417
418
|
}
|
|
@@ -435,14 +436,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
435
436
|
tools
|
|
436
437
|
}) {
|
|
437
438
|
var _a, _b;
|
|
438
|
-
const deepseekOptions = (_a = await
|
|
439
|
+
const deepseekOptions = (_a = await parseProviderOptions({
|
|
439
440
|
provider: this.providerOptionsName,
|
|
440
441
|
providerOptions,
|
|
441
|
-
schema:
|
|
442
|
+
schema: deepseekLanguageModelChatOptions
|
|
442
443
|
})) != null ? _a : {};
|
|
443
444
|
const { messages, warnings } = convertToDeepSeekChatMessages({
|
|
444
445
|
prompt,
|
|
445
|
-
responseFormat
|
|
446
|
+
responseFormat,
|
|
447
|
+
modelId: this.modelId
|
|
446
448
|
});
|
|
447
449
|
if (topK != null) {
|
|
448
450
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
@@ -471,27 +473,27 @@ var DeepSeekChatLanguageModel = class {
|
|
|
471
473
|
messages,
|
|
472
474
|
tools: deepseekTools,
|
|
473
475
|
tool_choice: deepseekToolChoices,
|
|
474
|
-
thinking: ((_b = deepseekOptions.thinking) == null ? void 0 : _b.type) != null ? { type: deepseekOptions.thinking.type } :
|
|
476
|
+
thinking: ((_b = deepseekOptions.thinking) == null ? void 0 : _b.type) != null ? { type: deepseekOptions.thinking.type } : isCustomReasoning(reasoning) ? { type: reasoning === "none" ? "disabled" : "enabled" } : void 0
|
|
475
477
|
},
|
|
476
478
|
warnings: [...warnings, ...toolWarnings]
|
|
477
479
|
};
|
|
478
480
|
}
|
|
479
481
|
async doGenerate(options) {
|
|
480
|
-
var _a, _b, _c, _d;
|
|
482
|
+
var _a, _b, _c, _d, _e, _f;
|
|
481
483
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
482
484
|
const {
|
|
483
485
|
responseHeaders,
|
|
484
486
|
value: responseBody,
|
|
485
487
|
rawValue: rawResponse
|
|
486
|
-
} = await
|
|
488
|
+
} = await postJsonToApi({
|
|
487
489
|
url: this.config.url({
|
|
488
490
|
path: "/chat/completions",
|
|
489
491
|
modelId: this.modelId
|
|
490
492
|
}),
|
|
491
|
-
headers: (
|
|
493
|
+
headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
|
|
492
494
|
body: args,
|
|
493
495
|
failedResponseHandler: this.failedResponseHandler,
|
|
494
|
-
successfulResponseHandler:
|
|
496
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
495
497
|
deepseekChatResponseSchema
|
|
496
498
|
),
|
|
497
499
|
abortSignal: options.abortSignal,
|
|
@@ -510,7 +512,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
510
512
|
for (const toolCall of choice.message.tool_calls) {
|
|
511
513
|
content.push({
|
|
512
514
|
type: "tool-call",
|
|
513
|
-
toolCallId: (
|
|
515
|
+
toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
|
|
514
516
|
toolName: toolCall.function.name,
|
|
515
517
|
input: toolCall.function.arguments
|
|
516
518
|
});
|
|
@@ -524,13 +526,13 @@ var DeepSeekChatLanguageModel = class {
|
|
|
524
526
|
content,
|
|
525
527
|
finishReason: {
|
|
526
528
|
unified: mapDeepSeekFinishReason(choice.finish_reason),
|
|
527
|
-
raw: (
|
|
529
|
+
raw: (_d = choice.finish_reason) != null ? _d : void 0
|
|
528
530
|
},
|
|
529
531
|
usage: convertDeepSeekUsage(responseBody.usage),
|
|
530
532
|
providerMetadata: {
|
|
531
533
|
[this.providerOptionsName]: {
|
|
532
|
-
promptCacheHitTokens: (
|
|
533
|
-
promptCacheMissTokens: (
|
|
534
|
+
promptCacheHitTokens: (_e = responseBody.usage) == null ? void 0 : _e.prompt_cache_hit_tokens,
|
|
535
|
+
promptCacheMissTokens: (_f = responseBody.usage) == null ? void 0 : _f.prompt_cache_miss_tokens
|
|
534
536
|
}
|
|
535
537
|
},
|
|
536
538
|
request: { body: args },
|
|
@@ -543,27 +545,28 @@ var DeepSeekChatLanguageModel = class {
|
|
|
543
545
|
};
|
|
544
546
|
}
|
|
545
547
|
async doStream(options) {
|
|
548
|
+
var _a, _b;
|
|
546
549
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
547
550
|
const body = {
|
|
548
551
|
...args,
|
|
549
552
|
stream: true,
|
|
550
553
|
stream_options: { include_usage: true }
|
|
551
554
|
};
|
|
552
|
-
const { responseHeaders, value: response } = await
|
|
555
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
553
556
|
url: this.config.url({
|
|
554
557
|
path: "/chat/completions",
|
|
555
558
|
modelId: this.modelId
|
|
556
559
|
}),
|
|
557
|
-
headers: (
|
|
560
|
+
headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
|
|
558
561
|
body,
|
|
559
562
|
failedResponseHandler: this.failedResponseHandler,
|
|
560
|
-
successfulResponseHandler:
|
|
563
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
561
564
|
deepseekChatChunkSchema
|
|
562
565
|
),
|
|
563
566
|
abortSignal: options.abortSignal,
|
|
564
567
|
fetch: this.config.fetch
|
|
565
568
|
});
|
|
566
|
-
|
|
569
|
+
let toolCallTracker;
|
|
567
570
|
let finishReason = {
|
|
568
571
|
unified: "other",
|
|
569
572
|
raw: void 0
|
|
@@ -577,10 +580,12 @@ var DeepSeekChatLanguageModel = class {
|
|
|
577
580
|
stream: response.pipeThrough(
|
|
578
581
|
new TransformStream({
|
|
579
582
|
start(controller) {
|
|
583
|
+
toolCallTracker = new StreamingToolCallTracker(controller, {
|
|
584
|
+
generateId
|
|
585
|
+
});
|
|
580
586
|
controller.enqueue({ type: "stream-start", warnings });
|
|
581
587
|
},
|
|
582
588
|
transform(chunk, controller) {
|
|
583
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
584
589
|
if (options.includeRawChunks) {
|
|
585
590
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
586
591
|
}
|
|
@@ -658,117 +663,27 @@ var DeepSeekChatLanguageModel = class {
|
|
|
658
663
|
isActiveReasoning = false;
|
|
659
664
|
}
|
|
660
665
|
for (const toolCallDelta of delta.tool_calls) {
|
|
661
|
-
|
|
662
|
-
if (toolCalls[index] == null) {
|
|
663
|
-
if (toolCallDelta.id == null) {
|
|
664
|
-
throw new import_provider.InvalidResponseDataError({
|
|
665
|
-
data: toolCallDelta,
|
|
666
|
-
message: `Expected 'id' to be a string.`
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
if (((_a = toolCallDelta.function) == null ? void 0 : _a.name) == null) {
|
|
670
|
-
throw new import_provider.InvalidResponseDataError({
|
|
671
|
-
data: toolCallDelta,
|
|
672
|
-
message: `Expected 'function.name' to be a string.`
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
controller.enqueue({
|
|
676
|
-
type: "tool-input-start",
|
|
677
|
-
id: toolCallDelta.id,
|
|
678
|
-
toolName: toolCallDelta.function.name
|
|
679
|
-
});
|
|
680
|
-
toolCalls[index] = {
|
|
681
|
-
id: toolCallDelta.id,
|
|
682
|
-
type: "function",
|
|
683
|
-
function: {
|
|
684
|
-
name: toolCallDelta.function.name,
|
|
685
|
-
arguments: (_b = toolCallDelta.function.arguments) != null ? _b : ""
|
|
686
|
-
},
|
|
687
|
-
hasFinished: false
|
|
688
|
-
};
|
|
689
|
-
const toolCall2 = toolCalls[index];
|
|
690
|
-
if (((_c = toolCall2.function) == null ? void 0 : _c.name) != null && ((_d = toolCall2.function) == null ? void 0 : _d.arguments) != null) {
|
|
691
|
-
if (toolCall2.function.arguments.length > 0) {
|
|
692
|
-
controller.enqueue({
|
|
693
|
-
type: "tool-input-delta",
|
|
694
|
-
id: toolCall2.id,
|
|
695
|
-
delta: toolCall2.function.arguments
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
if ((0, import_provider_utils2.isParsableJson)(toolCall2.function.arguments)) {
|
|
699
|
-
controller.enqueue({
|
|
700
|
-
type: "tool-input-end",
|
|
701
|
-
id: toolCall2.id
|
|
702
|
-
});
|
|
703
|
-
controller.enqueue({
|
|
704
|
-
type: "tool-call",
|
|
705
|
-
toolCallId: (_e = toolCall2.id) != null ? _e : (0, import_provider_utils2.generateId)(),
|
|
706
|
-
toolName: toolCall2.function.name,
|
|
707
|
-
input: toolCall2.function.arguments
|
|
708
|
-
});
|
|
709
|
-
toolCall2.hasFinished = true;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
continue;
|
|
713
|
-
}
|
|
714
|
-
const toolCall = toolCalls[index];
|
|
715
|
-
if (toolCall.hasFinished) {
|
|
716
|
-
continue;
|
|
717
|
-
}
|
|
718
|
-
if (((_f = toolCallDelta.function) == null ? void 0 : _f.arguments) != null) {
|
|
719
|
-
toolCall.function.arguments += (_h = (_g = toolCallDelta.function) == null ? void 0 : _g.arguments) != null ? _h : "";
|
|
720
|
-
}
|
|
721
|
-
controller.enqueue({
|
|
722
|
-
type: "tool-input-delta",
|
|
723
|
-
id: toolCall.id,
|
|
724
|
-
delta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
|
|
725
|
-
});
|
|
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)) {
|
|
727
|
-
controller.enqueue({
|
|
728
|
-
type: "tool-input-end",
|
|
729
|
-
id: toolCall.id
|
|
730
|
-
});
|
|
731
|
-
controller.enqueue({
|
|
732
|
-
type: "tool-call",
|
|
733
|
-
toolCallId: (_l = toolCall.id) != null ? _l : (0, import_provider_utils2.generateId)(),
|
|
734
|
-
toolName: toolCall.function.name,
|
|
735
|
-
input: toolCall.function.arguments
|
|
736
|
-
});
|
|
737
|
-
toolCall.hasFinished = true;
|
|
738
|
-
}
|
|
666
|
+
toolCallTracker.processDelta(toolCallDelta);
|
|
739
667
|
}
|
|
740
668
|
}
|
|
741
669
|
},
|
|
742
670
|
flush(controller) {
|
|
743
|
-
var
|
|
671
|
+
var _a2, _b2;
|
|
744
672
|
if (isActiveReasoning) {
|
|
745
673
|
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
746
674
|
}
|
|
747
675
|
if (isActiveText) {
|
|
748
676
|
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
749
677
|
}
|
|
750
|
-
|
|
751
|
-
(toolCall2) => !toolCall2.hasFinished
|
|
752
|
-
)) {
|
|
753
|
-
controller.enqueue({
|
|
754
|
-
type: "tool-input-end",
|
|
755
|
-
id: toolCall.id
|
|
756
|
-
});
|
|
757
|
-
controller.enqueue({
|
|
758
|
-
type: "tool-call",
|
|
759
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils2.generateId)(),
|
|
760
|
-
toolName: toolCall.function.name,
|
|
761
|
-
input: toolCall.function.arguments
|
|
762
|
-
});
|
|
763
|
-
}
|
|
678
|
+
toolCallTracker.flush();
|
|
764
679
|
controller.enqueue({
|
|
765
680
|
type: "finish",
|
|
766
681
|
finishReason,
|
|
767
682
|
usage: convertDeepSeekUsage(usage),
|
|
768
683
|
providerMetadata: {
|
|
769
684
|
[providerOptionsName]: {
|
|
770
|
-
promptCacheHitTokens: (
|
|
771
|
-
promptCacheMissTokens: (
|
|
685
|
+
promptCacheHitTokens: (_a2 = usage == null ? void 0 : usage.prompt_cache_hit_tokens) != null ? _a2 : void 0,
|
|
686
|
+
promptCacheMissTokens: (_b2 = usage == null ? void 0 : usage.prompt_cache_miss_tokens) != null ? _b2 : void 0
|
|
772
687
|
}
|
|
773
688
|
}
|
|
774
689
|
});
|
|
@@ -782,17 +697,17 @@ var DeepSeekChatLanguageModel = class {
|
|
|
782
697
|
};
|
|
783
698
|
|
|
784
699
|
// src/version.ts
|
|
785
|
-
var VERSION = true ? "3.0.0-
|
|
700
|
+
var VERSION = true ? "3.0.0-canary.34" : "0.0.0-test";
|
|
786
701
|
|
|
787
702
|
// src/deepseek-provider.ts
|
|
788
703
|
function createDeepSeek(options = {}) {
|
|
789
704
|
var _a;
|
|
790
|
-
const baseURL =
|
|
705
|
+
const baseURL = withoutTrailingSlash(
|
|
791
706
|
(_a = options.baseURL) != null ? _a : "https://api.deepseek.com"
|
|
792
707
|
);
|
|
793
|
-
const getHeaders = () =>
|
|
708
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
794
709
|
{
|
|
795
|
-
Authorization: `Bearer ${
|
|
710
|
+
Authorization: `Bearer ${loadApiKey({
|
|
796
711
|
apiKey: options.apiKey,
|
|
797
712
|
environmentVariableName: "DEEPSEEK_API_KEY",
|
|
798
713
|
description: "DeepSeek API key"
|
|
@@ -814,19 +729,19 @@ function createDeepSeek(options = {}) {
|
|
|
814
729
|
provider.languageModel = createLanguageModel;
|
|
815
730
|
provider.chat = createLanguageModel;
|
|
816
731
|
provider.embeddingModel = (modelId) => {
|
|
817
|
-
throw new
|
|
732
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
818
733
|
};
|
|
819
734
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
820
735
|
provider.imageModel = (modelId) => {
|
|
821
|
-
throw new
|
|
736
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
822
737
|
};
|
|
823
738
|
return provider;
|
|
824
739
|
}
|
|
825
|
-
var
|
|
826
|
-
|
|
827
|
-
0 && (module.exports = {
|
|
740
|
+
var deepSeek = createDeepSeek();
|
|
741
|
+
export {
|
|
828
742
|
VERSION,
|
|
829
743
|
createDeepSeek,
|
|
830
|
-
|
|
831
|
-
|
|
744
|
+
deepSeek,
|
|
745
|
+
deepSeek as deepseek
|
|
746
|
+
};
|
|
832
747
|
//# sourceMappingURL=index.js.map
|