File size: 3,812 Bytes
f27f108 f63bc6b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
---
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:
1. Allow user to upload TWO documents (instead of a single document)
2. Format of doc: they can be either text files or pdf docs.
3. Text splitter - RecursiveTextSplitter from Langchain
4. Vector store - using Chroma db
5. 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
6. 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](https://github.com/AI-Maker-Space/Beyond-ChatGPT/tree/main).
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)
![image](https://i.imgur.com/IaEVZG2.png)
## 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!
<details>
<summary>Creating a Hugging Face Space</summary>
1. Navigate to the `Spaces` tab.
![image](https://i.imgur.com/aSMlX2T.png)
2. Click on `Create new Space`
![image](https://i.imgur.com/YaSSy5p.png)
3. Create the Space by providing values in the form. Make sure you've selected "Docker" as your Space SDK.
![image](https://i.imgur.com/6h9CgH6.png)
</details>
<details>
<summary>Adding this Repository to the Newly Created Space</summary>
1. Collect the SSH address from the newly created Space.
![image](https://i.imgur.com/Oag0m8E.png)
> NOTE: The address is the component that starts with `[email protected]:spaces/`.
2. Use the command:
```bash
git remote add hf HF_SPACE_SSH_ADDRESS_HERE
```
3. Use the command:
```bash
git pull hf main --no-rebase --allow-unrelated-histories -X ours
```
4. Use the command:
```bash
git add .
```
5. Use the command:
```bash
git commit -m "Deploying Pythonic RAG"
```
6. Use the command:
```bash
git push hf main
```
7. The Space should automatically build as soon as the push is completed!
> NOTE: The build will fail before you complete the following steps!
</details>
<details>
<summary>Adding OpenAI Secrets to the Space</summary>
1. Navigate to your Space settings.
![image](https://i.imgur.com/zh0a2By.png)
2. Navigate to `Variables and secrets` on the Settings page and click `New secret`:
![image](https://i.imgur.com/g2KlZdz.png)
3. In the `Name` field - input `OPENAI_API_KEY` in the `Value (private)` field, put your OpenAI API Key.
![image](https://i.imgur.com/eFcZ8U3.png)
4. The Space will begin rebuilding!
</details>
## 🎉
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](./BuildingAChainlitApp.md)!
|