Spaces:
Running
Running
Alexander Sanchez commited on
Commit ·
445a455
1
Parent(s): 456bf68
prompt visibility updated
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ load_dotenv()
|
|
| 26 |
|
| 27 |
# ── Inicialización ────────────────────────────────────────────────────────────
|
| 28 |
|
| 29 |
-
print("
|
| 30 |
|
| 31 |
vs = VectorStore()
|
| 32 |
|
|
@@ -129,8 +129,9 @@ def corregir(htr_text: str, top_k: int, mostrar_prompt: bool):
|
|
| 129 |
|
| 130 |
status = f" Corrección completada con **{result['model']}** · {vs.count()} docs en índice"
|
| 131 |
|
| 132 |
-
return corrected, docs_md, analysis_md, diff_md, status
|
| 133 |
-
|
|
|
|
| 134 |
|
| 135 |
def evaluar_par(htr_text: str, gt_text: str):
|
| 136 |
if not htr_text.strip() or not gt_text.strip():
|
|
@@ -157,7 +158,7 @@ def evaluar_par(htr_text: str, gt_text: str):
|
|
| 157 |
report += f"\n**Texto corregido por RAG:**\n> {result['corrected']}"
|
| 158 |
return report
|
| 159 |
except Exception as e:
|
| 160 |
-
return f"
|
| 161 |
|
| 162 |
|
| 163 |
def add_to_corpus(htr_text: str, gt_text: str, doc_type: str, region: str, date: str, caligrafia: str):
|
|
@@ -180,7 +181,7 @@ def add_to_corpus(htr_text: str, gt_text: str, doc_type: str, region: str, date:
|
|
| 180 |
if added:
|
| 181 |
return f" Par añadido al corpus con id `{pair_id}`. Total: {vs.count()} docs."
|
| 182 |
else:
|
| 183 |
-
return f"
|
| 184 |
except Exception as e:
|
| 185 |
return f" Error: {e}"
|
| 186 |
|
|
@@ -251,12 +252,12 @@ with gr.Blocks(
|
|
| 251 |
analysis_out = gr.Markdown(label="Pattern analysis")
|
| 252 |
|
| 253 |
diff_out = gr.Markdown(label="Word-by-word differences")
|
| 254 |
-
prompt_out = gr.Markdown(label="Prompt sent to the LLM", visible=
|
| 255 |
|
| 256 |
btn_corregir.click(
|
| 257 |
fn=corregir,
|
| 258 |
inputs=[htr_input, top_k_slider, show_prompt],
|
| 259 |
-
outputs=[corrected_out, docs_out, analysis_out, diff_out, status_out],
|
| 260 |
)
|
| 261 |
|
| 262 |
# ── Pestaña 2: Evaluación ─────────────────────────────────────────────
|
|
|
|
| 26 |
|
| 27 |
# ── Inicialización ────────────────────────────────────────────────────────────
|
| 28 |
|
| 29 |
+
print(" Inicializando Scriptorium RAG...")
|
| 30 |
|
| 31 |
vs = VectorStore()
|
| 32 |
|
|
|
|
| 129 |
|
| 130 |
status = f" Corrección completada con **{result['model']}** · {vs.count()} docs en índice"
|
| 131 |
|
| 132 |
+
#return corrected, docs_md, analysis_md, diff_md, status
|
| 133 |
+
prompt_visible = result["prompt"] if mostrar_prompt else ""
|
| 134 |
+
return corrected, docs_md, analysis_md, diff_md, status, prompt_visible
|
| 135 |
|
| 136 |
def evaluar_par(htr_text: str, gt_text: str):
|
| 137 |
if not htr_text.strip() or not gt_text.strip():
|
|
|
|
| 158 |
report += f"\n**Texto corregido por RAG:**\n> {result['corrected']}"
|
| 159 |
return report
|
| 160 |
except Exception as e:
|
| 161 |
+
return f" Error: {e}"
|
| 162 |
|
| 163 |
|
| 164 |
def add_to_corpus(htr_text: str, gt_text: str, doc_type: str, region: str, date: str, caligrafia: str):
|
|
|
|
| 181 |
if added:
|
| 182 |
return f" Par añadido al corpus con id `{pair_id}`. Total: {vs.count()} docs."
|
| 183 |
else:
|
| 184 |
+
return f" Par ya existía en el corpus (id: `{pair_id}`)."
|
| 185 |
except Exception as e:
|
| 186 |
return f" Error: {e}"
|
| 187 |
|
|
|
|
| 252 |
analysis_out = gr.Markdown(label="Pattern analysis")
|
| 253 |
|
| 254 |
diff_out = gr.Markdown(label="Word-by-word differences")
|
| 255 |
+
prompt_out = gr.Markdown(label="Prompt sent to the LLM", visible=True)
|
| 256 |
|
| 257 |
btn_corregir.click(
|
| 258 |
fn=corregir,
|
| 259 |
inputs=[htr_input, top_k_slider, show_prompt],
|
| 260 |
+
outputs=[corrected_out, docs_out, analysis_out, diff_out, status_out, prompt_out],
|
| 261 |
)
|
| 262 |
|
| 263 |
# ── Pestaña 2: Evaluación ─────────────────────────────────────────────
|