@lobehub/chat 1.15.32 → 1.15.34
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.
Potentially problematic release.
This version of @lobehub/chat might be problematic. Click here for more details.
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.15.34](https://github.com/lobehub/lobe-chat/compare/v1.15.33...v1.15.34)
|
6
|
+
|
7
|
+
<sup>Released on **2024-09-10**</sup>
|
8
|
+
|
9
|
+
#### ♻ Code Refactoring
|
10
|
+
|
11
|
+
- **misc**: Change empty content stream behavior.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Code refactoring
|
19
|
+
|
20
|
+
- **misc**: Change empty content stream behavior, closes [#3883](https://github.com/lobehub/lobe-chat/issues/3883) ([e910f68](https://github.com/lobehub/lobe-chat/commit/e910f68))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.15.33](https://github.com/lobehub/lobe-chat/compare/v1.15.32...v1.15.33)
|
31
|
+
|
32
|
+
<sup>Released on **2024-09-10**</sup>
|
33
|
+
|
34
|
+
#### 🐛 Bug Fixes
|
35
|
+
|
36
|
+
- **misc**: Fix `/etc/resolv.conf`edit permission in docker image.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### What's fixed
|
44
|
+
|
45
|
+
- **misc**: Fix `/etc/resolv.conf`edit permission in docker image, closes [#3880](https://github.com/lobehub/lobe-chat/issues/3880) ([fdaa190](https://github.com/lobehub/lobe-chat/commit/fdaa190))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.15.32](https://github.com/lobehub/lobe-chat/compare/v1.15.31...v1.15.32)
|
6
56
|
|
7
57
|
<sup>Released on **2024-09-10**</sup>
|
package/Dockerfile
CHANGED
@@ -10,12 +10,13 @@ RUN \
|
|
10
10
|
fi \
|
11
11
|
# Add required package & update base package
|
12
12
|
&& apk update \
|
13
|
-
&& apk add --no-cache bind-tools proxychains-ng \
|
13
|
+
&& apk add --no-cache bind-tools proxychains-ng sudo \
|
14
14
|
&& apk upgrade --no-cache \
|
15
15
|
# Add user nextjs to run the app
|
16
16
|
&& addgroup --system --gid 1001 nodejs \
|
17
17
|
&& adduser --system --uid 1001 nextjs \
|
18
18
|
&& chown -R nextjs:nodejs "/etc/proxychains" \
|
19
|
+
&& echo "nextjs ALL=(ALL) NOPASSWD: /bin/chmod * /etc/resolv.conf" >> /etc/sudoers \
|
19
20
|
&& rm -rf /tmp/* /var/cache/apk/*
|
20
21
|
|
21
22
|
## Builder image, install all the dependencies and build the app
|
@@ -190,6 +191,7 @@ CMD \
|
|
190
191
|
fi; \
|
191
192
|
# Fix DNS resolving issue in Docker Compose, ref https://github.com/lobehub/lobe-chat/pull/3837
|
192
193
|
if [ -f "/etc/resolv.conf" ]; then \
|
194
|
+
sudo chmod 666 "/etc/resolv.conf"; \
|
193
195
|
resolv_conf=$(grep '^nameserver' "/etc/resolv.conf" | awk '{print "nameserver " $2}'); \
|
194
196
|
printf "%s\n" \
|
195
197
|
"$resolv_conf" \
|
package/Dockerfile.database
CHANGED
@@ -10,12 +10,13 @@ RUN \
|
|
10
10
|
fi \
|
11
11
|
# Add required package & update base package
|
12
12
|
&& apk update \
|
13
|
-
&& apk add --no-cache bind-tools proxychains-ng \
|
13
|
+
&& apk add --no-cache bind-tools proxychains-ng sudo \
|
14
14
|
&& apk upgrade --no-cache \
|
15
15
|
# Add user nextjs to run the app
|
16
16
|
&& addgroup --system --gid 1001 nodejs \
|
17
17
|
&& adduser --system --uid 1001 nextjs \
|
18
18
|
&& chown -R nextjs:nodejs "/etc/proxychains" \
|
19
|
+
&& echo "nextjs ALL=(ALL) NOPASSWD: /bin/chmod * /etc/resolv.conf" >> /etc/sudoers \
|
19
20
|
&& rm -rf /tmp/* /var/cache/apk/*
|
20
21
|
|
21
22
|
## Builder image, install all the dependencies and build the app
|
@@ -222,6 +223,7 @@ CMD \
|
|
222
223
|
fi; \
|
223
224
|
# Fix DNS resolving issue in Docker Compose, ref https://github.com/lobehub/lobe-chat/pull/3837
|
224
225
|
if [ -f "/etc/resolv.conf" ]; then \
|
226
|
+
sudo chmod 666 "/etc/resolv.conf"; \
|
225
227
|
resolv_conf=$(grep '^nameserver' "/etc/resolv.conf" | awk '{print "nameserver " $2}'); \
|
226
228
|
printf "%s\n" \
|
227
229
|
"$resolv_conf" \
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.15.
|
3
|
+
"version": "1.15.34",
|
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",
|
@@ -128,6 +128,40 @@ describe('OpenAIStream', () => {
|
|
128
128
|
expect(chunks).toEqual(['id: 3\n', 'event: data\n', `data: {"content":null}\n\n`]);
|
129
129
|
});
|
130
130
|
|
131
|
+
it('should handle content with finish_reason', async () => {
|
132
|
+
const mockOpenAIStream = new ReadableStream({
|
133
|
+
start(controller) {
|
134
|
+
controller.enqueue({
|
135
|
+
id: '123',
|
136
|
+
model: 'deepl',
|
137
|
+
choices: [
|
138
|
+
{
|
139
|
+
index: 0,
|
140
|
+
delta: { role: 'assistant', content: 'Introduce yourself.' },
|
141
|
+
finish_reason: 'stop',
|
142
|
+
},
|
143
|
+
],
|
144
|
+
});
|
145
|
+
|
146
|
+
controller.close();
|
147
|
+
},
|
148
|
+
});
|
149
|
+
|
150
|
+
const protocolStream = OpenAIStream(mockOpenAIStream);
|
151
|
+
|
152
|
+
const decoder = new TextDecoder();
|
153
|
+
const chunks = [];
|
154
|
+
|
155
|
+
// @ts-ignore
|
156
|
+
for await (const chunk of protocolStream) {
|
157
|
+
chunks.push(decoder.decode(chunk, { stream: true }));
|
158
|
+
}
|
159
|
+
|
160
|
+
expect(chunks).toEqual(
|
161
|
+
['id: 123', 'event: text', `data: "Introduce yourself."\n`].map((i) => `${i}\n`),
|
162
|
+
);
|
163
|
+
});
|
164
|
+
|
131
165
|
it('should handle other delta data', async () => {
|
132
166
|
const mockOpenAIStream = new ReadableStream({
|
133
167
|
start(controller) {
|
@@ -27,10 +27,6 @@ export const transformOpenAIStream = (
|
|
27
27
|
return { data: chunk, id: chunk.id, type: 'data' };
|
28
28
|
}
|
29
29
|
|
30
|
-
if (typeof item.delta?.content === 'string' && !item.finish_reason && !item.delta?.tool_calls) {
|
31
|
-
return { data: item.delta.content, id: chunk.id, type: 'text' };
|
32
|
-
}
|
33
|
-
|
34
30
|
if (item.delta?.tool_calls) {
|
35
31
|
return {
|
36
32
|
data: item.delta.tool_calls.map((value, index): StreamToolCallChunkData => {
|
@@ -60,9 +56,20 @@ export const transformOpenAIStream = (
|
|
60
56
|
|
61
57
|
// 给定结束原因
|
62
58
|
if (item.finish_reason) {
|
59
|
+
// one-api 的流式接口,会出现既有 finish_reason ,也有 content 的情况
|
60
|
+
// {"id":"demo","model":"deepl-en","choices":[{"index":0,"delta":{"role":"assistant","content":"Introduce yourself."},"finish_reason":"stop"}]}
|
61
|
+
|
62
|
+
if (typeof item.delta?.content === 'string' && !!item.delta.content) {
|
63
|
+
return { data: item.delta.content, id: chunk.id, type: 'text' };
|
64
|
+
}
|
65
|
+
|
63
66
|
return { data: item.finish_reason, id: chunk.id, type: 'stop' };
|
64
67
|
}
|
65
68
|
|
69
|
+
if (typeof item.delta?.content === 'string') {
|
70
|
+
return { data: item.delta.content, id: chunk.id, type: 'text' };
|
71
|
+
}
|
72
|
+
|
66
73
|
if (item.delta?.content === null) {
|
67
74
|
return { data: item.delta, id: chunk.id, type: 'data' };
|
68
75
|
}
|