Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,6 @@ def user(input_question, history, qa_bot_state):
|
|
23 |
def legal_doc_qa_bot(input_document, history):
|
24 |
bot_message = question_answer(input_document, history)
|
25 |
history[-1][1] = bot_message
|
26 |
-
# time.sleep(1)
|
27 |
return history
|
28 |
|
29 |
|
@@ -35,32 +34,24 @@ with gr.Blocks() as demo:
|
|
35 |
qa_bot_state = gr.State(value=[])
|
36 |
|
37 |
with gr.Tabs():
|
38 |
-
with gr.TabItem("Q&A"):
|
|
|
39 |
with gr.Row():
|
40 |
with gr.Column():
|
41 |
input_document = gr.Text(label="Copy your document here", lines=10)
|
42 |
|
43 |
with gr.Column():
|
44 |
chatbot = gr.Chatbot(label="Chat History")
|
45 |
-
input_question = gr.Text(label="Ask a question")
|
46 |
clear = gr.Button("Clear")
|
47 |
|
48 |
with gr.Row():
|
49 |
with gr.Accordion("Show example inputs I can load:", open=False):
|
50 |
example_1 = gr.Button("Load GPL License Document")
|
51 |
example_2 = gr.Button("Load Pokemon Go Terms of Service")
|
52 |
-
# gr.Examples(
|
53 |
-
# [
|
54 |
-
# [GPL_LICENSE_DOC, GPL_LICENSE_QUESTION],
|
55 |
-
# [POKEMON_GO_TERMS_OF_SERVICE, POKEMON_GO_QUESTION],
|
56 |
-
# ],
|
57 |
-
# [input_document, input_question],
|
58 |
-
# [],
|
59 |
-
# None,
|
60 |
-
# cache_examples=False,
|
61 |
-
# )
|
62 |
|
63 |
with gr.TabItem("Summarize"):
|
|
|
64 |
with gr.Row():
|
65 |
with gr.Column():
|
66 |
summary_input = gr.Text(label="Document", lines=10)
|
@@ -101,16 +92,6 @@ with gr.Blocks() as demo:
|
|
101 |
with gr.Accordion("Show example inputs I can load:", open=False):
|
102 |
example_3 = gr.Button("Load GPL License Document")
|
103 |
example_4 = gr.Button("Load Pokemon Go Terms of Service")
|
104 |
-
# gr.Examples(
|
105 |
-
# [
|
106 |
-
# [GPL_LICENSE_DOC],
|
107 |
-
# [POKEMON_GO_TERMS_OF_SERVICE],
|
108 |
-
# ],
|
109 |
-
# [summary_input],
|
110 |
-
# [],
|
111 |
-
# None,
|
112 |
-
# cache_examples=False,
|
113 |
-
# )
|
114 |
|
115 |
with gr.TabItem("Document Search"):
|
116 |
gr.HTML("""<p style="text-align:center;"><b>Search across a set of legal documents in any language or even a mix of languages. Query them using any one of over 100 supported languages.</p>""")
|
@@ -166,28 +147,32 @@ with gr.Blocks() as demo:
|
|
166 |
|
167 |
# reset the chatbot Q&A history when input document changes
|
168 |
input_document.change(fn=reset_chatbot, inputs=[], outputs=chatbot)
|
169 |
-
|
|
|
170 |
example_1.click(
|
171 |
load_gpl_license,
|
172 |
[],
|
173 |
[input_document, input_question],
|
174 |
queue=False,
|
175 |
)
|
176 |
-
|
|
|
177 |
example_2.click(
|
178 |
load_pokemon_license,
|
179 |
[],
|
180 |
[input_document, input_question],
|
181 |
queue=False,
|
182 |
)
|
183 |
-
|
|
|
184 |
example_3.click(
|
185 |
load_gpl_license,
|
186 |
[],
|
187 |
[summary_input, invisible_comp],
|
188 |
queue=False,
|
189 |
)
|
190 |
-
|
|
|
191 |
example_4.click(
|
192 |
load_pokemon_license,
|
193 |
[],
|
|
|
23 |
def legal_doc_qa_bot(input_document, history):
|
24 |
bot_message = question_answer(input_document, history)
|
25 |
history[-1][1] = bot_message
|
|
|
26 |
return history
|
27 |
|
28 |
|
|
|
34 |
qa_bot_state = gr.State(value=[])
|
35 |
|
36 |
with gr.Tabs():
|
37 |
+
with gr.TabItem("Q&A"):
|
38 |
+
gr.HTML("""<p style="text-align:center;"><b>Legal documents can be difficult to comprehend and understand. Add a legal document below and ask any questions related to it.</p>""")
|
39 |
with gr.Row():
|
40 |
with gr.Column():
|
41 |
input_document = gr.Text(label="Copy your document here", lines=10)
|
42 |
|
43 |
with gr.Column():
|
44 |
chatbot = gr.Chatbot(label="Chat History")
|
45 |
+
input_question = gr.Text(label="Ask a question", placeholder="Type a question here and hit enter.")
|
46 |
clear = gr.Button("Clear")
|
47 |
|
48 |
with gr.Row():
|
49 |
with gr.Accordion("Show example inputs I can load:", open=False):
|
50 |
example_1 = gr.Button("Load GPL License Document")
|
51 |
example_2 = gr.Button("Load Pokemon Go Terms of Service")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
with gr.TabItem("Summarize"):
|
54 |
+
gr.HTML("""<p style="text-align:center;"><b>Legal documents can be very lengthy. Add a legal document below and generate a quick summary for it.</p>""")
|
55 |
with gr.Row():
|
56 |
with gr.Column():
|
57 |
summary_input = gr.Text(label="Document", lines=10)
|
|
|
92 |
with gr.Accordion("Show example inputs I can load:", open=False):
|
93 |
example_3 = gr.Button("Load GPL License Document")
|
94 |
example_4 = gr.Button("Load Pokemon Go Terms of Service")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
with gr.TabItem("Document Search"):
|
97 |
gr.HTML("""<p style="text-align:center;"><b>Search across a set of legal documents in any language or even a mix of languages. Query them using any one of over 100 supported languages.</p>""")
|
|
|
147 |
|
148 |
# reset the chatbot Q&A history when input document changes
|
149 |
input_document.change(fn=reset_chatbot, inputs=[], outputs=chatbot)
|
150 |
+
|
151 |
+
# load gpl example for Q&A task
|
152 |
example_1.click(
|
153 |
load_gpl_license,
|
154 |
[],
|
155 |
[input_document, input_question],
|
156 |
queue=False,
|
157 |
)
|
158 |
+
|
159 |
+
# load pokemon go example for Q&A task
|
160 |
example_2.click(
|
161 |
load_pokemon_license,
|
162 |
[],
|
163 |
[input_document, input_question],
|
164 |
queue=False,
|
165 |
)
|
166 |
+
|
167 |
+
# load gpl example for summarization task
|
168 |
example_3.click(
|
169 |
load_gpl_license,
|
170 |
[],
|
171 |
[summary_input, invisible_comp],
|
172 |
queue=False,
|
173 |
)
|
174 |
+
|
175 |
+
# load pokemon go example for summarization task
|
176 |
example_4.click(
|
177 |
load_pokemon_license,
|
178 |
[],
|