MaawaKhalid commited on
Commit
d00f8b0
·
verified ·
1 Parent(s): fb1b355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -16
app.py CHANGED
@@ -1,25 +1,20 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the model and tokenizer from Hugging Face
5
  qa_pipeline = pipeline('question-answering', model='MaawaKhalid/Extractive-QA-Bot')
6
 
7
- # Define the function to answer questions
8
- def answer_question(context, question):
9
- result = qa_pipeline(question=question, context=context)
10
  return result['answer']
11
 
12
- # Create a simple Gradio interface
13
- interface = gr.Interface(
14
- fn=answer_question,
15
  inputs=[
16
- gr.inputs.Textbox(label="Context", placeholder="Enter some text to ask questions from"),
17
- gr.inputs.Textbox(label="Question", placeholder="Ask a question based on the context")
18
  ],
19
- outputs="text",
20
- title="Extractive QA Bot",
21
- description="Ask questions and get answers based on the provided context."
22
- )
23
-
24
- # Launch the interface
25
- interface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load your QA model
5
  qa_pipeline = pipeline('question-answering', model='MaawaKhalid/Extractive-QA-Bot')
6
 
7
+ # Define a function to handle the QA
8
+ def qa_function(context, question):
9
+ result = qa_pipeline({'context': context, 'question': question})
10
  return result['answer']
11
 
12
+ # Create a Gradio interface
13
+ gr.Interface(
14
+ fn=qa_function,
15
  inputs=[
16
+ gr.components.Textbox(label="Context", placeholder="Enter some text to ask questions from"),
17
+ gr.components.Textbox(label="Question", placeholder="Enter your question")
18
  ],
19
+ outputs=gr.components.Textbox(label="Answer")
20
+ ).launch()