Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
# app.py (repo root)
|
2 |
-
import gradio as gr
|
3 |
-
from day3.rag_system import RAGPipeline
|
4 |
-
|
5 |
-
# separate persistent dir for Spaces
|
6 |
-
rag = RAGPipeline(persist_dir="./chroma_db_space", collection_name="pdf_docs")
|
7 |
-
|
8 |
-
def chat_with_pdf(pdf_file, question):
|
9 |
-
if pdf_file is None or not question:
|
10 |
-
return "Please upload a PDF and enter a question."
|
11 |
-
# index uploaded PDF (idempotent for small demos)
|
12 |
-
rag.index_document(pdf_file.name, doc_id_prefix="upload")
|
13 |
-
out = rag.query(question, k=4)
|
14 |
-
return out["answer"]
|
15 |
-
|
16 |
-
demo = gr.Interface(
|
17 |
-
fn=chat_with_pdf,
|
18 |
-
inputs=[gr.File(label="Upload PDF", file_types=[".pdf"]),
|
19 |
-
gr.Textbox(label="Ask a question")],
|
20 |
-
outputs=gr.Textbox(label="Answer"),
|
21 |
-
title="PDF RAG (Chroma + Groq)",
|
22 |
-
description="Upload a PDF, ask a question. Uses Chroma for retrieval and Groq LLM for answering."
|
23 |
-
)
|
24 |
-
|
25 |
-
if __name__ == "__main__":
|
26 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|