@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/CHANGELOG.md +235 -4
- package/README.md +2 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +133 -218
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/chat/convert-to-deepseek-chat-messages.ts +16 -10
- package/src/chat/convert-to-deepseek-usage.ts +2 -2
- package/src/chat/deepseek-chat-language-model.ts +51 -156
- package/src/chat/deepseek-prepare-tools.ts +5 -5
- package/src/chat/map-deepseek-finish-reason.ts +2 -2
- package/src/deepseek-provider.ts +7 -7
- package/dist/index.d.mts +0 -68
- package/dist/index.mjs +0 -819
- 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
|
|
@@ -296,13 +288,13 @@ var deepseekChatChunkSchema = (0, import_provider_utils.lazySchema)(
|
|
|
296
288
|
);
|
|
297
289
|
|
|
298
290
|
// src/chat/deepseek-chat-options.ts
|
|
299
|
-
|
|
300
|
-
var deepseekLanguageModelOptions =
|
|
291
|
+
import { z as z2 } from "zod/v4";
|
|
292
|
+
var deepseekLanguageModelOptions = 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
|
-
this.specificationVersion = "
|
|
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
|
}
|
|
@@ -426,6 +427,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
426
427
|
topK,
|
|
427
428
|
frequencyPenalty,
|
|
428
429
|
presencePenalty,
|
|
430
|
+
reasoning,
|
|
429
431
|
providerOptions,
|
|
430
432
|
stopSequences,
|
|
431
433
|
responseFormat,
|
|
@@ -434,14 +436,15 @@ var DeepSeekChatLanguageModel = class {
|
|
|
434
436
|
tools
|
|
435
437
|
}) {
|
|
436
438
|
var _a, _b;
|
|
437
|
-
const deepseekOptions = (_a = await
|
|
439
|
+
const deepseekOptions = (_a = await parseProviderOptions({
|
|
438
440
|
provider: this.providerOptionsName,
|
|
439
441
|
providerOptions,
|
|
440
442
|
schema: deepseekLanguageModelOptions
|
|
441
443
|
})) != null ? _a : {};
|
|
442
444
|
const { messages, warnings } = convertToDeepSeekChatMessages({
|
|
443
445
|
prompt,
|
|
444
|
-
responseFormat
|
|
446
|
+
responseFormat,
|
|
447
|
+
modelId: this.modelId
|
|
445
448
|
});
|
|
446
449
|
if (topK != null) {
|
|
447
450
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
@@ -470,27 +473,27 @@ var DeepSeekChatLanguageModel = class {
|
|
|
470
473
|
messages,
|
|
471
474
|
tools: deepseekTools,
|
|
472
475
|
tool_choice: deepseekToolChoices,
|
|
473
|
-
thinking: ((_b = deepseekOptions.thinking) == null ? void 0 : _b.type) != null ? { type: deepseekOptions.thinking.type } : void 0
|
|
476
|
+
thinking: ((_b = deepseekOptions.thinking) == null ? void 0 : _b.type) != null ? { type: deepseekOptions.thinking.type } : isCustomReasoning(reasoning) ? { type: reasoning === "none" ? "disabled" : "enabled" } : void 0
|
|
474
477
|
},
|
|
475
478
|
warnings: [...warnings, ...toolWarnings]
|
|
476
479
|
};
|
|
477
480
|
}
|
|
478
481
|
async doGenerate(options) {
|
|
479
|
-
var _a, _b, _c, _d;
|
|
482
|
+
var _a, _b, _c, _d, _e, _f;
|
|
480
483
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
481
484
|
const {
|
|
482
485
|
responseHeaders,
|
|
483
486
|
value: responseBody,
|
|
484
487
|
rawValue: rawResponse
|
|
485
|
-
} = await
|
|
488
|
+
} = await postJsonToApi({
|
|
486
489
|
url: this.config.url({
|
|
487
490
|
path: "/chat/completions",
|
|
488
491
|
modelId: this.modelId
|
|
489
492
|
}),
|
|
490
|
-
headers: (
|
|
493
|
+
headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
|
|
491
494
|
body: args,
|
|
492
495
|
failedResponseHandler: this.failedResponseHandler,
|
|
493
|
-
successfulResponseHandler:
|
|
496
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
494
497
|
deepseekChatResponseSchema
|
|
495
498
|
),
|
|
496
499
|
abortSignal: options.abortSignal,
|
|
@@ -509,7 +512,7 @@ var DeepSeekChatLanguageModel = class {
|
|
|
509
512
|
for (const toolCall of choice.message.tool_calls) {
|
|
510
513
|
content.push({
|
|
511
514
|
type: "tool-call",
|
|
512
|
-
toolCallId: (
|
|
515
|
+
toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
|
|
513
516
|
toolName: toolCall.function.name,
|
|
514
517
|
input: toolCall.function.arguments
|
|
515
518
|
});
|
|
@@ -523,13 +526,13 @@ var DeepSeekChatLanguageModel = class {
|
|
|
523
526
|
content,
|
|
524
527
|
finishReason: {
|
|
525
528
|
unified: mapDeepSeekFinishReason(choice.finish_reason),
|
|
526
|
-
raw: (
|
|
529
|
+
raw: (_d = choice.finish_reason) != null ? _d : void 0
|
|
527
530
|
},
|
|
528
531
|
usage: convertDeepSeekUsage(responseBody.usage),
|
|
529
532
|
providerMetadata: {
|
|
530
533
|
[this.providerOptionsName]: {
|
|
531
|
-
promptCacheHitTokens: (
|
|
532
|
-
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
|
|
533
536
|
}
|
|
534
537
|
},
|
|
535
538
|
request: { body: args },
|
|
@@ -542,27 +545,28 @@ var DeepSeekChatLanguageModel = class {
|
|
|
542
545
|
};
|
|
543
546
|
}
|
|
544
547
|
async doStream(options) {
|
|
548
|
+
var _a, _b;
|
|
545
549
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
546
550
|
const body = {
|
|
547
551
|
...args,
|
|
548
552
|
stream: true,
|
|
549
553
|
stream_options: { include_usage: true }
|
|
550
554
|
};
|
|
551
|
-
const { responseHeaders, value: response } = await
|
|
555
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
552
556
|
url: this.config.url({
|
|
553
557
|
path: "/chat/completions",
|
|
554
558
|
modelId: this.modelId
|
|
555
559
|
}),
|
|
556
|
-
headers: (
|
|
560
|
+
headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
|
|
557
561
|
body,
|
|
558
562
|
failedResponseHandler: this.failedResponseHandler,
|
|
559
|
-
successfulResponseHandler:
|
|
563
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
560
564
|
deepseekChatChunkSchema
|
|
561
565
|
),
|
|
562
566
|
abortSignal: options.abortSignal,
|
|
563
567
|
fetch: this.config.fetch
|
|
564
568
|
});
|
|
565
|
-
|
|
569
|
+
let toolCallTracker;
|
|
566
570
|
let finishReason = {
|
|
567
571
|
unified: "other",
|
|
568
572
|
raw: void 0
|
|
@@ -576,10 +580,12 @@ var DeepSeekChatLanguageModel = class {
|
|
|
576
580
|
stream: response.pipeThrough(
|
|
577
581
|
new TransformStream({
|
|
578
582
|
start(controller) {
|
|
583
|
+
toolCallTracker = new StreamingToolCallTracker(controller, {
|
|
584
|
+
generateId
|
|
585
|
+
});
|
|
579
586
|
controller.enqueue({ type: "stream-start", warnings });
|
|
580
587
|
},
|
|
581
588
|
transform(chunk, controller) {
|
|
582
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
583
589
|
if (options.includeRawChunks) {
|
|
584
590
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
585
591
|
}
|
|
@@ -657,117 +663,27 @@ var DeepSeekChatLanguageModel = class {
|
|
|
657
663
|
isActiveReasoning = false;
|
|
658
664
|
}
|
|
659
665
|
for (const toolCallDelta of delta.tool_calls) {
|
|
660
|
-
|
|
661
|
-
if (toolCalls[index] == null) {
|
|
662
|
-
if (toolCallDelta.id == null) {
|
|
663
|
-
throw new import_provider.InvalidResponseDataError({
|
|
664
|
-
data: toolCallDelta,
|
|
665
|
-
message: `Expected 'id' to be a string.`
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
if (((_a = toolCallDelta.function) == null ? void 0 : _a.name) == null) {
|
|
669
|
-
throw new import_provider.InvalidResponseDataError({
|
|
670
|
-
data: toolCallDelta,
|
|
671
|
-
message: `Expected 'function.name' to be a string.`
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
controller.enqueue({
|
|
675
|
-
type: "tool-input-start",
|
|
676
|
-
id: toolCallDelta.id,
|
|
677
|
-
toolName: toolCallDelta.function.name
|
|
678
|
-
});
|
|
679
|
-
toolCalls[index] = {
|
|
680
|
-
id: toolCallDelta.id,
|
|
681
|
-
type: "function",
|
|
682
|
-
function: {
|
|
683
|
-
name: toolCallDelta.function.name,
|
|
684
|
-
arguments: (_b = toolCallDelta.function.arguments) != null ? _b : ""
|
|
685
|
-
},
|
|
686
|
-
hasFinished: false
|
|
687
|
-
};
|
|
688
|
-
const toolCall2 = toolCalls[index];
|
|
689
|
-
if (((_c = toolCall2.function) == null ? void 0 : _c.name) != null && ((_d = toolCall2.function) == null ? void 0 : _d.arguments) != null) {
|
|
690
|
-
if (toolCall2.function.arguments.length > 0) {
|
|
691
|
-
controller.enqueue({
|
|
692
|
-
type: "tool-input-delta",
|
|
693
|
-
id: toolCall2.id,
|
|
694
|
-
delta: toolCall2.function.arguments
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
if ((0, import_provider_utils2.isParsableJson)(toolCall2.function.arguments)) {
|
|
698
|
-
controller.enqueue({
|
|
699
|
-
type: "tool-input-end",
|
|
700
|
-
id: toolCall2.id
|
|
701
|
-
});
|
|
702
|
-
controller.enqueue({
|
|
703
|
-
type: "tool-call",
|
|
704
|
-
toolCallId: (_e = toolCall2.id) != null ? _e : (0, import_provider_utils2.generateId)(),
|
|
705
|
-
toolName: toolCall2.function.name,
|
|
706
|
-
input: toolCall2.function.arguments
|
|
707
|
-
});
|
|
708
|
-
toolCall2.hasFinished = true;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
continue;
|
|
712
|
-
}
|
|
713
|
-
const toolCall = toolCalls[index];
|
|
714
|
-
if (toolCall.hasFinished) {
|
|
715
|
-
continue;
|
|
716
|
-
}
|
|
717
|
-
if (((_f = toolCallDelta.function) == null ? void 0 : _f.arguments) != null) {
|
|
718
|
-
toolCall.function.arguments += (_h = (_g = toolCallDelta.function) == null ? void 0 : _g.arguments) != null ? _h : "";
|
|
719
|
-
}
|
|
720
|
-
controller.enqueue({
|
|
721
|
-
type: "tool-input-delta",
|
|
722
|
-
id: toolCall.id,
|
|
723
|
-
delta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
|
|
724
|
-
});
|
|
725
|
-
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)) {
|
|
726
|
-
controller.enqueue({
|
|
727
|
-
type: "tool-input-end",
|
|
728
|
-
id: toolCall.id
|
|
729
|
-
});
|
|
730
|
-
controller.enqueue({
|
|
731
|
-
type: "tool-call",
|
|
732
|
-
toolCallId: (_l = toolCall.id) != null ? _l : (0, import_provider_utils2.generateId)(),
|
|
733
|
-
toolName: toolCall.function.name,
|
|
734
|
-
input: toolCall.function.arguments
|
|
735
|
-
});
|
|
736
|
-
toolCall.hasFinished = true;
|
|
737
|
-
}
|
|
666
|
+
toolCallTracker.processDelta(toolCallDelta);
|
|
738
667
|
}
|
|
739
668
|
}
|
|
740
669
|
},
|
|
741
670
|
flush(controller) {
|
|
742
|
-
var
|
|
671
|
+
var _a2, _b2;
|
|
743
672
|
if (isActiveReasoning) {
|
|
744
673
|
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
745
674
|
}
|
|
746
675
|
if (isActiveText) {
|
|
747
676
|
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
748
677
|
}
|
|
749
|
-
|
|
750
|
-
(toolCall2) => !toolCall2.hasFinished
|
|
751
|
-
)) {
|
|
752
|
-
controller.enqueue({
|
|
753
|
-
type: "tool-input-end",
|
|
754
|
-
id: toolCall.id
|
|
755
|
-
});
|
|
756
|
-
controller.enqueue({
|
|
757
|
-
type: "tool-call",
|
|
758
|
-
toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils2.generateId)(),
|
|
759
|
-
toolName: toolCall.function.name,
|
|
760
|
-
input: toolCall.function.arguments
|
|
761
|
-
});
|
|
762
|
-
}
|
|
678
|
+
toolCallTracker.flush();
|
|
763
679
|
controller.enqueue({
|
|
764
680
|
type: "finish",
|
|
765
681
|
finishReason,
|
|
766
682
|
usage: convertDeepSeekUsage(usage),
|
|
767
683
|
providerMetadata: {
|
|
768
684
|
[providerOptionsName]: {
|
|
769
|
-
promptCacheHitTokens: (
|
|
770
|
-
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
|
|
771
687
|
}
|
|
772
688
|
}
|
|
773
689
|
});
|
|
@@ -781,17 +697,17 @@ var DeepSeekChatLanguageModel = class {
|
|
|
781
697
|
};
|
|
782
698
|
|
|
783
699
|
// src/version.ts
|
|
784
|
-
var VERSION = true ? "3.0.0-beta.
|
|
700
|
+
var VERSION = true ? "3.0.0-beta.31" : "0.0.0-test";
|
|
785
701
|
|
|
786
702
|
// src/deepseek-provider.ts
|
|
787
703
|
function createDeepSeek(options = {}) {
|
|
788
704
|
var _a;
|
|
789
|
-
const baseURL =
|
|
705
|
+
const baseURL = withoutTrailingSlash(
|
|
790
706
|
(_a = options.baseURL) != null ? _a : "https://api.deepseek.com"
|
|
791
707
|
);
|
|
792
|
-
const getHeaders = () =>
|
|
708
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
793
709
|
{
|
|
794
|
-
Authorization: `Bearer ${
|
|
710
|
+
Authorization: `Bearer ${loadApiKey({
|
|
795
711
|
apiKey: options.apiKey,
|
|
796
712
|
environmentVariableName: "DEEPSEEK_API_KEY",
|
|
797
713
|
description: "DeepSeek API key"
|
|
@@ -809,23 +725,22 @@ function createDeepSeek(options = {}) {
|
|
|
809
725
|
});
|
|
810
726
|
};
|
|
811
727
|
const provider = (modelId) => createLanguageModel(modelId);
|
|
812
|
-
provider.specificationVersion = "
|
|
728
|
+
provider.specificationVersion = "v4";
|
|
813
729
|
provider.languageModel = createLanguageModel;
|
|
814
730
|
provider.chat = createLanguageModel;
|
|
815
731
|
provider.embeddingModel = (modelId) => {
|
|
816
|
-
throw new
|
|
732
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
817
733
|
};
|
|
818
734
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
819
735
|
provider.imageModel = (modelId) => {
|
|
820
|
-
throw new
|
|
736
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
821
737
|
};
|
|
822
738
|
return provider;
|
|
823
739
|
}
|
|
824
740
|
var deepseek = createDeepSeek();
|
|
825
|
-
|
|
826
|
-
0 && (module.exports = {
|
|
741
|
+
export {
|
|
827
742
|
VERSION,
|
|
828
743
|
createDeepSeek,
|
|
829
744
|
deepseek
|
|
830
|
-
}
|
|
745
|
+
};
|
|
831
746
|
//# sourceMappingURL=index.js.map
|