mirror of
https://github.com/tcsenpai/ollama.git
synced 2025-06-06 19:25:21 +00:00
Update examples/typescript-simplechat/client.ts
Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>
This commit is contained in:
parent
b84d34e632
commit
6cc823c9b5
@ -30,7 +30,7 @@ async function chat(messages: Message[]): Promise<Message> {
|
|||||||
if (!reader) {
|
if (!reader) {
|
||||||
throw new Error("Failed to read response body")
|
throw new Error("Failed to read response body")
|
||||||
}
|
}
|
||||||
const content: string[] = []
|
let content = ""
|
||||||
while (true) {
|
while (true) {
|
||||||
const { done, value } = await reader.read()
|
const { done, value } = await reader.read()
|
||||||
if (done) {
|
if (done) {
|
||||||
@ -41,7 +41,7 @@ async function chat(messages: Message[]): Promise<Message> {
|
|||||||
|
|
||||||
if (json.done === false) {
|
if (json.done === false) {
|
||||||
process.stdout.write(json.message.content);
|
process.stdout.write(json.message.content);
|
||||||
content.push(json.message.content)
|
content += json.message.content
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user