Spaces:
Sleeping
Sleeping
Lautaro Cardarelli
commited on
Commit
·
23ea224
1
Parent(s):
3fb83c0
add chat bot
Browse files
app.py
CHANGED
|
@@ -95,10 +95,34 @@ def generate_summary(text):
|
|
| 95 |
return summary
|
| 96 |
|
| 97 |
|
| 98 |
-
def
|
| 99 |
-
return
|
| 100 |
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
textbox_input = gr.Textbox(label="Pega el text aca:", placeholder="Texto...", lines=15)
|
| 103 |
question_input = gr.Textbox(label="Pregunta sobre el texto aca:", placeholder="Mensaje...", lines=15)
|
| 104 |
summary_output = gr.Textbox(label="Resumen", lines=15)
|
|
@@ -106,5 +130,5 @@ questions_output = gr.Textbox(label="Preguntas de guia generadas", lines=5)
|
|
| 106 |
questions_response = gr.Textbox(label="Respuestas", lines=5)
|
| 107 |
|
| 108 |
|
| 109 |
-
demo = gr.Interface(fn=process, inputs=[textbox_input, question_input], outputs=[summary_output, questions_output, questions_response])
|
| 110 |
demo.launch()
|
|
|
|
| 95 |
return summary
|
| 96 |
|
| 97 |
|
| 98 |
+
def generate_question_response(question):
|
| 99 |
+
return f'response: {question}'
|
| 100 |
|
| 101 |
|
| 102 |
+
class SummarizerAndQA:
|
| 103 |
+
def __init__(self):
|
| 104 |
+
self.input_text = ''
|
| 105 |
+
self.question = ''
|
| 106 |
+
|
| 107 |
+
self.summary = ''
|
| 108 |
+
self.study_generated_questions = ''
|
| 109 |
+
self.question_response = ''
|
| 110 |
+
|
| 111 |
+
def process(self, text, question):
|
| 112 |
+
if text != self.input_text:
|
| 113 |
+
self.input_text = text
|
| 114 |
+
self.summary = generate_summary(text)
|
| 115 |
+
self.study_generated_questions = generate_questions(text)
|
| 116 |
+
|
| 117 |
+
if question != self.question:
|
| 118 |
+
self.question = question
|
| 119 |
+
self.question_response = generate_question_response(question)
|
| 120 |
+
|
| 121 |
+
return self.summary, self.study_generated_questions, self.question_response
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
summarizer_and_qa = SummarizerAndQA()
|
| 125 |
+
|
| 126 |
textbox_input = gr.Textbox(label="Pega el text aca:", placeholder="Texto...", lines=15)
|
| 127 |
question_input = gr.Textbox(label="Pregunta sobre el texto aca:", placeholder="Mensaje...", lines=15)
|
| 128 |
summary_output = gr.Textbox(label="Resumen", lines=15)
|
|
|
|
| 130 |
questions_response = gr.Textbox(label="Respuestas", lines=5)
|
| 131 |
|
| 132 |
|
| 133 |
+
demo = gr.Interface(fn=summarizer_and_qa.process, inputs=[textbox_input, question_input], outputs=[summary_output, questions_output, questions_response], allow_flagging="never")
|
| 134 |
demo.launch()
|