A starter application for an AI-powered chatbot with Next.js, Lakebase Postgres (pgvector), OpenAI, and LlamaIndex.
It implements a chat interface that takes the user's input, embeds it, and retrieves relevant information from the Neon database using similarity search. It then uses the OpenAI chat API to generate a contextually appropriate response based on the retrieved data and chat history.
To follow along with this guide, you will need:
- A Neon account. If you do not have one, sign up at Neon. Your Neon project comes with a ready-to-use Postgres database named
neondb. We'll use this database in the following examples. - An OpenAI API key. If you do not have an OpenAI account, sign up and navigate to the API keys page to create an API key.
- Node.js and npm installed on your machine.
npx degit neondatabase/examples/ai/llamaindex/chatbot-nextjs ./chatbot-nextjs- Create a
.envfile:
cp .env.example .env-
Update the environment variables with your OpenAI API Key and Lakebase Postgres URL.
-
Install the dependencies:
npm install- Run the application:
npm run dev- Neon AI documentation
- pgvector documentation
- OpenAI documentation
- Llama Index documentation
- Next.js documentation
- Rishi Raj Jain (@rishi_raj_jain_)
