37-AN
commited on
Commit
Β·
780b542
1
Parent(s):
bfba788
Update for Hugging Face Spaces deployment
Browse files- Dockerfile +4 -4
- README.md +31 -85
- huggingface-space.yml +1 -1
Dockerfile
CHANGED
@@ -23,8 +23,8 @@ RUN mkdir -p data/documents data/vector_db
|
|
23 |
# Set environment variable to avoid TOKENIZERS_PARALLELISM warning
|
24 |
ENV TOKENIZERS_PARALLELISM=false
|
25 |
|
26 |
-
# Expose the
|
27 |
-
EXPOSE
|
28 |
|
29 |
-
# Set the entrypoint command to run the Streamlit app
|
30 |
-
CMD ["streamlit", "run", "app/ui/streamlit_app.py", "--server.port=
|
|
|
23 |
# Set environment variable to avoid TOKENIZERS_PARALLELISM warning
|
24 |
ENV TOKENIZERS_PARALLELISM=false
|
25 |
|
26 |
+
# Expose the port required by Hugging Face Spaces
|
27 |
+
EXPOSE 7860
|
28 |
|
29 |
+
# Set the entrypoint command to run the Streamlit app on port 7860
|
30 |
+
CMD ["streamlit", "run", "app/ui/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
README.md
CHANGED
@@ -1,95 +1,41 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
[](https://colab.research.google.com)
|
7 |
|
8 |
## Features
|
9 |
|
10 |
-
-
|
11 |
-
-
|
12 |
-
-
|
13 |
-
-
|
14 |
-
-
|
15 |
-
-
|
16 |
|
17 |
-
##
|
18 |
|
19 |
-
|
20 |
-
.
|
21 |
-
|
22 |
-
|
23 |
-
βββ .env.example
|
24 |
-
βββ app.py # Main entry point for Hugging Face Spaces
|
25 |
-
βββ space.py # Hugging Face Spaces SDK integration
|
26 |
-
βββ app/
|
27 |
-
β βββ main.py # FastAPI application entry point
|
28 |
-
β βββ config.py # Configuration settings
|
29 |
-
β βββ ui/
|
30 |
-
β β βββ streamlit_app.py # Streamlit web interface
|
31 |
-
β βββ core/
|
32 |
-
β β βββ llm.py # LLM integration (Hugging Face)
|
33 |
-
β β βββ memory.py # RAG and vector store integration
|
34 |
-
β β βββ agent.py # Agent orchestration
|
35 |
-
β β βββ ingestion.py # Document processing pipeline
|
36 |
-
β βββ utils/
|
37 |
-
β βββ helpers.py # Utility functions
|
38 |
-
βββ data/
|
39 |
-
βββ documents/ # Store for uploaded documents
|
40 |
-
βββ vector_db/ # Local vector database storage
|
41 |
-
```
|
42 |
|
43 |
-
##
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
4. Start the Streamlit UI:
|
52 |
-
```
|
53 |
-
streamlit run app/ui/streamlit_app.py
|
54 |
-
```
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
1. Upload documents through the web interface
|
59 |
-
2. Chat with your assistant, which can now reference your documents
|
60 |
-
3. The assistant will automatically leverage your document knowledge to provide more personalized responses
|
61 |
-
|
62 |
-
## Deployment to Hugging Face Spaces
|
63 |
-
|
64 |
-
This app can be easily deployed to Hugging Face Spaces for free hosting:
|
65 |
-
|
66 |
-
1. Create a Hugging Face account at [huggingface.co](https://huggingface.co)
|
67 |
-
2. Set environment variables:
|
68 |
-
```
|
69 |
-
export HF_USERNAME=your-username
|
70 |
-
export HF_TOKEN=your-huggingface-token
|
71 |
-
export SPACE_NAME=personal-rag-assistant # optional
|
72 |
-
```
|
73 |
-
3. Run the deployment script:
|
74 |
-
```
|
75 |
-
python space.py
|
76 |
-
```
|
77 |
-
4. Visit your deployed app at `https://huggingface.co/spaces/{your-username}/{space-name}`
|
78 |
-
|
79 |
-
Alternatively, you can manually create a new Space on Hugging Face and link it to your GitHub repository.
|
80 |
-
|
81 |
-
## Models Used
|
82 |
-
|
83 |
-
This implementation uses the following free models from Hugging Face:
|
84 |
-
|
85 |
-
- LLM: [google/flan-t5-large](https://huggingface.co/google/flan-t5-large) - A powerful instruction-tuned model
|
86 |
-
- Embeddings: [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) - Efficient embedding model
|
87 |
-
|
88 |
-
You can change these in the `.env` file.
|
89 |
-
|
90 |
-
## Extending
|
91 |
-
|
92 |
-
- Add more document loaders in `ingestion.py`
|
93 |
-
- Integrate additional tools in `agent.py`
|
94 |
-
- Customize the UI in `streamlit_app.py`
|
95 |
-
- Switch to a different LLM in `llm.py` and `.env`
|
|
|
1 |
+
---
|
2 |
+
title: Personal AI Assistant with RAG
|
3 |
+
emoji: π€
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: purple
|
6 |
+
sdk: docker
|
7 |
+
app_port: 7860
|
8 |
+
pinned: true
|
9 |
+
license: mit
|
10 |
+
---
|
11 |
|
12 |
+
# Personal AI Assistant with RAG
|
13 |
|
14 |
+
A powerful personal AI assistant that uses Retrieval-Augmented Generation (RAG) to provide responses based on your documents and notes.
|
|
|
15 |
|
16 |
## Features
|
17 |
|
18 |
+
- Uses free Hugging Face models for language processing and embeddings
|
19 |
+
- Stores and retrieves information in a vector database
|
20 |
+
- Upload PDF, TXT, and CSV files to expand the knowledge base
|
21 |
+
- Add direct text input to your knowledge base
|
22 |
+
- View sources for AI responses
|
23 |
+
- Conversation history tracking
|
24 |
|
25 |
+
## How to Use
|
26 |
|
27 |
+
1. **Upload Documents**: Use the sidebar to upload files (PDF, TXT, CSV)
|
28 |
+
2. **Add Text**: Enter text directly into the knowledge base
|
29 |
+
3. **Ask Questions**: Chat with the assistant about your documents
|
30 |
+
4. **View Sources**: See where information is coming from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
## Built With
|
33 |
|
34 |
+
- Hugging Face Models
|
35 |
+
- LLM: google/flan-t5-large
|
36 |
+
- Embeddings: sentence-transformers/all-MiniLM-L6-v2
|
37 |
+
- LangChain for orchestration
|
38 |
+
- Qdrant for vector storage
|
39 |
+
- Streamlit for UI
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
Created by [p3rc03](https://huggingface.co/p3rc03)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
huggingface-space.yml
CHANGED
@@ -3,7 +3,7 @@ emoji: π€
|
|
3 |
colorFrom: indigo
|
4 |
colorTo: purple
|
5 |
sdk: docker
|
6 |
-
app_port:
|
7 |
pinned: true
|
8 |
license: mit
|
9 |
duplicated_from: huggingface/transformers-examples
|
|
|
3 |
colorFrom: indigo
|
4 |
colorTo: purple
|
5 |
sdk: docker
|
6 |
+
app_port: 7860
|
7 |
pinned: true
|
8 |
license: mit
|
9 |
duplicated_from: huggingface/transformers-examples
|