Update app.py
Browse files
app.py
CHANGED
|
@@ -104,7 +104,8 @@ def process_input(text, rag, prompt_template):
|
|
| 104 |
"""
|
| 105 |
output = generate(prompt)
|
| 106 |
|
| 107 |
-
return output
|
|
|
|
| 108 |
|
| 109 |
def create_interface():
|
| 110 |
# Definimos los componentes de la interfaz
|
|
@@ -126,17 +127,18 @@ def create_interface():
|
|
| 126 |
|
| 127 |
# Definimos la funci贸n que se ejecutar谩 cuando se env铆e la entrada
|
| 128 |
def fn(text, rag, prompt_template):
|
| 129 |
-
|
|
|
|
| 130 |
output = process_input(text, rag, prompt_template)
|
| 131 |
-
matches = re.findall(r'"tipo"\s*:\s*"(.*?)"', output)
|
| 132 |
classification_types = matches
|
| 133 |
classification_types_options = [(option, option) for option in classification_types]
|
| 134 |
classification_types_checkboxes = gr.CheckboxGroup(label="Clasificacion Tipo", choices=classification_types_options,value=[option[0] for option in classification_types_options], interactive = True)
|
| 135 |
|
| 136 |
# Resalta las partes del texto que se encuentran en la variable output en rojo
|
| 137 |
-
highlighted_text = highlight_text(text, output, color="red")
|
| 138 |
|
| 139 |
-
return highlighted_text, classification_types_checkboxes, output
|
| 140 |
|
| 141 |
examples = [
|
| 142 |
[recorte, False, True]
|
|
@@ -149,7 +151,7 @@ def create_interface():
|
|
| 149 |
iface = gr.Interface(
|
| 150 |
fn=fn,
|
| 151 |
inputs=[input_text, rag_checkbox, prompt_template],
|
| 152 |
-
outputs=["html", classification_types_checkboxes,
|
| 153 |
examples=examples,
|
| 154 |
allow_flagging="manual",
|
| 155 |
flagging_options=["馃憤", "馃憥"],
|
|
|
|
| 104 |
"""
|
| 105 |
output = generate(prompt)
|
| 106 |
|
| 107 |
+
return output,prompt
|
| 108 |
+
|
| 109 |
|
| 110 |
def create_interface():
|
| 111 |
# Definimos los componentes de la interfaz
|
|
|
|
| 127 |
|
| 128 |
# Definimos la funci贸n que se ejecutar谩 cuando se env铆e la entrada
|
| 129 |
def fn(text, rag, prompt_template):
|
| 130 |
+
|
| 131 |
+
output = []
|
| 132 |
output = process_input(text, rag, prompt_template)
|
| 133 |
+
matches = re.findall(r'"tipo"\s*:\s*"(.*?)"', output[0])
|
| 134 |
classification_types = matches
|
| 135 |
classification_types_options = [(option, option) for option in classification_types]
|
| 136 |
classification_types_checkboxes = gr.CheckboxGroup(label="Clasificacion Tipo", choices=classification_types_options,value=[option[0] for option in classification_types_options], interactive = True)
|
| 137 |
|
| 138 |
# Resalta las partes del texto que se encuentran en la variable output en rojo
|
| 139 |
+
highlighted_text = highlight_text(text, output[0], color="red")
|
| 140 |
|
| 141 |
+
return highlighted_text, classification_types_checkboxes, output[0], output[1]
|
| 142 |
|
| 143 |
examples = [
|
| 144 |
[recorte, False, True]
|
|
|
|
| 151 |
iface = gr.Interface(
|
| 152 |
fn=fn,
|
| 153 |
inputs=[input_text, rag_checkbox, prompt_template],
|
| 154 |
+
outputs=["html", classification_types_checkboxes, "text", "text"],
|
| 155 |
examples=examples,
|
| 156 |
allow_flagging="manual",
|
| 157 |
flagging_options=["馃憤", "馃憥"],
|