@lobehub/lobehub 2.0.0-next.57 → 2.0.0-next.59
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 +50 -0
- package/changelog/v1.json +18 -0
- package/locales/ar/models.json +123 -23
- package/locales/bg-BG/models.json +147 -26
- package/locales/de-DE/models.json +123 -23
- package/locales/en-US/models.json +75 -23
- package/locales/es-ES/models.json +123 -23
- package/locales/fa-IR/models.json +123 -23
- package/locales/fr-FR/models.json +123 -23
- package/locales/it-IT/models.json +123 -23
- package/locales/ja-JP/models.json +123 -23
- package/locales/ko-KR/models.json +123 -23
- package/locales/nl-NL/models.json +123 -23
- package/locales/pl-PL/models.json +123 -23
- package/locales/pt-BR/models.json +123 -23
- package/locales/ru-RU/models.json +123 -23
- package/locales/tr-TR/models.json +123 -23
- package/locales/vi-VN/models.json +123 -23
- package/locales/zh-TW/models.json +123 -23
- package/package.json +1 -1
- package/packages/model-runtime/src/core/contextBuilders/openai.test.ts +10 -8
- package/packages/model-runtime/src/core/contextBuilders/openai.ts +3 -0
- package/packages/model-runtime/src/providers/deepseek/index.test.ts +86 -0
- package/packages/model-runtime/src/providers/deepseek/index.ts +24 -0
|
@@ -20,6 +20,92 @@ testProvider({
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
describe('LobeDeepSeekAI - custom features', () => {
|
|
23
|
+
describe('chatCompletion.handlePayload', () => {
|
|
24
|
+
it('should transform reasoning object to reasoning_content string', () => {
|
|
25
|
+
const payload = {
|
|
26
|
+
messages: [
|
|
27
|
+
{ role: 'user', content: 'Hello' },
|
|
28
|
+
{
|
|
29
|
+
role: 'assistant',
|
|
30
|
+
content: 'Hi there',
|
|
31
|
+
reasoning: { content: 'Let me think...', duration: 1000 },
|
|
32
|
+
},
|
|
33
|
+
{ role: 'user', content: 'How are you?' },
|
|
34
|
+
],
|
|
35
|
+
model: 'deepseek-r1',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const result = params.chatCompletion!.handlePayload!(payload as any);
|
|
39
|
+
|
|
40
|
+
expect(result.messages).toEqual([
|
|
41
|
+
{ role: 'user', content: 'Hello' },
|
|
42
|
+
{
|
|
43
|
+
role: 'assistant',
|
|
44
|
+
content: 'Hi there',
|
|
45
|
+
reasoning_content: 'Let me think...',
|
|
46
|
+
},
|
|
47
|
+
{ role: 'user', content: 'How are you?' },
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should not modify messages without reasoning field', () => {
|
|
52
|
+
const payload = {
|
|
53
|
+
messages: [
|
|
54
|
+
{ role: 'user', content: 'Hello' },
|
|
55
|
+
{ role: 'assistant', content: 'Hi there' },
|
|
56
|
+
],
|
|
57
|
+
model: 'deepseek-chat',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const result = params.chatCompletion!.handlePayload!(payload as any);
|
|
61
|
+
|
|
62
|
+
expect(result.messages).toEqual(payload.messages);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should handle empty reasoning content', () => {
|
|
66
|
+
const payload = {
|
|
67
|
+
messages: [
|
|
68
|
+
{
|
|
69
|
+
role: 'assistant',
|
|
70
|
+
content: 'Response',
|
|
71
|
+
reasoning: { duration: 1000 },
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
model: 'deepseek-r1',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const result = params.chatCompletion!.handlePayload!(payload as any);
|
|
78
|
+
|
|
79
|
+
expect(result.messages[0]).toEqual({
|
|
80
|
+
role: 'assistant',
|
|
81
|
+
content: 'Response',
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should set stream to true by default', () => {
|
|
86
|
+
const payload = {
|
|
87
|
+
messages: [{ role: 'user', content: 'Hello' }],
|
|
88
|
+
model: 'deepseek-chat',
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const result = params.chatCompletion!.handlePayload!(payload as any);
|
|
92
|
+
|
|
93
|
+
expect(result.stream).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should preserve existing stream value', () => {
|
|
97
|
+
const payload = {
|
|
98
|
+
messages: [{ role: 'user', content: 'Hello' }],
|
|
99
|
+
model: 'deepseek-chat',
|
|
100
|
+
stream: false,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const result = params.chatCompletion!.handlePayload!(payload as any);
|
|
104
|
+
|
|
105
|
+
expect(result.stream).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
23
109
|
describe('Debug Configuration', () => {
|
|
24
110
|
it('should disable debug by default', () => {
|
|
25
111
|
delete process.env.DEBUG_DEEPSEEK_CHAT_COMPLETION;
|
|
@@ -12,6 +12,30 @@ export interface DeepSeekModelCard {
|
|
|
12
12
|
|
|
13
13
|
export const params = {
|
|
14
14
|
baseURL: 'https://api.deepseek.com/v1',
|
|
15
|
+
chatCompletion: {
|
|
16
|
+
handlePayload: (payload) => {
|
|
17
|
+
// Transform reasoning object to reasoning_content string for multi-turn conversations
|
|
18
|
+
const messages = payload.messages.map((message: any) => {
|
|
19
|
+
// Only transform if message has reasoning.content
|
|
20
|
+
if (message.reasoning?.content) {
|
|
21
|
+
const { reasoning, ...rest } = message;
|
|
22
|
+
return {
|
|
23
|
+
...rest,
|
|
24
|
+
reasoning_content: reasoning.content,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// If message has reasoning but no content, remove reasoning field entirely
|
|
28
|
+
delete message.reasoning;
|
|
29
|
+
return message;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...payload,
|
|
34
|
+
messages,
|
|
35
|
+
stream: payload.stream ?? true,
|
|
36
|
+
} as any;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
15
39
|
debug: {
|
|
16
40
|
chatCompletion: () => process.env.DEBUG_DEEPSEEK_CHAT_COMPLETION === '1',
|
|
17
41
|
},
|