@usecrow/ui 0.1.37 → 0.1.38
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/dist/index.cjs +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -138,11 +138,13 @@ function useChat({
|
|
|
138
138
|
const reader = response.body?.getReader();
|
|
139
139
|
const decoder = new TextDecoder();
|
|
140
140
|
if (reader) {
|
|
141
|
+
let buffer = "";
|
|
141
142
|
while (true) {
|
|
142
143
|
const { done, value } = await reader.read();
|
|
143
144
|
if (done) break;
|
|
144
|
-
|
|
145
|
-
const lines =
|
|
145
|
+
buffer += decoder.decode(value, { stream: true });
|
|
146
|
+
const lines = buffer.split("\n");
|
|
147
|
+
buffer = lines.pop() || "";
|
|
146
148
|
for (const line of lines) {
|
|
147
149
|
if (line.startsWith("data: ")) {
|
|
148
150
|
const data = line.slice(6).trim();
|
|
@@ -491,11 +493,13 @@ function useChat({
|
|
|
491
493
|
const decoder = new TextDecoder();
|
|
492
494
|
let accumulatedText = "";
|
|
493
495
|
if (reader) {
|
|
496
|
+
let buffer = "";
|
|
494
497
|
while (true) {
|
|
495
498
|
const { done, value } = await reader.read();
|
|
496
499
|
if (done) break;
|
|
497
|
-
|
|
498
|
-
const lines =
|
|
500
|
+
buffer += decoder.decode(value, { stream: true });
|
|
501
|
+
const lines = buffer.split("\n");
|
|
502
|
+
buffer = lines.pop() || "";
|
|
499
503
|
for (const line of lines) {
|
|
500
504
|
if (line.startsWith("data: ")) {
|
|
501
505
|
const data = line.slice(6).trim();
|