Streaming OpenAI Chat Completions Using React and Node JS

preview_player
Показать описание
In this tutorial we go over the code for an endpoint that allows us to stream back a response from the OpenAI chat completion API. We use a Node JS server and a React JS frontend.

Links

#chatgpt #openai #reactjs
Рекомендации по теме
Комментарии
Автор

thanks, bro, I thought this was something complex and only Vercel could do this. Now I have also created my own streaming solution

veerbal
Автор

How do you handle special tokens returned by openai for formatting in your react component?

Автор

Hey Tosh, for some reason this code doesn't work for Azure open AI api. Can you tell me why?

thedakota
Автор

hey great video, can we do this directly on frontend without using NODE js?

SimranpreetSingh-oo
Автор

Where do you host the server code? I normally use Firebase functions, but it doesn't support streaming.

golightlyplus
Автор

I got ERROR: TypeError: Cannot read properties of undefined (reading 'on') when i return the response i dont get a .data object i jsut get this:

Stream {
iterator: [AsyncGeneratorFunction: iterator],
controller: AbortController { signal: AbortSignal { aborted: false } }
}

swagz
Автор

How do I use react to make a chat like feature and stream in unique responses from the server, not public to anybody that fetches from the endpoint

bantoonoises
Автор

thanks! will this solution work with a backend in node/express, a frontend in react? (no next.js)

SeanAhrens
Автор

Worked like magic. Thanks bro. Props to not over explaining and wasting time!

alkaribeats
Автор

subscribed. Thank you. Which package did u install to import, configuration and openai API from "openAI" ? i tried the same but unable to import

alishoaib