@lobehub/chat 1.6.4 → 1.6.5
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 +25 -0
- package/package.json +3 -3
- package/src/libs/agent-runtime/qwen/index.test.ts +15 -13
- package/src/libs/agent-runtime/qwen/index.ts +1 -1
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.test.ts +15 -7
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +1 -1
- package/src/libs/agent-runtime/utils/streams/qwen.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 1.6.5](https://github.com/lobehub/lobe-chat/compare/v1.6.4...v1.6.5)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-07-22**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Content lost unexpectedly on Qwen provider when `finish_reason` is `stop`.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Content lost unexpectedly on Qwen provider when `finish_reason` is `stop`, closes [#3252](https://github.com/lobehub/lobe-chat/issues/3252) ([d35c5b0](https://github.com/lobehub/lobe-chat/commit/d35c5b0))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 1.6.4](https://github.com/lobehub/lobe-chat/compare/v1.6.3...v1.6.4)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-07-21**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"debug": "^4.3.5",
|
|
139
139
|
"dexie": "^3.2.7",
|
|
140
140
|
"diff": "^5.2.0",
|
|
141
|
-
"drizzle-orm": "^0.
|
|
141
|
+
"drizzle-orm": "^0.32.0",
|
|
142
142
|
"drizzle-zod": "^0.5.1",
|
|
143
143
|
"fast-deep-equal": "^3.1.3",
|
|
144
144
|
"gpt-tokenizer": "^2.1.2",
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
"consola": "^3.2.3",
|
|
242
242
|
"dotenv": "^16.4.5",
|
|
243
243
|
"dpdm": "^3.14.0",
|
|
244
|
-
"drizzle-kit": "^0.
|
|
244
|
+
"drizzle-kit": "^0.23.0",
|
|
245
245
|
"eslint": "^8.57.0",
|
|
246
246
|
"eslint-plugin-mdx": "^2.3.4",
|
|
247
247
|
"fake-indexeddb": "^6.0.0",
|
|
@@ -3,9 +3,7 @@ import OpenAI from 'openai';
|
|
|
3
3
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
4
|
|
|
5
5
|
import Qwen from '@/config/modelProviders/qwen';
|
|
6
|
-
import {
|
|
7
|
-
import { ModelProvider } from '@/libs/agent-runtime';
|
|
8
|
-
import { AgentRuntimeErrorType } from '@/libs/agent-runtime';
|
|
6
|
+
import { AgentRuntimeErrorType, ModelProvider } from '@/libs/agent-runtime';
|
|
9
7
|
|
|
10
8
|
import * as debugStreamModule from '../utils/debugStream';
|
|
11
9
|
import { LobeQwenAI } from './index';
|
|
@@ -134,19 +132,23 @@ describe('LobeQwenAI', () => {
|
|
|
134
132
|
});
|
|
135
133
|
|
|
136
134
|
const decoder = new TextDecoder();
|
|
137
|
-
|
|
138
135
|
const reader = result.body!.getReader();
|
|
139
|
-
|
|
140
|
-
'id: chatcmpl-fc539f49-51a8-94be-8061\n',
|
|
141
|
-
);
|
|
142
|
-
expect(decoder.decode((await reader.read()).value)).toContain('event: text\n');
|
|
143
|
-
expect(decoder.decode((await reader.read()).value)).toContain('data: "Hello"\n\n');
|
|
136
|
+
const stream: string[] = [];
|
|
144
137
|
|
|
145
|
-
|
|
138
|
+
while (true) {
|
|
139
|
+
const { value, done } = await reader.read();
|
|
140
|
+
if (done) break;
|
|
141
|
+
stream.push(decoder.decode(value));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
expect(stream).toEqual([
|
|
146
145
|
'id: chatcmpl-fc539f49-51a8-94be-8061\n',
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
'event: text\n',
|
|
147
|
+
'data: "Hello"\n\n',
|
|
148
|
+
'id: chatcmpl-fc539f49-51a8-94be-8061\n',
|
|
149
|
+
'event: stop\n',
|
|
150
|
+
'data: "stop"\n\n',
|
|
151
|
+
]);
|
|
150
152
|
|
|
151
153
|
expect((await reader.read()).done).toBe(true);
|
|
152
154
|
});
|
|
@@ -373,15 +373,23 @@ describe('LobeOpenAICompatibleFactory', () => {
|
|
|
373
373
|
});
|
|
374
374
|
|
|
375
375
|
const decoder = new TextDecoder();
|
|
376
|
-
|
|
377
376
|
const reader = result.body!.getReader();
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
377
|
+
const stream: string[] = [];
|
|
378
|
+
|
|
379
|
+
while (true) {
|
|
380
|
+
const { value, done } = await reader.read();
|
|
381
|
+
if (done) break;
|
|
382
|
+
stream.push(decoder.decode(value));
|
|
383
|
+
}
|
|
381
384
|
|
|
382
|
-
expect(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
+
expect(stream).toEqual([
|
|
386
|
+
'id: a\n',
|
|
387
|
+
'event: text\n',
|
|
388
|
+
'data: "Hello"\n\n',
|
|
389
|
+
'id: a\n',
|
|
390
|
+
'event: stop\n',
|
|
391
|
+
'data: "stop"\n\n',
|
|
392
|
+
]);
|
|
385
393
|
|
|
386
394
|
expect((await reader.read()).done).toBe(true);
|
|
387
395
|
});
|
|
@@ -89,7 +89,7 @@ export function transformResponseToStream(data: OpenAI.ChatCompletion) {
|
|
|
89
89
|
controller.enqueue({
|
|
90
90
|
choices: data.choices.map((choice: OpenAI.ChatCompletion.Choice) => ({
|
|
91
91
|
delta: {
|
|
92
|
-
content:
|
|
92
|
+
content: null,
|
|
93
93
|
role: choice.message.role,
|
|
94
94
|
},
|
|
95
95
|
finish_reason: choice.finish_reason,
|
|
@@ -62,14 +62,14 @@ export const transformQwenStream = (chunk: OpenAI.ChatCompletionChunk): StreamPr
|
|
|
62
62
|
} as StreamProtocolToolCallChunk;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
if (item.finish_reason) {
|
|
66
|
-
return { data: item.finish_reason, id: chunk.id, type: 'stop' };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
65
|
if (typeof item.delta?.content === 'string') {
|
|
70
66
|
return { data: item.delta.content, id: chunk.id, type: 'text' };
|
|
71
67
|
}
|
|
72
68
|
|
|
69
|
+
if (item.finish_reason) {
|
|
70
|
+
return { data: item.finish_reason, id: chunk.id, type: 'stop' };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
73
|
if (item.delta?.content === null) {
|
|
74
74
|
return { data: item.delta, id: chunk.id, type: 'data' };
|
|
75
75
|
}
|