37-AN commited on
Commit
780b542
Β·
1 Parent(s): bfba788

Update for Hugging Face Spaces deployment

Browse files
Files changed (3) hide show
  1. Dockerfile +4 -4
  2. README.md +31 -85
  3. 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 Streamlit port
27
- EXPOSE 8501
28
 
29
- # Set the entrypoint command to run the Streamlit app
30
- CMD ["streamlit", "run", "app/ui/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
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
- # Personal AI Assistant with RAG (Hugging Face Edition)
 
 
 
 
 
 
 
 
 
2
 
3
- A powerful personal AI assistant built with LangChain, integrating Retrieval-Augmented Generation (RAG) with a vector database (Qdrant) for improved contextual awareness and memory. This version uses Hugging Face models and can be deployed to Hugging Face Spaces for free hosting.
4
 
5
- [![Open In Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/open-in-spaces-sm.svg)](https://huggingface.co/spaces)
6
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com)
7
 
8
  ## Features
9
 
10
- - Large Language Model integration using Hugging Face's free models
11
- - RAG-based memory system with vector database storage
12
- - Document ingestion pipeline for various file types
13
- - Simple web UI built with Streamlit
14
- - Conversation history tracking and retrieval
15
- - Free deployment on Hugging Face Spaces
16
 
17
- ## Project Structure
18
 
19
- ```
20
- .
21
- β”œβ”€β”€ README.md
22
- β”œβ”€β”€ requirements.txt
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
- ## Setup
44
 
45
- 1. Clone this repository
46
- 2. Install dependencies:
47
- ```
48
- pip install -r requirements.txt
49
- ```
50
- 3. Copy `.env.example` to `.env` and fill in your Hugging Face API keys (optional)
51
- 4. Start the Streamlit UI:
52
- ```
53
- streamlit run app/ui/streamlit_app.py
54
- ```
55
 
56
- ## Usage
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: 8501
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