Skip to content

Commit

Permalink
fix: local stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Googlefan committed Jun 6, 2024
1 parent e1c2b38 commit 7235044
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/chat/llama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ async function* generate(chat: Chat[], system?: string) {
})),
),
});
const data: any = await res.body.json();
yield {
tokens: data.tokens,
content: data.content,
};
const stream = (await res.body.blob()).stream();
while (true) {
const { done, value } = await stream.getReader().read();
if (done) {
break;
}
yield {
tokens: 1,
content: value,
};
}
}

export const llama: ChatModel = {
Expand Down

0 comments on commit 7235044

Please sign in to comment.