@ai-sdk/deepseek 2.0.10 → 2.0.12

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.
@@ -1,332 +0,0 @@
1
- import { convertToDeepSeekChatMessages } from './convert-to-deepseek-chat-messages';
2
- import { describe, it, expect } from 'vitest';
3
-
4
- describe('convertToDeepSeekChatMessages', () => {
5
- describe('user messages', () => {
6
- it('should convert messages with only a text part to a string content', async () => {
7
- const result = convertToDeepSeekChatMessages({
8
- prompt: [
9
- {
10
- role: 'user',
11
- content: [{ type: 'text', text: 'Hello' }],
12
- },
13
- ],
14
- responseFormat: undefined,
15
- });
16
-
17
- expect(result).toMatchInlineSnapshot(`
18
- {
19
- "messages": [
20
- {
21
- "content": "Hello",
22
- "role": "user",
23
- },
24
- ],
25
- "warnings": [],
26
- }
27
- `);
28
- });
29
-
30
- it('should warn about unsupported file parts', async () => {
31
- const result = convertToDeepSeekChatMessages({
32
- prompt: [
33
- {
34
- role: 'user',
35
- content: [
36
- { type: 'text', text: 'Hello' },
37
- {
38
- type: 'file',
39
- data: Buffer.from([0, 1, 2, 3]).toString('base64'),
40
- mediaType: 'image/png',
41
- },
42
- ],
43
- },
44
- ],
45
- responseFormat: undefined,
46
- });
47
-
48
- expect(result).toMatchInlineSnapshot(`
49
- {
50
- "messages": [
51
- {
52
- "content": "Hello",
53
- "role": "user",
54
- },
55
- ],
56
- "warnings": [
57
- {
58
- "feature": "user message part type: file",
59
- "type": "unsupported",
60
- },
61
- ],
62
- }
63
- `);
64
- });
65
- });
66
-
67
- describe('tool calls', () => {
68
- it('should stringify arguments to tool calls', () => {
69
- const result = convertToDeepSeekChatMessages({
70
- prompt: [
71
- {
72
- role: 'assistant',
73
- content: [
74
- {
75
- type: 'tool-call',
76
- input: { foo: 'bar123' },
77
- toolCallId: 'quux',
78
- toolName: 'thwomp',
79
- },
80
- ],
81
- },
82
- {
83
- role: 'tool',
84
- content: [
85
- {
86
- type: 'tool-result',
87
- toolCallId: 'quux',
88
- toolName: 'thwomp',
89
- output: { type: 'json', value: { oof: '321rab' } },
90
- },
91
- ],
92
- },
93
- ],
94
- responseFormat: undefined,
95
- });
96
-
97
- expect(result).toMatchInlineSnapshot(`
98
- {
99
- "messages": [
100
- {
101
- "content": "",
102
- "reasoning_content": undefined,
103
- "role": "assistant",
104
- "tool_calls": [
105
- {
106
- "function": {
107
- "arguments": "{"foo":"bar123"}",
108
- "name": "thwomp",
109
- },
110
- "id": "quux",
111
- "type": "function",
112
- },
113
- ],
114
- },
115
- {
116
- "content": "{"oof":"321rab"}",
117
- "role": "tool",
118
- "tool_call_id": "quux",
119
- },
120
- ],
121
- "warnings": [],
122
- }
123
- `);
124
- });
125
-
126
- it('should handle text output type in tool results', () => {
127
- const result = convertToDeepSeekChatMessages({
128
- prompt: [
129
- {
130
- role: 'assistant',
131
- content: [
132
- {
133
- type: 'tool-call',
134
- input: { query: 'weather' },
135
- toolCallId: 'call-1',
136
- toolName: 'getWeather',
137
- },
138
- ],
139
- },
140
- {
141
- role: 'tool',
142
- content: [
143
- {
144
- type: 'tool-result',
145
- toolCallId: 'call-1',
146
- toolName: 'getWeather',
147
- output: { type: 'text', value: 'It is sunny today' },
148
- },
149
- ],
150
- },
151
- ],
152
- responseFormat: undefined,
153
- });
154
-
155
- expect(result).toMatchInlineSnapshot(`
156
- {
157
- "messages": [
158
- {
159
- "content": "",
160
- "reasoning_content": undefined,
161
- "role": "assistant",
162
- "tool_calls": [
163
- {
164
- "function": {
165
- "arguments": "{"query":"weather"}",
166
- "name": "getWeather",
167
- },
168
- "id": "call-1",
169
- "type": "function",
170
- },
171
- ],
172
- },
173
- {
174
- "content": "It is sunny today",
175
- "role": "tool",
176
- "tool_call_id": "call-1",
177
- },
178
- ],
179
- "warnings": [],
180
- }
181
- `);
182
- });
183
-
184
- it('should support reasoning content in tool calls', () => {
185
- const result = convertToDeepSeekChatMessages({
186
- prompt: [
187
- {
188
- role: 'user',
189
- content: [{ type: 'text', text: 'Hello' }],
190
- },
191
- {
192
- role: 'assistant',
193
- content: [
194
- {
195
- type: 'reasoning',
196
- text: 'I think the tool will return the correct value.',
197
- },
198
- {
199
- type: 'tool-call',
200
- input: { foo: 'bar123' },
201
- toolCallId: 'quux',
202
- toolName: 'thwomp',
203
- },
204
- ],
205
- },
206
- {
207
- role: 'tool',
208
- content: [
209
- {
210
- type: 'tool-result',
211
- toolCallId: 'quux',
212
- toolName: 'thwomp',
213
- output: { type: 'json', value: { oof: '321rab' } },
214
- },
215
- ],
216
- },
217
- ],
218
- responseFormat: undefined,
219
- });
220
-
221
- expect(result).toMatchInlineSnapshot(`
222
- {
223
- "messages": [
224
- {
225
- "content": "Hello",
226
- "role": "user",
227
- },
228
- {
229
- "content": "",
230
- "reasoning_content": "I think the tool will return the correct value.",
231
- "role": "assistant",
232
- "tool_calls": [
233
- {
234
- "function": {
235
- "arguments": "{"foo":"bar123"}",
236
- "name": "thwomp",
237
- },
238
- "id": "quux",
239
- "type": "function",
240
- },
241
- ],
242
- },
243
- {
244
- "content": "{"oof":"321rab"}",
245
- "role": "tool",
246
- "tool_call_id": "quux",
247
- },
248
- ],
249
- "warnings": [],
250
- }
251
- `);
252
- });
253
-
254
- it('should filter out reasoning content from turns before the last user message', () => {
255
- const result = convertToDeepSeekChatMessages({
256
- prompt: [
257
- {
258
- role: 'user',
259
- content: [{ type: 'text', text: 'Hello' }],
260
- },
261
- {
262
- role: 'assistant',
263
- content: [
264
- {
265
- type: 'reasoning',
266
- text: 'I think the tool will return the correct value.',
267
- },
268
- {
269
- type: 'tool-call',
270
- input: { foo: 'bar123' },
271
- toolCallId: 'quux',
272
- toolName: 'thwomp',
273
- },
274
- ],
275
- },
276
- {
277
- role: 'tool',
278
- content: [
279
- {
280
- type: 'tool-result',
281
- toolCallId: 'quux',
282
- toolName: 'thwomp',
283
- output: { type: 'json', value: { oof: '321rab' } },
284
- },
285
- ],
286
- },
287
- {
288
- role: 'user',
289
- content: [{ type: 'text', text: 'Goodbye' }],
290
- },
291
- ],
292
- responseFormat: undefined,
293
- });
294
-
295
- expect(result).toMatchInlineSnapshot(`
296
- {
297
- "messages": [
298
- {
299
- "content": "Hello",
300
- "role": "user",
301
- },
302
- {
303
- "content": "",
304
- "reasoning_content": undefined,
305
- "role": "assistant",
306
- "tool_calls": [
307
- {
308
- "function": {
309
- "arguments": "{"foo":"bar123"}",
310
- "name": "thwomp",
311
- },
312
- "id": "quux",
313
- "type": "function",
314
- },
315
- ],
316
- },
317
- {
318
- "content": "{"oof":"321rab"}",
319
- "role": "tool",
320
- "tool_call_id": "quux",
321
- },
322
- {
323
- "content": "Goodbye",
324
- "role": "user",
325
- },
326
- ],
327
- "warnings": [],
328
- }
329
- `);
330
- });
331
- });
332
- });