Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from documents.loader import DocumentLoader | |
| from utils.rag_pipeline import RAGPipeline | |
| loader = DocumentLoader() | |
| rag = RAGPipeline() | |
| def process_query(question, history): | |
| return f"AI Tutor: I received your question: {question}" | |
| def upload_file(file): | |
| return f"Uploaded: {file.name}" | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# AI Tutor for Exam Preparation") | |
| with gr.Row(): | |
| with gr.Column(): | |
| file_input = gr.File(label="Upload PDF/Image") | |
| upload_btn = gr.Button("Upload") | |
| upload_output = gr.Textbox(label="Upload Status") | |
| with gr.Column(): | |
| chatbot = gr.Chatbot() | |
| msg = gr.Textbox(label="Your question") | |
| send_btn = gr.Button("Send") | |
| upload_btn.click(upload_file, inputs=file_input, outputs=upload_output) | |
| send_btn.click(process_query, inputs=msg, outputs=chatbot) | |
| demo.launch() | |