Settings

Theme

Consume streaming data from OpenAI with vanilla JavaScript

youtube.com

1 points by umaar 3 years ago · 2 comments

Reader

umaarOP 3 years ago

Hey HN, have seen a lot of AI demos recently using libraries/frameworks for what is effectively an API call - so thought to showcase how this could be done with vanilla JavaScript. Turns out response.body is an async iterable, so you can do something like:

  for await (const chunk of response.body) { // use chunk }
sbricks 3 years ago

why everyone likes JavaScript so much? :)

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection