Spaces:
Sleeping
Sleeping
Update Docker configuration to change application port and environment variables
Browse files- Changed the exposed port from 8000 to 7860 in both Dockerfile and docker-compose.yml.
- Updated environment variables to set PORT and HOST for the application.
- Adjusted CMD in Dockerfile to reflect the new port for the application startup.
- .huggingface/DESCRIPTION +9 -0
- Dockerfile +5 -3
- HUGGINGFACE.md +76 -0
- README-HF.md +40 -0
- docker-compose.yml +3 -1
.huggingface/DESCRIPTION
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: RAG Chat with Document Dashboard & Quiz
|
| 3 |
+
emoji: 🧠
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: true
|
| 8 |
+
app_port: 7860
|
| 9 |
+
---
|
Dockerfile
CHANGED
|
@@ -43,9 +43,11 @@ RUN ls -la /app/static/ /app/static/css/ /app/static/js/
|
|
| 43 |
|
| 44 |
# Set environment variables
|
| 45 |
ENV PYTHONPATH=/app
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
# Expose the
|
| 48 |
-
EXPOSE
|
| 49 |
|
| 50 |
# Start the application
|
| 51 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "
|
|
|
|
| 43 |
|
| 44 |
# Set environment variables
|
| 45 |
ENV PYTHONPATH=/app
|
| 46 |
+
ENV PORT=7860
|
| 47 |
+
ENV HOST=0.0.0.0
|
| 48 |
|
| 49 |
+
# Expose the Hugging Face required port
|
| 50 |
+
EXPOSE 7860
|
| 51 |
|
| 52 |
# Start the application
|
| 53 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
HUGGINGFACE.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RAG Chat Application - Hugging Face Deployment
|
| 2 |
+
|
| 3 |
+
This document provides instructions for deploying the RAG Chat Application on Hugging Face Spaces.
|
| 4 |
+
|
| 5 |
+
## Overview
|
| 6 |
+
|
| 7 |
+
This RAG (Retrieval-Augmented Generation) Chat application allows users to:
|
| 8 |
+
- Upload documents (PDF/text)
|
| 9 |
+
- Ask questions about the uploaded documents
|
| 10 |
+
- View a document summary dashboard with key topics, word cloud, and document structure
|
| 11 |
+
- Take quizzes to test knowledge about the document content
|
| 12 |
+
|
| 13 |
+
## Features
|
| 14 |
+
|
| 15 |
+
- **Document Summary Dashboard:** Visual summaries of document content
|
| 16 |
+
- **Interactive Chat:** Ask questions about the uploaded documents
|
| 17 |
+
- **Knowledge Quiz:** Test your understanding with automatically generated quizzes
|
| 18 |
+
- **Thinking/Answer Format:** See the AI's reasoning process with expandable "thinking" sections
|
| 19 |
+
|
| 20 |
+
## Deployment Instructions
|
| 21 |
+
|
| 22 |
+
### Option 1: Deploy with Docker (Recommended)
|
| 23 |
+
|
| 24 |
+
1. Create a new Hugging Face Space:
|
| 25 |
+
- Go to [huggingface.co/spaces](https://huggingface.co/spaces)
|
| 26 |
+
- Click "Create new Space"
|
| 27 |
+
- Select "Docker" as the Space SDK
|
| 28 |
+
- Name your space and configure visibility settings
|
| 29 |
+
|
| 30 |
+
2. Upload the application files:
|
| 31 |
+
- Use Git to push the code to your Hugging Face Space repository
|
| 32 |
+
- Make sure to include the Dockerfile, which is already configured for Hugging Face
|
| 33 |
+
|
| 34 |
+
3. Set environment variables:
|
| 35 |
+
- Go to your Space settings
|
| 36 |
+
- Add the following environment variable:
|
| 37 |
+
- `OPENAI_API_KEY`: Your OpenAI API key
|
| 38 |
+
|
| 39 |
+
4. Hugging Face will automatically build and deploy the Docker container.
|
| 40 |
+
|
| 41 |
+
### Option 2: Manual Deployment
|
| 42 |
+
|
| 43 |
+
If you prefer to customize the deployment:
|
| 44 |
+
|
| 45 |
+
1. Fork this repository
|
| 46 |
+
2. Create a new Hugging Face Space with Docker SDK
|
| 47 |
+
3. Connect your GitHub repository to the Hugging Face Space
|
| 48 |
+
4. Add your OpenAI API key in the Space settings
|
| 49 |
+
5. Hugging Face will build and deploy your application
|
| 50 |
+
|
| 51 |
+
## Usage
|
| 52 |
+
|
| 53 |
+
1. Open your deployed application in Hugging Face Spaces
|
| 54 |
+
2. Upload a document (PDF or text)
|
| 55 |
+
3. Ask questions about the document content
|
| 56 |
+
4. Explore the document summary dashboard
|
| 57 |
+
5. After asking a few questions, try the quiz feature
|
| 58 |
+
|
| 59 |
+
## Configuration
|
| 60 |
+
|
| 61 |
+
You can customize your deployment by modifying:
|
| 62 |
+
- `Dockerfile` - Container configuration
|
| 63 |
+
- `api/main.py` - Backend API endpoints
|
| 64 |
+
- `app/frontend/src/` - Frontend React components
|
| 65 |
+
|
| 66 |
+
## Troubleshooting
|
| 67 |
+
|
| 68 |
+
If you encounter issues:
|
| 69 |
+
1. Check that your OpenAI API key is valid and properly set in the Space settings
|
| 70 |
+
2. Verify that your Space has sufficient resources allocated
|
| 71 |
+
3. Check the Space logs for any errors
|
| 72 |
+
4. For larger documents, you may need to increase the Space's resource allocation
|
| 73 |
+
|
| 74 |
+
## Contributing
|
| 75 |
+
|
| 76 |
+
Contributions are welcome! Feel free to submit pull requests or issues.
|
README-HF.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🧠 RAG Chat with Document Dashboard & Quiz
|
| 2 |
+
|
| 3 |
+
This application combines document analysis with interactive Q&A and knowledge quizzes.
|
| 4 |
+
|
| 5 |
+
## 📑 Features
|
| 6 |
+
|
| 7 |
+
- **Document Analysis:** Upload any PDF or text file
|
| 8 |
+
- **Interactive Q&A:** Ask questions about your document content
|
| 9 |
+
- **Document Dashboard:** View key topics, entities, word cloud and document structure
|
| 10 |
+
- **Knowledge Quiz:** Test your understanding with auto-generated quizzes
|
| 11 |
+
- **AI Reasoning:** See the AI's thinking process with expandable sections
|
| 12 |
+
|
| 13 |
+
## 🚀 Getting Started
|
| 14 |
+
|
| 15 |
+
1. **Upload a Document:** Click the upload button and select a PDF or text file
|
| 16 |
+
2. **Ask Questions:** Type questions about the document in the chat
|
| 17 |
+
3. **Explore Dashboard:** Browse the document summary dashboard to see insights
|
| 18 |
+
4. **Take a Quiz:** After asking a few questions, try the quiz feature (or type "quiz me")
|
| 19 |
+
|
| 20 |
+
## 💡 Example Questions
|
| 21 |
+
|
| 22 |
+
- "What are the main topics in this document?"
|
| 23 |
+
- "Can you summarize the key points?"
|
| 24 |
+
- "Explain the relationship between X and Y mentioned in the document."
|
| 25 |
+
- "Quiz me about this document's content."
|
| 26 |
+
|
| 27 |
+
## 🔧 Settings
|
| 28 |
+
|
| 29 |
+
- Toggle the dashboard visibility in the settings (gear icon)
|
| 30 |
+
- Switch between light and dark mode (sun/moon icon)
|
| 31 |
+
|
| 32 |
+
## 🛠️ Technical Details
|
| 33 |
+
|
| 34 |
+
This application uses a Retrieval-Augmented Generation (RAG) system with:
|
| 35 |
+
- Document chunking and vector embeddings
|
| 36 |
+
- Semantic search for relevant context
|
| 37 |
+
- LLM for generating detailed, accurate responses
|
| 38 |
+
- Separate AI reasoning and answer sections
|
| 39 |
+
|
| 40 |
+
Created with FastAPI, React, and OpenAI.
|
docker-compose.yml
CHANGED
|
@@ -6,10 +6,12 @@ services:
|
|
| 6 |
context: .
|
| 7 |
dockerfile: Dockerfile
|
| 8 |
ports:
|
| 9 |
-
- "
|
| 10 |
environment:
|
| 11 |
- PYTHONPATH=/app
|
| 12 |
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
|
|
|
|
|
|
| 13 |
env_file:
|
| 14 |
- .env
|
| 15 |
restart: unless-stopped
|
|
|
|
| 6 |
context: .
|
| 7 |
dockerfile: Dockerfile
|
| 8 |
ports:
|
| 9 |
+
- "7860:7860"
|
| 10 |
environment:
|
| 11 |
- PYTHONPATH=/app
|
| 12 |
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
| 13 |
+
- PORT=7860
|
| 14 |
+
- HOST=0.0.0.0
|
| 15 |
env_file:
|
| 16 |
- .env
|
| 17 |
restart: unless-stopped
|