Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from rag_pipeline import load_rag_chain
|
3 |
|
|
|
4 |
rag_chain = load_rag_chain()
|
5 |
|
|
|
6 |
def ask_question(query):
|
7 |
result = rag_chain.invoke(query)
|
8 |
return result['result']
|
9 |
|
10 |
-
iface = gr.Interface(
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
if __name__ == "__main__":
|
16 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from rag_pipeline import load_rag_chain
|
3 |
|
4 |
+
# Load the RAG chain once
|
5 |
rag_chain = load_rag_chain()
|
6 |
|
7 |
+
# Gradio interface
|
8 |
def ask_question(query):
|
9 |
result = rag_chain.invoke(query)
|
10 |
return result['result']
|
11 |
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=ask_question,
|
14 |
+
inputs=gr.Textbox(lines=3, placeholder="Ask something from your PDF...", label="Your Question"),
|
15 |
+
outputs="text",
|
16 |
+
title="🧠 Custom PDF Chatbot (Hugging Face)",
|
17 |
+
description="Ask questions from your own uploaded PDF data."
|
18 |
+
)
|
19 |
|
20 |
if __name__ == "__main__":
|
21 |
+
iface.launch()
|