Sybghat commited on
Commit
670bb5f
1 Parent(s): dce1aa8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -1,10 +1,24 @@
1
- import gradio as gr
2
- context = "The Amazon rainforest, also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname and French Guiana. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species."
3
- question = "Which continent is the Amazon rainforest in?"
4
- gr.Interface.load(
5
- "huggingface/deepset/roberta-base-squad2",
6
- theme="default",
7
- inputs=[gr.inputs.Textbox(lines=7, default=context, label="Context paragraph"), gr.inputs.Textbox(lines=2, default=question, label="Question")],
8
- outputs=[gr.outputs.Textbox(label="Answer"), gr.outputs.Textbox(label="Score")],
9
- title=None,
10
- description="Provide your own paragraph and ask any question about the text. How well does the model answer?").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from Q_A import QuestionAnswering
3
+
4
+ st.title('Answering Question from a Document with Reference Text')
5
+ st.write("Loading the models...")
6
+ qa = QuestionAnswering()
7
+ st.write('Models Loaded')
8
+
9
+
10
+ document_text = st.text_area("Document Text", "", height=100)
11
+ query = st.text_input("Query")
12
+
13
+
14
+ #if st.button("Get Answers From Document"):
15
+ if len(document_text.strip()) > 0 and len(query.strip()) > 0:
16
+ st.write('Fetching answer...')
17
+ answers_lines = qa.fetch_answers(query, document_text).splitlines()
18
+ answer_first = answers_lines[0]
19
+ reference_first = answers_lines[1]
20
+ st.write('Check the answer below...with reference text')
21
+ st.header("ANSWER: "+answer_first)
22
+ st.subheader("REFERENCE: "+reference_first)
23
+ #st.markdown()
24
+