Spaces:
Sleeping
Sleeping
File size: 715 Bytes
e02136d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
from rag_system import RAGPipeline
rag = RAGPipeline()
def chat_with_pdf(pdf_file, question):
if pdf_file is None or question.strip() == "":
return "Please upload a PDF and enter a question."
# Index the PDF
rag.index_document(pdf_file.name)
# Query the indexed document
return rag.query(question)
interface = gr.Interface(
fn=chat_with_pdf,
inputs=[
gr.File(label="Upload PDF", file_types=[".pdf"]),
gr.Textbox(label="Ask a question")
],
outputs=gr.Textbox(label="Answer"),
title="Chat with your PDF",
description="Upload a PDF and ask questions about its content"
)
if __name__ == "__main__":
interface.launch() |