@usecrow/ui 0.1.36 → 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 +2 -2
package/dist/index.cjs
CHANGED
|
@@ -164,11 +164,13 @@ function useChat({
|
|
|
164
164
|
const reader = response.body?.getReader();
|
|
165
165
|
const decoder = new TextDecoder();
|
|
166
166
|
if (reader) {
|
|
167
|
+
let buffer = "";
|
|
167
168
|
while (true) {
|
|
168
169
|
const { done, value } = await reader.read();
|
|
169
170
|
if (done) break;
|
|
170
|
-
|
|
171
|
-
const lines =
|
|
171
|
+
buffer += decoder.decode(value, { stream: true });
|
|
172
|
+
const lines = buffer.split("\n");
|
|
173
|
+
buffer = lines.pop() || "";
|
|
172
174
|
for (const line of lines) {
|
|
173
175
|
if (line.startsWith("data: ")) {
|
|
174
176
|
const data = line.slice(6).trim();
|
|
@@ -517,11 +519,13 @@ function useChat({
|
|
|
517
519
|
const decoder = new TextDecoder();
|
|
518
520
|
let accumulatedText = "";
|
|
519
521
|
if (reader) {
|
|
522
|
+
let buffer = "";
|
|
520
523
|
while (true) {
|
|
521
524
|
const { done, value } = await reader.read();
|
|
522
525
|
if (done) break;
|
|
523
|
-
|
|
524
|
-
const lines =
|
|
526
|
+
buffer += decoder.decode(value, { stream: true });
|
|
527
|
+
const lines = buffer.split("\n");
|
|
528
|
+
buffer = lines.pop() || "";
|
|
525
529
|
for (const line of lines) {
|
|
526
530
|
if (line.startsWith("data: ")) {
|
|
527
531
|
const data = line.slice(6).trim();
|