Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion:why did not set the response word by word #70

Closed
haorenqq opened this issue Mar 24, 2023 · 2 comments
Closed

suggestion:why did not set the response word by word #70

haorenqq opened this issue Mar 24, 2023 · 2 comments

Comments

@haorenqq
Copy link

why did not set the response word by word

@Niek
Copy link
Owner

Niek commented Mar 24, 2023

I just got this working yesterday:

request.stream = true
await fetchEventSource(apiBase + '/v1/chat/completions', {
method: 'POST',
headers: {
Authorization:
`Bearer ${$apiKeyStorage}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(request),
onmessage (ev) {
const data = JSON.parse(ev.data)
console.log(data)
},
onerror (err) {
throw err
}
})

I'm not sure how to implement it through without having to rewrite a whole bunch of code. Maybe by wrapping Response in a Readable, but I'm not too sure.

@Niek
Copy link
Owner

Niek commented Jun 9, 2023

Fixed in #152

@Niek Niek closed this as completed Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants