Spaces:
Sleeping
Sleeping
title: DeployPythonicRAG | |
emoji: 📉 | |
colorFrom: blue | |
colorTo: purple | |
sdk: docker | |
pinned: false | |
license: apache-2.0 | |
# Deploying Pythonic Chat With Your Text File Application | |
In today's breakout rooms, we will be following the process 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) | |
 | |
## 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. | |
 | |
2. Click on `Create new Space` | |
 | |
3. Create the Space by providing values in the form. Make sure you've selected "Docker" as your Space SDK. | |
 | |
</details> | |
<details> | |
<summary>Adding this Repository to the Newly Created Space</summary> | |
1. Collect the SSH address from the newly created Space. | |
 | |
> 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. | |
 | |
2. Navigate to `Variables and secrets` on the Settings page and click `New secret`: | |
 | |
3. In the `Name` field - input `OPENAI_API_KEY` in the `Value (private)` field, put your OpenAI API Key. | |
 | |
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)! | |