Skip to content

ahmedbesbes/chat-with-papers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo contains the code for building a RAG-based assistant to chat with Papers With Code.

0. Some requirements

  • A GCP account with VertexAI and Cloud Run services activated
  • An OpenAI key
  • A free account on Upstash (serverless database)

1. Indexing

To index data into the vector DB, you first need to create an index on Upstash and fill in the credentials in the .env file:

UPSTASH_URL=...
UPSTASH_TOKEN=...

Then you have to run this command:

poetry run python -m src.index_papers --query "OpenAI" --limit 200

Here's the result of indexing 200 chunks matching the "OpenAI" query.

2. Run the Streamlit application locally to interact with the RAG

poetry run python -m streamlit run  src/app.py --theme.primaryColor "#135aaf"

3. Deploy the application to Cloud Run

Follow these steps:

Build the Docker image locally:

docker build -t chat-pwc .

Push the image to container registry:

gcloud builds submit --tag gcr.io/<PROJECT_ID>/pwc-rag --timeout=2h

Connect to GCP console, go to Cloud Run service and hit the button "Create service":

Fill in these parameters:

  • The container image URL and the region

  • The container port (To match the value mentioned in the Dockerfile=80)

  • The secrets that will be injected as environment variables

  • Activate unathenticated invocations

Then hit the create button:

  • Once the service created, you'll see the corresponding URL

Now you can visit the app:

More details

Check Medium post.