rithwikreal commited on
Commit
81b6a4f
·
verified ·
1 Parent(s): eb411b5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ qa = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")
5
+
6
+ def answer(question, context):
7
+ if not context.strip():
8
+ return "Please upload or paste content first."
9
+ return qa(question=question, context=context)["answer"]
10
+
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown("## Free AI Document Chatbot")
13
+
14
+ context = gr.Textbox(label="Paste document text here", lines=10)
15
+ question = gr.Textbox(label="Ask a question")
16
+
17
+ output = gr.Textbox(label="Answer")
18
+
19
+ ask = gr.Button("Ask")
20
+
21
+ ask.click(answer, [question, context], output)
22
+
23
+ demo.launch()