Run and deploy a GPT-4 powered chatbot in minutes!
Utilizes ChromaDB for its vectorstore, with a Next.js frontend.
-
Install Docker Desktop for your platform.
-
Clone the repo or download the ZIP
git clone [github https url]
- Install packages
First run npm install yarn -g
to install yarn globally (if you haven't already).
Then run:
yarn install
After installation, you should now see a node_modules
folder.
- Set up your
.env
file
- Copy
.env.example
into.env
Your.env
file should look like this:
OPENAI_API_KEY=
CHROMA_AUTH_BASIC=
CHROMA_AUTH_TOKEN=
CHROMA_URL=
COLLECTION_NAME=[optional]
- Visit openai to retrieve API keys and insert into your
.env
file. - Choose a collection name where you'd like to store your embeddings in Chroma. This collection will later be used for queries and retrieval.
- Chroma details
-
Depending on your setup, you may need to modify
app/api/files/utilities.ts
to connect to the right ChromaDB instance. -
In a new terminal window, run Chroma in the Docker container:
docker run -p 8000:8000 ghcr.io/chroma-core/chroma:latest
You can run the app with npm run dev
to launch the local dev environment, and then upload one or many PDF files to chat with. After uploading, you'll be able to chat with the model.
The terraform folder contains scripts originally from chromadb/examples
. To deploy your ChromaDB to GCP, do as follows:
-
Install GCP CLI, log in via CLI, and create a new project. Note the project ID.
-
Install terraform CLI.
-
Update
terraform/exportapply.sh
with your project ID variable. -
(Optional) Generate a keypair if you want to be able to SSH in to the GCP instance.
-
Run
exportapply.sh
in your terminal. -
Run
terraform output instance_public_ip
. Take note of the output IP, and update your.env
. -
Run
terraform output chroma_auth_token
. Take note of your auth token, and update your.env
. -
(optional) It takes some time for the GCP instance to come up, so you can check on the status with
% export instance_public_ip=$(terraform output instance_public_ip | sed 's/"//g')
% curl -v http://$instance_public_ip:8000/api/v1/heartbeat
- The API should now be able to connect with your GCP-deployed ChromaDB instance for vector store operations.
In general, keep an eye out in the issues
and discussions
section of this repo for solutions.
General errors
- Make sure you're running the latest Node version. Run
node -v
- Try a different PDF or convert your PDF to text first. It's possible your PDF is corrupted, scanned, or requires OCR to convert to text.
Console.log
theenv
variables and make sure they are exposed.- Check that you've created an
.env
file that contains your valid (and working) API keys, environment and index name. - If you change
modelName
inOpenAI
, make sure you have access to the api for the appropriate model. - Make sure you have enough OpenAI credits and a valid card on your billings account.
- Check that you don't have multiple OPENAPI keys in your global environment. If you do, the local
env
file from the project will be overwritten by systemsenv
variable. - Try to hard code your API keys into the
process.env
variables if there are still issues.
Originally forked from https://github.com/mayooear/gpt4-pdf-chatbot-langchain/tree/feat/chroma