nikhilwani commited on
Commit
91fa53c
1 Parent(s): 96aa1bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -2
app.py CHANGED
@@ -1,5 +1,29 @@
1
  import gradio as gr
 
2
 
3
- # Create a simple Gradio interface
4
- demo = gr.Interface.load("models/microsoft/DialoGPT-medium")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  demo.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load the model from Hugging Face
5
+ qa_pipeline = pipeline("question-answering", model="nikhilwani/question_answering")
6
+
7
+ # Define the QA function
8
+ def answer_question(context, question):
9
+ result = qa_pipeline(question=question, context=context)
10
+ return result["answer"]
11
+
12
+ # Create a Gradio app using the new syntax for Gradio 5.5.0
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# Question Answering")
15
+ gr.Markdown("Provide context and ask a question to get an answer.")
16
+
17
+ with gr.Row():
18
+ context_input = gr.Textbox(lines=5, placeholder="Enter the context here...", label="Context")
19
+ question_input = gr.Textbox(placeholder="Ask your question here...", label="Question")
20
+
21
+ with gr.Row():
22
+ submit_button = gr.Button("Submit")
23
+ output_box = gr.Textbox(label="Answer")
24
+
25
+ # Connect the function to the components
26
+ submit_button.click(answer_question, inputs=[context_input, question_input], outputs=output_box)
27
+
28
+ # Launch the app
29
  demo.launch()