@ai-sdk/deepseek 3.0.0-beta.4 → 3.0.0-beta.55
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 +417 -4
- package/README.md +2 -0
- package/dist/index.d.ts +17 -9
- package/dist/index.js +171 -227
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +57 -0
- package/dist/{index.mjs → internal/index.js} +84 -183
- package/dist/internal/index.js.map +1 -0
- package/docs/30-deepseek.mdx +31 -19
- package/internal.d.ts +1 -0
- package/package.json +21 -15
- package/src/chat/convert-to-deepseek-chat-messages.ts +18 -12
- package/src/chat/convert-to-deepseek-usage.ts +2 -2
- package/src/chat/deepseek-chat-language-model-options.ts +34 -0
- package/src/chat/deepseek-chat-language-model.ts +95 -172
- package/src/chat/deepseek-prepare-tools.ts +9 -6
- package/src/chat/map-deepseek-finish-reason.ts +2 -2
- package/src/deepseek-provider.ts +10 -10
- package/src/index.ts +12 -5
- package/src/internal/index.ts +2 -0
- package/dist/index.d.mts +0 -68
- package/dist/index.mjs.map +0 -1
- package/src/chat/deepseek-chat-options.ts +0 -22
|
@@ -1,53 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
APICallError,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
LanguageModelV4,
|
|
4
|
+
LanguageModelV4CallOptions,
|
|
5
|
+
LanguageModelV4Content,
|
|
6
|
+
LanguageModelV4FinishReason,
|
|
7
|
+
LanguageModelV4GenerateResult,
|
|
8
|
+
LanguageModelV4StreamPart,
|
|
9
|
+
LanguageModelV4StreamResult,
|
|
10
|
+
SharedV4Warning,
|
|
11
11
|
} from '@ai-sdk/provider';
|
|
12
12
|
import {
|
|
13
13
|
combineHeaders,
|
|
14
14
|
createEventSourceResponseHandler,
|
|
15
15
|
createJsonErrorResponseHandler,
|
|
16
16
|
createJsonResponseHandler,
|
|
17
|
-
FetchFunction,
|
|
18
17
|
generateId,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
isCustomReasoning,
|
|
19
|
+
mapReasoningToProviderEffort,
|
|
21
20
|
parseProviderOptions,
|
|
22
|
-
ParseResult,
|
|
23
21
|
postJsonToApi,
|
|
24
|
-
|
|
22
|
+
serializeModelOptions,
|
|
23
|
+
StreamingToolCallTracker,
|
|
24
|
+
WORKFLOW_SERIALIZE,
|
|
25
|
+
WORKFLOW_DESERIALIZE,
|
|
26
|
+
type FetchFunction,
|
|
27
|
+
type InferSchema,
|
|
28
|
+
type ParseResult,
|
|
29
|
+
type ResponseHandler,
|
|
25
30
|
} from '@ai-sdk/provider-utils';
|
|
26
31
|
import { convertToDeepSeekChatMessages } from './convert-to-deepseek-chat-messages';
|
|
27
32
|
import { convertDeepSeekUsage } from './convert-to-deepseek-usage';
|
|
28
33
|
import {
|
|
29
34
|
deepseekChatChunkSchema,
|
|
30
35
|
deepseekChatResponseSchema,
|
|
31
|
-
DeepSeekChatTokenUsage,
|
|
32
36
|
deepSeekErrorSchema,
|
|
37
|
+
type DeepSeekChatTokenUsage,
|
|
33
38
|
} from './deepseek-chat-api-types';
|
|
34
39
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from './deepseek-chat-options';
|
|
40
|
+
deepseekLanguageModelChatOptions,
|
|
41
|
+
type DeepSeekChatModelId,
|
|
42
|
+
} from './deepseek-chat-language-model-options';
|
|
38
43
|
import { prepareTools } from './deepseek-prepare-tools';
|
|
39
44
|
import { getResponseMetadata } from './get-response-metadata';
|
|
40
45
|
import { mapDeepSeekFinishReason } from './map-deepseek-finish-reason';
|
|
41
46
|
|
|
42
47
|
export type DeepSeekChatConfig = {
|
|
43
48
|
provider: string;
|
|
44
|
-
headers
|
|
49
|
+
headers?: () => Record<string, string | undefined>;
|
|
45
50
|
url: (options: { modelId: string; path: string }) => string;
|
|
46
51
|
fetch?: FetchFunction;
|
|
52
|
+
supportsThinking?: boolean;
|
|
47
53
|
};
|
|
48
54
|
|
|
49
|
-
export class DeepSeekChatLanguageModel implements
|
|
50
|
-
readonly specificationVersion = '
|
|
55
|
+
export class DeepSeekChatLanguageModel implements LanguageModelV4 {
|
|
56
|
+
readonly specificationVersion = 'v4';
|
|
51
57
|
|
|
52
58
|
readonly modelId: DeepSeekChatModelId;
|
|
53
59
|
readonly supportedUrls = {};
|
|
@@ -55,6 +61,20 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
55
61
|
private readonly config: DeepSeekChatConfig;
|
|
56
62
|
private readonly failedResponseHandler: ResponseHandler<APICallError>;
|
|
57
63
|
|
|
64
|
+
static [WORKFLOW_SERIALIZE](model: DeepSeekChatLanguageModel) {
|
|
65
|
+
return serializeModelOptions({
|
|
66
|
+
modelId: model.modelId,
|
|
67
|
+
config: model.config,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
72
|
+
modelId: DeepSeekChatModelId;
|
|
73
|
+
config: DeepSeekChatConfig;
|
|
74
|
+
}) {
|
|
75
|
+
return new DeepSeekChatLanguageModel(options.modelId, options.config);
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
constructor(modelId: DeepSeekChatModelId, config: DeepSeekChatConfig) {
|
|
59
79
|
this.modelId = modelId;
|
|
60
80
|
this.config = config;
|
|
@@ -82,31 +102,34 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
82
102
|
topK,
|
|
83
103
|
frequencyPenalty,
|
|
84
104
|
presencePenalty,
|
|
105
|
+
reasoning,
|
|
85
106
|
providerOptions,
|
|
86
107
|
stopSequences,
|
|
87
108
|
responseFormat,
|
|
88
109
|
seed,
|
|
89
110
|
toolChoice,
|
|
90
111
|
tools,
|
|
91
|
-
}:
|
|
112
|
+
}: LanguageModelV4CallOptions) {
|
|
92
113
|
const deepseekOptions =
|
|
93
114
|
(await parseProviderOptions({
|
|
94
115
|
provider: this.providerOptionsName,
|
|
95
116
|
providerOptions,
|
|
96
|
-
schema:
|
|
117
|
+
schema: deepseekLanguageModelChatOptions,
|
|
97
118
|
})) ?? {};
|
|
98
119
|
|
|
99
120
|
const { messages, warnings } = convertToDeepSeekChatMessages({
|
|
100
121
|
prompt,
|
|
101
122
|
responseFormat,
|
|
123
|
+
modelId: this.modelId,
|
|
102
124
|
});
|
|
125
|
+
const allWarnings: SharedV4Warning[] = [...warnings];
|
|
103
126
|
|
|
104
127
|
if (topK != null) {
|
|
105
|
-
|
|
128
|
+
allWarnings.push({ type: 'unsupported', feature: 'topK' });
|
|
106
129
|
}
|
|
107
130
|
|
|
108
131
|
if (seed != null) {
|
|
109
|
-
|
|
132
|
+
allWarnings.push({ type: 'unsupported', feature: 'seed' });
|
|
110
133
|
}
|
|
111
134
|
|
|
112
135
|
const {
|
|
@@ -118,6 +141,31 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
118
141
|
toolChoice,
|
|
119
142
|
});
|
|
120
143
|
|
|
144
|
+
const thinking =
|
|
145
|
+
this.config.supportsThinking === false
|
|
146
|
+
? undefined
|
|
147
|
+
: deepseekOptions.thinking?.type != null
|
|
148
|
+
? { type: deepseekOptions.thinking.type }
|
|
149
|
+
: isCustomReasoning(reasoning)
|
|
150
|
+
? { type: reasoning === 'none' ? 'disabled' : 'enabled' }
|
|
151
|
+
: undefined;
|
|
152
|
+
|
|
153
|
+
const reasoningEffort =
|
|
154
|
+
deepseekOptions.reasoningEffort ??
|
|
155
|
+
(isCustomReasoning(reasoning) && reasoning !== 'none'
|
|
156
|
+
? mapReasoningToProviderEffort({
|
|
157
|
+
reasoning,
|
|
158
|
+
effortMap: {
|
|
159
|
+
minimal: 'low',
|
|
160
|
+
low: 'low',
|
|
161
|
+
medium: 'medium',
|
|
162
|
+
high: 'high',
|
|
163
|
+
xhigh: 'max',
|
|
164
|
+
},
|
|
165
|
+
warnings: allWarnings,
|
|
166
|
+
})
|
|
167
|
+
: undefined);
|
|
168
|
+
|
|
121
169
|
return {
|
|
122
170
|
args: {
|
|
123
171
|
model: this.modelId,
|
|
@@ -132,18 +180,19 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
132
180
|
messages,
|
|
133
181
|
tools: deepseekTools,
|
|
134
182
|
tool_choice: deepseekToolChoices,
|
|
135
|
-
thinking
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
:
|
|
183
|
+
thinking,
|
|
184
|
+
...(thinking?.type !== 'disabled' &&
|
|
185
|
+
reasoningEffort != null && {
|
|
186
|
+
reasoning_effort: reasoningEffort,
|
|
187
|
+
}),
|
|
139
188
|
},
|
|
140
|
-
warnings: [...
|
|
189
|
+
warnings: [...allWarnings, ...toolWarnings],
|
|
141
190
|
};
|
|
142
191
|
}
|
|
143
192
|
|
|
144
193
|
async doGenerate(
|
|
145
|
-
options:
|
|
146
|
-
): Promise<
|
|
194
|
+
options: LanguageModelV4CallOptions,
|
|
195
|
+
): Promise<LanguageModelV4GenerateResult> {
|
|
147
196
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
148
197
|
|
|
149
198
|
const {
|
|
@@ -155,7 +204,7 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
155
204
|
path: '/chat/completions',
|
|
156
205
|
modelId: this.modelId,
|
|
157
206
|
}),
|
|
158
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
207
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
159
208
|
body: args,
|
|
160
209
|
failedResponseHandler: this.failedResponseHandler,
|
|
161
210
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -166,7 +215,7 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
166
215
|
});
|
|
167
216
|
|
|
168
217
|
const choice = responseBody.choices[0];
|
|
169
|
-
const content: Array<
|
|
218
|
+
const content: Array<LanguageModelV4Content> = [];
|
|
170
219
|
|
|
171
220
|
// reasoning content (before text):
|
|
172
221
|
const reasoning = choice.message.reasoning_content;
|
|
@@ -219,8 +268,8 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
219
268
|
}
|
|
220
269
|
|
|
221
270
|
async doStream(
|
|
222
|
-
options:
|
|
223
|
-
): Promise<
|
|
271
|
+
options: LanguageModelV4CallOptions,
|
|
272
|
+
): Promise<LanguageModelV4StreamResult> {
|
|
224
273
|
const { args, warnings } = await this.getArgs({ ...options });
|
|
225
274
|
|
|
226
275
|
const body = {
|
|
@@ -234,7 +283,7 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
234
283
|
path: '/chat/completions',
|
|
235
284
|
modelId: this.modelId,
|
|
236
285
|
}),
|
|
237
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
286
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
238
287
|
body,
|
|
239
288
|
failedResponseHandler: this.failedResponseHandler,
|
|
240
289
|
successfulResponseHandler: createEventSourceResponseHandler(
|
|
@@ -244,17 +293,9 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
244
293
|
fetch: this.config.fetch,
|
|
245
294
|
});
|
|
246
295
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
function: {
|
|
251
|
-
name: string;
|
|
252
|
-
arguments: string;
|
|
253
|
-
};
|
|
254
|
-
hasFinished: boolean;
|
|
255
|
-
}> = [];
|
|
256
|
-
|
|
257
|
-
let finishReason: LanguageModelV3FinishReason = {
|
|
296
|
+
let toolCallTracker: StreamingToolCallTracker;
|
|
297
|
+
|
|
298
|
+
let finishReason: LanguageModelV4FinishReason = {
|
|
258
299
|
unified: 'other',
|
|
259
300
|
raw: undefined,
|
|
260
301
|
};
|
|
@@ -268,9 +309,12 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
268
309
|
stream: response.pipeThrough(
|
|
269
310
|
new TransformStream<
|
|
270
311
|
ParseResult<InferSchema<typeof deepseekChatChunkSchema>>,
|
|
271
|
-
|
|
312
|
+
LanguageModelV4StreamPart
|
|
272
313
|
>({
|
|
273
314
|
start(controller) {
|
|
315
|
+
toolCallTracker = new StreamingToolCallTracker(controller, {
|
|
316
|
+
generateId,
|
|
317
|
+
});
|
|
274
318
|
controller.enqueue({ type: 'stream-start', warnings });
|
|
275
319
|
},
|
|
276
320
|
|
|
@@ -374,113 +418,7 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
374
418
|
}
|
|
375
419
|
|
|
376
420
|
for (const toolCallDelta of delta.tool_calls) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
if (toolCalls[index] == null) {
|
|
380
|
-
if (toolCallDelta.id == null) {
|
|
381
|
-
throw new InvalidResponseDataError({
|
|
382
|
-
data: toolCallDelta,
|
|
383
|
-
message: `Expected 'id' to be a string.`,
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (toolCallDelta.function?.name == null) {
|
|
388
|
-
throw new InvalidResponseDataError({
|
|
389
|
-
data: toolCallDelta,
|
|
390
|
-
message: `Expected 'function.name' to be a string.`,
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
controller.enqueue({
|
|
395
|
-
type: 'tool-input-start',
|
|
396
|
-
id: toolCallDelta.id,
|
|
397
|
-
toolName: toolCallDelta.function.name,
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
toolCalls[index] = {
|
|
401
|
-
id: toolCallDelta.id,
|
|
402
|
-
type: 'function',
|
|
403
|
-
function: {
|
|
404
|
-
name: toolCallDelta.function.name,
|
|
405
|
-
arguments: toolCallDelta.function.arguments ?? '',
|
|
406
|
-
},
|
|
407
|
-
hasFinished: false,
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
const toolCall = toolCalls[index];
|
|
411
|
-
|
|
412
|
-
if (
|
|
413
|
-
toolCall.function?.name != null &&
|
|
414
|
-
toolCall.function?.arguments != null
|
|
415
|
-
) {
|
|
416
|
-
// send delta if the argument text has already started:
|
|
417
|
-
if (toolCall.function.arguments.length > 0) {
|
|
418
|
-
controller.enqueue({
|
|
419
|
-
type: 'tool-input-delta',
|
|
420
|
-
id: toolCall.id,
|
|
421
|
-
delta: toolCall.function.arguments,
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// check if tool call is complete
|
|
426
|
-
// (some providers send the full tool call in one chunk):
|
|
427
|
-
if (isParsableJson(toolCall.function.arguments)) {
|
|
428
|
-
controller.enqueue({
|
|
429
|
-
type: 'tool-input-end',
|
|
430
|
-
id: toolCall.id,
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
controller.enqueue({
|
|
434
|
-
type: 'tool-call',
|
|
435
|
-
toolCallId: toolCall.id ?? generateId(),
|
|
436
|
-
toolName: toolCall.function.name,
|
|
437
|
-
input: toolCall.function.arguments,
|
|
438
|
-
});
|
|
439
|
-
toolCall.hasFinished = true;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
continue;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// existing tool call, merge if not finished
|
|
447
|
-
const toolCall = toolCalls[index];
|
|
448
|
-
|
|
449
|
-
if (toolCall.hasFinished) {
|
|
450
|
-
continue;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (toolCallDelta.function?.arguments != null) {
|
|
454
|
-
toolCall.function!.arguments +=
|
|
455
|
-
toolCallDelta.function?.arguments ?? '';
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// send delta
|
|
459
|
-
controller.enqueue({
|
|
460
|
-
type: 'tool-input-delta',
|
|
461
|
-
id: toolCall.id,
|
|
462
|
-
delta: toolCallDelta.function.arguments ?? '',
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
// check if tool call is complete
|
|
466
|
-
if (
|
|
467
|
-
toolCall.function?.name != null &&
|
|
468
|
-
toolCall.function?.arguments != null &&
|
|
469
|
-
isParsableJson(toolCall.function.arguments)
|
|
470
|
-
) {
|
|
471
|
-
controller.enqueue({
|
|
472
|
-
type: 'tool-input-end',
|
|
473
|
-
id: toolCall.id,
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
controller.enqueue({
|
|
477
|
-
type: 'tool-call',
|
|
478
|
-
toolCallId: toolCall.id ?? generateId(),
|
|
479
|
-
toolName: toolCall.function.name,
|
|
480
|
-
input: toolCall.function.arguments,
|
|
481
|
-
});
|
|
482
|
-
toolCall.hasFinished = true;
|
|
483
|
-
}
|
|
421
|
+
toolCallTracker.processDelta(toolCallDelta);
|
|
484
422
|
}
|
|
485
423
|
}
|
|
486
424
|
},
|
|
@@ -494,22 +432,7 @@ export class DeepSeekChatLanguageModel implements LanguageModelV3 {
|
|
|
494
432
|
controller.enqueue({ type: 'text-end', id: 'txt-0' });
|
|
495
433
|
}
|
|
496
434
|
|
|
497
|
-
|
|
498
|
-
for (const toolCall of toolCalls.filter(
|
|
499
|
-
toolCall => !toolCall.hasFinished,
|
|
500
|
-
)) {
|
|
501
|
-
controller.enqueue({
|
|
502
|
-
type: 'tool-input-end',
|
|
503
|
-
id: toolCall.id,
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
controller.enqueue({
|
|
507
|
-
type: 'tool-call',
|
|
508
|
-
toolCallId: toolCall.id ?? generateId(),
|
|
509
|
-
toolName: toolCall.function.name,
|
|
510
|
-
input: toolCall.function.arguments,
|
|
511
|
-
});
|
|
512
|
-
}
|
|
435
|
+
toolCallTracker.flush();
|
|
513
436
|
|
|
514
437
|
controller.enqueue({
|
|
515
438
|
type: 'finish',
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
LanguageModelV4CallOptions,
|
|
3
|
+
SharedV4Warning,
|
|
4
|
+
} from '@ai-sdk/provider';
|
|
5
|
+
import type {
|
|
3
6
|
DeepSeekFunctionTool,
|
|
4
7
|
DeepSeekToolChoice,
|
|
5
8
|
} from './deepseek-chat-api-types';
|
|
@@ -8,17 +11,17 @@ export function prepareTools({
|
|
|
8
11
|
tools,
|
|
9
12
|
toolChoice,
|
|
10
13
|
}: {
|
|
11
|
-
tools:
|
|
12
|
-
toolChoice?:
|
|
14
|
+
tools: LanguageModelV4CallOptions['tools'];
|
|
15
|
+
toolChoice?: LanguageModelV4CallOptions['toolChoice'];
|
|
13
16
|
}): {
|
|
14
17
|
tools: undefined | Array<DeepSeekFunctionTool>;
|
|
15
18
|
toolChoice: DeepSeekToolChoice;
|
|
16
|
-
toolWarnings:
|
|
19
|
+
toolWarnings: SharedV4Warning[];
|
|
17
20
|
} {
|
|
18
21
|
// when the tools array is empty, change it to undefined to prevent errors:
|
|
19
22
|
tools = tools?.length ? tools : undefined;
|
|
20
23
|
|
|
21
|
-
const toolWarnings:
|
|
24
|
+
const toolWarnings: SharedV4Warning[] = [];
|
|
22
25
|
|
|
23
26
|
if (tools == null) {
|
|
24
27
|
return { tools: undefined, toolChoice: undefined, toolWarnings };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';
|
|
2
2
|
|
|
3
3
|
export function mapDeepSeekFinishReason(
|
|
4
4
|
finishReason: string | null | undefined,
|
|
5
|
-
):
|
|
5
|
+
): LanguageModelV4FinishReason['unified'] {
|
|
6
6
|
switch (finishReason) {
|
|
7
7
|
case 'stop':
|
|
8
8
|
return 'stop';
|
package/src/deepseek-provider.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LanguageModelV3,
|
|
3
2
|
NoSuchModelError,
|
|
4
|
-
|
|
3
|
+
type LanguageModelV4,
|
|
4
|
+
type ProviderV4,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
6
|
import {
|
|
7
|
-
FetchFunction,
|
|
8
7
|
loadApiKey,
|
|
9
8
|
withoutTrailingSlash,
|
|
10
9
|
withUserAgentSuffix,
|
|
10
|
+
type FetchFunction,
|
|
11
11
|
} from '@ai-sdk/provider-utils';
|
|
12
|
-
import { DeepSeekChatModelId } from './chat/deepseek-chat-options';
|
|
12
|
+
import type { DeepSeekChatModelId } from './chat/deepseek-chat-language-model-options';
|
|
13
13
|
import { DeepSeekChatLanguageModel } from './chat/deepseek-chat-language-model';
|
|
14
14
|
import { VERSION } from './version';
|
|
15
15
|
|
|
@@ -36,21 +36,21 @@ export interface DeepSeekProviderSettings {
|
|
|
36
36
|
fetch?: FetchFunction;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export interface DeepSeekProvider extends
|
|
39
|
+
export interface DeepSeekProvider extends ProviderV4 {
|
|
40
40
|
/**
|
|
41
41
|
* Creates a DeepSeek model for text generation.
|
|
42
42
|
*/
|
|
43
|
-
(modelId: DeepSeekChatModelId):
|
|
43
|
+
(modelId: DeepSeekChatModelId): LanguageModelV4;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Creates a DeepSeek model for text generation.
|
|
47
47
|
*/
|
|
48
|
-
languageModel(modelId: DeepSeekChatModelId):
|
|
48
|
+
languageModel(modelId: DeepSeekChatModelId): LanguageModelV4;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Creates a DeepSeek chat model for text generation.
|
|
52
52
|
*/
|
|
53
|
-
chat(modelId: DeepSeekChatModelId):
|
|
53
|
+
chat(modelId: DeepSeekChatModelId): LanguageModelV4;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* @deprecated Use `embeddingModel` instead.
|
|
@@ -90,7 +90,7 @@ export function createDeepSeek(
|
|
|
90
90
|
const provider = (modelId: DeepSeekChatModelId) =>
|
|
91
91
|
createLanguageModel(modelId);
|
|
92
92
|
|
|
93
|
-
provider.specificationVersion = '
|
|
93
|
+
provider.specificationVersion = 'v4' as const;
|
|
94
94
|
provider.languageModel = createLanguageModel;
|
|
95
95
|
provider.chat = createLanguageModel;
|
|
96
96
|
|
|
@@ -105,4 +105,4 @@ export function createDeepSeek(
|
|
|
105
105
|
return provider;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export const
|
|
108
|
+
export const deepSeek = createDeepSeek();
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
createDeepSeek,
|
|
3
|
+
deepSeek,
|
|
4
|
+
/** @deprecated Use `deepSeek` instead. */
|
|
5
|
+
deepSeek as deepseek,
|
|
6
|
+
} from './deepseek-provider';
|
|
2
7
|
export type {
|
|
3
8
|
DeepSeekProvider,
|
|
4
9
|
DeepSeekProviderSettings,
|
|
5
10
|
} from './deepseek-provider';
|
|
6
11
|
export { VERSION } from './version';
|
|
7
12
|
export type {
|
|
8
|
-
|
|
9
|
-
/** @deprecated Use `
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
DeepSeekLanguageModelChatOptions,
|
|
14
|
+
/** @deprecated Use `DeepSeekLanguageModelChatOptions` instead. */
|
|
15
|
+
DeepSeekLanguageModelChatOptions as DeepSeekLanguageModelOptions,
|
|
16
|
+
/** @deprecated Use `DeepSeekLanguageModelChatOptions` instead. */
|
|
17
|
+
DeepSeekLanguageModelChatOptions as DeepSeekChatOptions,
|
|
18
|
+
} from './chat/deepseek-chat-language-model-options';
|
|
12
19
|
export type { DeepSeekErrorData } from './chat/deepseek-chat-api-types';
|
package/dist/index.d.mts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
2
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { z } from 'zod/v4';
|
|
4
|
-
|
|
5
|
-
type DeepSeekChatModelId = 'deepseek-chat' | 'deepseek-reasoner' | (string & {});
|
|
6
|
-
declare const deepseekLanguageModelOptions: z.ZodObject<{
|
|
7
|
-
thinking: z.ZodOptional<z.ZodObject<{
|
|
8
|
-
type: z.ZodOptional<z.ZodEnum<{
|
|
9
|
-
enabled: "enabled";
|
|
10
|
-
disabled: "disabled";
|
|
11
|
-
}>>;
|
|
12
|
-
}, z.core.$strip>>;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
type DeepSeekLanguageModelOptions = z.infer<typeof deepseekLanguageModelOptions>;
|
|
15
|
-
|
|
16
|
-
interface DeepSeekProviderSettings {
|
|
17
|
-
/**
|
|
18
|
-
* DeepSeek API key.
|
|
19
|
-
*/
|
|
20
|
-
apiKey?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Base URL for the API calls.
|
|
23
|
-
*/
|
|
24
|
-
baseURL?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Custom headers to include in the requests.
|
|
27
|
-
*/
|
|
28
|
-
headers?: Record<string, string>;
|
|
29
|
-
/**
|
|
30
|
-
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
31
|
-
* or to provide a custom fetch implementation for e.g. testing.
|
|
32
|
-
*/
|
|
33
|
-
fetch?: FetchFunction;
|
|
34
|
-
}
|
|
35
|
-
interface DeepSeekProvider extends ProviderV3 {
|
|
36
|
-
/**
|
|
37
|
-
* Creates a DeepSeek model for text generation.
|
|
38
|
-
*/
|
|
39
|
-
(modelId: DeepSeekChatModelId): LanguageModelV3;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a DeepSeek model for text generation.
|
|
42
|
-
*/
|
|
43
|
-
languageModel(modelId: DeepSeekChatModelId): LanguageModelV3;
|
|
44
|
-
/**
|
|
45
|
-
* Creates a DeepSeek chat model for text generation.
|
|
46
|
-
*/
|
|
47
|
-
chat(modelId: DeepSeekChatModelId): LanguageModelV3;
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated Use `embeddingModel` instead.
|
|
50
|
-
*/
|
|
51
|
-
textEmbeddingModel(modelId: string): never;
|
|
52
|
-
}
|
|
53
|
-
declare function createDeepSeek(options?: DeepSeekProviderSettings): DeepSeekProvider;
|
|
54
|
-
declare const deepseek: DeepSeekProvider;
|
|
55
|
-
|
|
56
|
-
declare const VERSION: string;
|
|
57
|
-
|
|
58
|
-
declare const deepSeekErrorSchema: z.ZodObject<{
|
|
59
|
-
error: z.ZodObject<{
|
|
60
|
-
message: z.ZodString;
|
|
61
|
-
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
62
|
-
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
63
|
-
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
64
|
-
}, z.core.$strip>;
|
|
65
|
-
}, z.core.$strip>;
|
|
66
|
-
type DeepSeekErrorData = z.infer<typeof deepSeekErrorSchema>;
|
|
67
|
-
|
|
68
|
-
export { type DeepSeekLanguageModelOptions as DeepSeekChatOptions, type DeepSeekErrorData, type DeepSeekLanguageModelOptions, type DeepSeekProvider, type DeepSeekProviderSettings, VERSION, createDeepSeek, deepseek };
|