Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- Dockerfile +6 -0
- README.md +8 -12
- app.py +29 -0
- requirements.txt +13 -0
Dockerfile
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
COPY requirements.txt .
|
| 4 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 5 |
+
COPY . .
|
| 6 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -1,12 +1,8 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
short_description: ai tutor
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
# AI Tutor Application
|
| 2 |
+
|
| 3 |
+
This is an AI tutor application for exam preparation.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
- RAG-based question answering
|
| 7 |
+
- PDF and image upload
|
| 8 |
+
- Text-to-speech responses
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from documents.loader import DocumentLoader
|
| 3 |
+
from utils.rag_pipeline import RAGPipeline
|
| 4 |
+
|
| 5 |
+
loader = DocumentLoader()
|
| 6 |
+
rag = RAGPipeline()
|
| 7 |
+
|
| 8 |
+
def process_query(question, history):
|
| 9 |
+
return f"AI Tutor: I received your question: {question}"
|
| 10 |
+
|
| 11 |
+
def upload_file(file):
|
| 12 |
+
return f"Uploaded: {file.name}"
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("# AI Tutor for Exam Preparation")
|
| 16 |
+
with gr.Row():
|
| 17 |
+
with gr.Column():
|
| 18 |
+
file_input = gr.File(label="Upload PDF/Image")
|
| 19 |
+
upload_btn = gr.Button("Upload")
|
| 20 |
+
upload_output = gr.Textbox(label="Upload Status")
|
| 21 |
+
with gr.Column():
|
| 22 |
+
chatbot = gr.Chatbot()
|
| 23 |
+
msg = gr.Textbox(label="Your question")
|
| 24 |
+
send_btn = gr.Button("Send")
|
| 25 |
+
|
| 26 |
+
upload_btn.click(upload_file, inputs=file_input, outputs=upload_output)
|
| 27 |
+
send_btn.click(process_query, inputs=msg, outputs=chatbot)
|
| 28 |
+
|
| 29 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
sentence-transformers
|
| 4 |
+
chromadb
|
| 5 |
+
langchain
|
| 6 |
+
langchain-huggingface
|
| 7 |
+
pillow
|
| 8 |
+
pypdf
|
| 9 |
+
python-multipart
|
| 10 |
+
accelerate
|
| 11 |
+
torch
|
| 12 |
+
datasets
|
| 13 |
+
huggingface-hub
|