An open-source AI chatbot to chat with multiple PDF files.
Tech Stack · Running Enviroment · Deployment · Run the server · References
An open-source AI chatbot to chat with multiple PDF files.
- Next.js 13 App Router
- Typescript as a language
- Tailwind CSS as a CSS framework, with light and dark themes
- NextAuth.js for authentication
- Powered by LangChain
- OpenAI gpt-3.5-turbo as a language model (You can change it to gpt-4 if you have access to it)
- Pinecone as a vectorstore
- PostgreSQL and Sequelize as database and ORM for managing users and chat history
Node: 18.x
- Clone the repo or download the ZIP
git clone [github https url]
- Install packages
npm install
- Set up .env.development
-
Copy .example.env.development to .env.development for local dev
-
Copy .example.env.production to .env.production for production
-
Fill env variables
OPENAI_API_KEY=
PINECONE_API_KEY=
PINECONE_ENVIRONMENT=
NEXTAUTH_SECRET=
- Get an API key on openai dashboard and fill it in OPENAI_API_KEY.
- Create an API key on pinecone dashboard and copy API key and Environment and then fill them in PINECONE_API_KEY and PINECONE_ENVIRONMENT.
- Generate a random 32-digit hexadecimal string and fill it in NEXTAUTH_SECRET.
- Set up database.
- Create a database in PostgreSQL on your local or remote For local dev, In sequelize/config/config.js, replace variables with your correct values under development. For production, In sequelize/config/config.js, replace variables with your correct values under production.
-
In lib/server/makechain.ts chain change the QA_PROMPT for your own usecase. Change modelName in new OpenAI to gpt-4, if you have access to gpt-4 api.
-
In the Starter(free) plan, you cannot delete saved vectors in an index. In non-starter plan, you should open these lines
- line 71 in lib/server/embeddings
- line 115 in app/api/file/route.ts
- Run the app npm run dev to launch the local dev environment
npm run dev
Then this should be running on localhost:3000
- Upload PDF files and then type questions
The parts of Chain and Embedding were inspired by GPT-4 & LangChain