Alexander Sanchez commited on
Commit
f1d274f
Β·
1 Parent(s): 563ceb8

name updated

Browse files
Files changed (1) hide show
  1. app.py +26 -26
app.py CHANGED
@@ -205,7 +205,7 @@ with gr.Blocks(
205
  # ── Header ────────────────────────────────────────────────────────────────
206
  gr.HTML("""
207
  <div class="header">
208
- <h1>RAG CODEX for Historical Spanish'</h1>
209
  <p>RAG system of Spanish correction from the 16th century</p>
210
  </div>
211
  """)
@@ -213,31 +213,31 @@ with gr.Blocks(
213
  with gr.Tabs():
214
 
215
  # ── PestaΓ±a 1: CorrecciΓ³n ─────────────────────────────────────────────
216
- with gr.TabItem(" CorrecciΓ³n HTR"):
217
  with gr.Row():
218
  with gr.Column(scale=2):
219
  htr_input = gr.Textbox(
220
- label="Texto HTR (entrada del reconocedor)",
221
- placeholder="Pega aquΓ­ el texto resultado del HTR…",
222
  lines=6,
223
  )
224
  with gr.Row():
225
  top_k_slider = gr.Slider(
226
  minimum=1, maximum=10, value=5, step=1,
227
- label="Documentos recuperados (k)",
228
  )
229
- show_prompt = gr.Checkbox(label="Mostrar prompt RAG", value=False)
230
- btn_corregir = gr.Button("✦ Corregir con RAG", variant="primary")
231
 
232
  gr.Examples(
233
  examples=DEMO_EXAMPLES,
234
  inputs=htr_input,
235
- label="Ejemplos de demostraciΓ³n",
236
  )
237
 
238
  with gr.Column(scale=2):
239
  corrected_out = gr.Textbox(
240
- label="Texto corregido (salida RAG)",
241
  lines=6,
242
  interactive=False,
243
  )
@@ -245,12 +245,12 @@ with gr.Blocks(
245
 
246
  with gr.Row():
247
  with gr.Column():
248
- docs_out = gr.Markdown(label="Documentos recuperados del corpus")
249
  with gr.Column():
250
- analysis_out = gr.Markdown(label="AnΓ‘lisis de patrones")
251
 
252
- diff_out = gr.Markdown(label="Diferencias palabra a palabra")
253
- prompt_out = gr.Markdown(label="Prompt enviado al LLM", visible=False)
254
 
255
  btn_corregir.click(
256
  fn=corregir,
@@ -259,26 +259,26 @@ with gr.Blocks(
259
  )
260
 
261
  # ── PestaΓ±a 2: EvaluaciΓ³n ─────────────────────────────────────────────
262
- with gr.TabItem(" EvaluaciΓ³n con GT"):
263
- gr.Markdown("Compara la correcciΓ³n RAG contra el groundtruth real para medir CER/WER y detectar modernismos.")
264
  with gr.Row():
265
- eval_htr = gr.Textbox(label="Texto HTR", lines=4)
266
- eval_gt = gr.Textbox(label="Groundtruth (referencia)", lines=4)
267
- btn_eval = gr.Button("Evaluar", variant="primary")
268
  eval_out = gr.Markdown()
269
  btn_eval.click(fn=evaluar_par, inputs=[eval_htr, eval_gt], outputs=eval_out)
270
 
271
  # ── PestaΓ±a 3: AΓ±adir al corpus ───────────────────────────────────────
272
- with gr.TabItem("βž• AΓ±adir al corpus"):
273
- gr.Markdown("AΓ±ade nuevos pares al vector store para mejorar el RAG de forma continua.")
274
  with gr.Row():
275
  add_htr = gr.Textbox(label="Texto HTR", lines=4)
276
  add_gt = gr.Textbox(label="Groundtruth corregido", lines=4)
277
  with gr.Row():
278
- add_type = gr.Textbox(label="Tipo documental", placeholder="notarial / judicial / eclesiastico")
279
- add_region = gr.Textbox(label="RegiΓ³n", placeholder="Castilla, AndalucΓ­a…")
280
- add_date = gr.Textbox(label="Fecha", placeholder="1542")
281
- btn_add = gr.Button("AΓ±adir al corpus", variant="primary")
282
  add_out = gr.Markdown()
283
  btn_add.click(
284
  fn=add_to_corpus,
@@ -287,9 +287,9 @@ with gr.Blocks(
287
  )
288
 
289
  # ── PestaΓ±a 4: Info del sistema ───────────────────────────────────────
290
- with gr.TabItem("β„Ή Sistema"):
291
  gr.Markdown(f"""
292
- ## Estado del sistema
293
 
294
  - **Modelo LLM:** {os.getenv('OPENAI_MODEL', 'gpt-4o')}
295
  - **Vector store:** ChromaDB (persistente en `{os.getenv('CHROMA_PATH','./chroma_db')}`)
 
205
  # ── Header ────────────────────────────────────────────────────────────────
206
  gr.HTML("""
207
  <div class="header">
208
+ <h1>RAG CODEX for Historical Spanish</h1>
209
  <p>RAG system of Spanish correction from the 16th century</p>
210
  </div>
211
  """)
 
213
  with gr.Tabs():
214
 
215
  # ── PestaΓ±a 1: CorrecciΓ³n ─────────────────────────────────────────────
216
+ with gr.TabItem(" HTR Correction"):
217
  with gr.Row():
218
  with gr.Column(scale=2):
219
  htr_input = gr.Textbox(
220
+ label="HTR text (recognizer input)",
221
+ placeholder="Paste the HTR result here…",
222
  lines=6,
223
  )
224
  with gr.Row():
225
  top_k_slider = gr.Slider(
226
  minimum=1, maximum=10, value=5, step=1,
227
+ label="Documents retrieved (k)",
228
  )
229
+ show_prompt = gr.Checkbox(label="Show RAG prompt", value=False)
230
+ btn_corregir = gr.Button("✦ Correct with RAG", variant="primary")
231
 
232
  gr.Examples(
233
  examples=DEMO_EXAMPLES,
234
  inputs=htr_input,
235
+ label="Demonstration examples",
236
  )
237
 
238
  with gr.Column(scale=2):
239
  corrected_out = gr.Textbox(
240
+ label="Corrected text (RAG output)",
241
  lines=6,
242
  interactive=False,
243
  )
 
245
 
246
  with gr.Row():
247
  with gr.Column():
248
+ docs_out = gr.Markdown(label="Documents recovered from the corpus")
249
  with gr.Column():
250
+ analysis_out = gr.Markdown(label="Pattern analysis")
251
 
252
+ diff_out = gr.Markdown(label="Word-by-word differences")
253
+ prompt_out = gr.Markdown(label="Prompt sent to the LLM", visible=False)
254
 
255
  btn_corregir.click(
256
  fn=corregir,
 
259
  )
260
 
261
  # ── PestaΓ±a 2: EvaluaciΓ³n ─────────────────────────────────────────────
262
+ with gr.TabItem(" Evaluation with GT"):
263
+ gr.Markdown("Compare the RAG correction against the actual groundtruth to measure CER/WER and detect modernisms.")
264
  with gr.Row():
265
+ eval_htr = gr.Textbox(label="HTR text", lines=4)
266
+ eval_gt = gr.Textbox(label="Groundtruth (reference)", lines=4)
267
+ btn_eval = gr.Button("Evaluate", variant="primary")
268
  eval_out = gr.Markdown()
269
  btn_eval.click(fn=evaluar_par, inputs=[eval_htr, eval_gt], outputs=eval_out)
270
 
271
  # ── PestaΓ±a 3: AΓ±adir al corpus ───────────────────────────────────────
272
+ with gr.TabItem("βž• Add to corpus"):
273
+ gr.Markdown("Add new pairs to the vector store to improve the RAG continuously.")
274
  with gr.Row():
275
  add_htr = gr.Textbox(label="Texto HTR", lines=4)
276
  add_gt = gr.Textbox(label="Groundtruth corregido", lines=4)
277
  with gr.Row():
278
+ add_type = gr.Textbox(label="Document type", placeholder="notarial / judicial / eclesiastico")
279
+ add_region = gr.Textbox(label="Region", placeholder="Castilla, AndalucΓ­a…")
280
+ add_date = gr.Textbox(label="Date", placeholder="1542")
281
+ btn_add = gr.Button("Add to corpus", variant="primary")
282
  add_out = gr.Markdown()
283
  btn_add.click(
284
  fn=add_to_corpus,
 
287
  )
288
 
289
  # ── PestaΓ±a 4: Info del sistema ───────────────────────────────────────
290
+ with gr.TabItem("β„Ή System"):
291
  gr.Markdown(f"""
292
+ ## System status
293
 
294
  - **Modelo LLM:** {os.getenv('OPENAI_MODEL', 'gpt-4o')}
295
  - **Vector store:** ChromaDB (persistente en `{os.getenv('CHROMA_PATH','./chroma_db')}`)