title: Vc Aie4 Pythonic RAG
emoji: 🌖
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
license: apache-2.0
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Summary
This is my completed pythonic RAG assignment, completed for Session 3 of the AI Engineering Cohort 4. I implemented the following:
- Allow user to upload TWO documents (instead of a single document)
- Format of doc: they can be either text files or pdf docs.
- Text splitter - RecursiveTextSplitter from Langchain
- Vector store - using Chroma db
- Coded the chain in two ways for my own education a. traditional Langchain syntax - two step process of with 'stuff documents chain' and 'retrieval chain' b. using LCEL syntax with Runnables
- Most processing pythonic steps implemented via a single class with modular components that can be replaced with others (e.g., text splitter, vector store, etc.)
Retaining the original content of the README.md for my future reference!!
Deploying Pythonic Chat With Your Text File Application
In today's breakout rooms, we will be following the processed that you saw during the challenge - for reference, the instructions for that are available here.
Today, we will repeat the same process - but powered by our Pythonic RAG implementation we created last week.
You'll notice a few differences in the app.py
logic - as well as a few changes to the aimakerspace
package to get things working smoothly with Chainlit.
Reference Diagram (It's Busy, but it works)
Deploying the Application to Hugging Face Space
Due to the way the repository is created - it should be straightforward to deploy this to a Hugging Face Space!
NOTE: If you wish to go through the local deployments using
chainlit run app.py
and Docker - please feel free to do so!
Creating a Hugging Face Space
- Navigate to the
Spaces
tab.
- Click on
Create new Space
- Create the Space by providing values in the form. Make sure you've selected "Docker" as your Space SDK.
Adding this Repository to the Newly Created Space
- Collect the SSH address from the newly created Space.
NOTE: The address is the component that starts with
[email protected]:spaces/
.
- Use the command:
git remote add hf HF_SPACE_SSH_ADDRESS_HERE
- Use the command:
git pull hf main --no-rebase --allow-unrelated-histories -X ours
- Use the command:
git add .
- Use the command:
git commit -m "Deploying Pythonic RAG"
- Use the command:
git push hf main
- The Space should automatically build as soon as the push is completed!
NOTE: The build will fail before you complete the following steps!
Adding OpenAI Secrets to the Space
- Navigate to your Space settings.
- Navigate to
Variables and secrets
on the Settings page and clickNew secret
:
- In the
Name
field - inputOPENAI_API_KEY
in theValue (private)
field, put your OpenAI API Key.
- The Space will begin rebuilding!
🎉
You just deployed Pythonic RAG!
Try uploading a text file and asking some questions!
🚧CHALLENGE MODE 🚧
For more of a challenge, please reference Building a Chainlit App!