dan-kwiat/openai-edge

Client Side Example

Closed this issue · 1 comments

Could you provide a simple example of how you would use this on the client side? My requests are working using the library but I haven't figured out how to read the chunks and get the "text" response as it is fetched from the application.

@tycomo OpenAI responds with server-sent events (when using the text completion streaming option).

Here's a react hook to consume those:
https://github.com/dan-kwiat/react-hooks#useserversentevents

And a full NextJS example:
https://github.com/dan-kwiat/chat-gpt-clone