Spaces:
Sleeping
Sleeping
Lautaro Cardarelli
commited on
Commit
·
ed5c58f
1
Parent(s):
f12740c
try disable questions button
Browse files
app.py
CHANGED
|
@@ -127,17 +127,8 @@ class SummarizerAndQA:
|
|
| 127 |
self.study_generated_questions = ''
|
| 128 |
self.question_response = ''
|
| 129 |
|
| 130 |
-
def
|
| 131 |
-
|
| 132 |
-
self.input_text = text
|
| 133 |
-
self.summary = generate_summary(text)
|
| 134 |
-
self.study_generated_questions = generate_questions(text)
|
| 135 |
-
|
| 136 |
-
if question != self.question and text != '':
|
| 137 |
-
self.question = question
|
| 138 |
-
self.question_response = generate_question_response(question, text)
|
| 139 |
-
|
| 140 |
-
return self.summary, self.study_generated_questions, self.question_response
|
| 141 |
|
| 142 |
def process_summarizer(self, text):
|
| 143 |
self.input_text = text
|
|
@@ -152,19 +143,11 @@ class SummarizerAndQA:
|
|
| 152 |
summarizer_and_qa = SummarizerAndQA()
|
| 153 |
|
| 154 |
textbox_input = gr.Textbox(label="Pega el text aca:", placeholder="Texto...", lines=15)
|
| 155 |
-
question_input = gr.Textbox(label="Pregunta sobre el texto aca:", placeholder="Mensaje...", lines=15)
|
| 156 |
summary_output = gr.Textbox(label="Resumen", lines=15)
|
| 157 |
questions_output = gr.Textbox(label="Preguntas de guia generadas", lines=5)
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
# demo = gr.Interface(fn=summarizer_and_qa.process, inputs=[textbox_input, question_input], outputs=[summary_output, questions_output, questions_response], allow_flagging="never")
|
| 162 |
-
# demo.launch()
|
| 163 |
-
|
| 164 |
-
|
| 165 |
|
| 166 |
-
# --------------
|
| 167 |
summarizer_interface = gr.Interface(fn=summarizer_and_qa.process_summarizer, inputs=[textbox_input], outputs=[summary_output], allow_flagging="never")
|
| 168 |
-
questions_interface = gr.Interface(fn=summarizer_and_qa.process_questions, inputs=[], outputs=[questions_output], allow_flagging="never")
|
| 169 |
chatbot_interface = gr.ChatInterface(fn=summarizer_and_qa.process_question_response, type="messages", examples=[], title="Preguntas sobre el texto")
|
| 170 |
gr.TabbedInterface([summarizer_interface, questions_interface, chatbot_interface], ["Resumidor", "Preguntas de guia", "Chatbot"]).launch()
|
|
|
|
| 127 |
self.study_generated_questions = ''
|
| 128 |
self.question_response = ''
|
| 129 |
|
| 130 |
+
def is_text_loaded(self):
|
| 131 |
+
return self.input_text != ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
def process_summarizer(self, text):
|
| 134 |
self.input_text = text
|
|
|
|
| 143 |
summarizer_and_qa = SummarizerAndQA()
|
| 144 |
|
| 145 |
textbox_input = gr.Textbox(label="Pega el text aca:", placeholder="Texto...", lines=15)
|
|
|
|
| 146 |
summary_output = gr.Textbox(label="Resumen", lines=15)
|
| 147 |
questions_output = gr.Textbox(label="Preguntas de guia generadas", lines=5)
|
| 148 |
+
questions_generate_button = gr.Button("Generate", variant="primary", interactive=summarizer_and_qa.is_text_loaded())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
|
|
|
| 150 |
summarizer_interface = gr.Interface(fn=summarizer_and_qa.process_summarizer, inputs=[textbox_input], outputs=[summary_output], allow_flagging="never")
|
| 151 |
+
questions_interface = gr.Interface(fn=summarizer_and_qa.process_questions, inputs=[], outputs=[questions_output], allow_flagging="never", submit_btn=questions_generate_button)
|
| 152 |
chatbot_interface = gr.ChatInterface(fn=summarizer_and_qa.process_question_response, type="messages", examples=[], title="Preguntas sobre el texto")
|
| 153 |
gr.TabbedInterface([summarizer_interface, questions_interface, chatbot_interface], ["Resumidor", "Preguntas de guia", "Chatbot"]).launch()
|