Skip to content

Commit 4d762de

Browse files
committed
update stream
1 parent 13d7ef2 commit 4d762de

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/Chat/Chat.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const Chat = memo(({stopConversationRef}: Props) => {
169169
done = true;
170170
} else {
171171
if (!done && obj1["delta"] && obj1["delta"]["content"]) {
172+
console.log("push data:", obj1["delta"]["content"])
172173
queue.push(obj1["delta"]["content"]);
173174
}
174175
}
@@ -179,12 +180,14 @@ export const Chat = memo(({stopConversationRef}: Props) => {
179180

180181
for (const item of queue) {
181182
const thisWord = queue.shift();
182-
if(!isShowFirst){
183-
await delay(Math.random() * 500);
184-
}else {
183+
console.log("push speed:", queue.length < 10 ? 500 : 200)
184+
if (!isShowFirst) {
185+
await delay(Math.random() * (queue.length < 10 ? 500 : 200));
186+
} else {
185187
isShowFirst = false;
186188
}
187189
text += thisWord
190+
console.log("set data:", thisWord)
188191
if (isFirst) {
189192
isFirst = false;
190193
homeDispatch({field: 'loading', value: false});
@@ -220,6 +223,7 @@ export const Chat = memo(({stopConversationRef}: Props) => {
220223
value: updatedConversation,
221224
});
222225
}
226+
console.log("push speed:", queue.length < 10 ? 500 : 200)
223227
if (done && queue.length === 0) {
224228
homeDispatch({field: 'messageIsStreaming', value: false});
225229
controller.abort();

0 commit comments

Comments
 (0)