Realtime chat using OpenAI, Next.js, and OrbisDB.
- Install your dependencies:
npm install
-
Copy the env example file and rename it
.env
-
Create a WalletConnect project ID by visiting https://cloud.walletconnect.com/sign-in, create a new project (with a name of your choosing and the
App
type selected), and copy theProject ID
key once available.
Once copied, assign it to NEXT_PUBLIC_PROJECT_ID
in your .env file
- Visit OpenAI's API Signup page to create an account if you don't yet have one and generate an API key.
At the time of writing this tutorial, OpenAI is offering a free OpenAI API trial, with $5 worth of credit (which can take you a LONGGG way).
Include in your .env file:
OPENAI_API_KEY="sk-thisisabunchofL3ttersandNum8ers"
- Visit the Orbis Studio and create a free account if you do not already have one.
First, set up a new context (required to use a shared instance). Assign this to NEXT_PUBLIC_CONTEXT_ID
in your .env file.
Next, navigate to the model builder view and use the table reference to define your tables. Use the corresponding model IDs to assign to NEXT_PUBLIC_POST_ID
and NEXT_PUBLIC_PROFILE_ID
in your .env file.
Finally, click the "Contexts" tab in the studio navbar and copy your environment ID from the left-hand side of the screen. Assign the value to NEXT_PUBLIC_ENV_ID
in your .env file.
- Run the application:
nvm use 20
npm run dev
To learn more about OrbisDB please visit the following links
Credit to ChatBase for an awesome template to work with.