Spaces:
Sleeping
Sleeping
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() |