Update app.py
Browse files
app.py
CHANGED
|
@@ -119,12 +119,9 @@ def extract_text_from_txt(file_path_or_obj):
|
|
| 119 |
if isinstance(file_path_or_obj, str):
|
| 120 |
with open(file_path_or_obj, 'rb') as f: content = f.read()
|
| 121 |
elif hasattr(file_path_or_obj, 'read'):
|
| 122 |
-
# CORRIGIDO: Bloco try/except indentado corretamente
|
| 123 |
if hasattr(file_path_or_obj, 'seek') and callable(file_path_or_obj.seek):
|
| 124 |
-
try:
|
| 125 |
-
|
| 126 |
-
except Exception as seek_e:
|
| 127 |
-
logger.warning(f"Não foi possível resetar ponteiro do arquivo TXT: {seek_e}")
|
| 128 |
content = file_path_or_obj.read()
|
| 129 |
else: return "❌ Input TXT inválido."
|
| 130 |
for enc in encodings:
|
|
@@ -278,9 +275,15 @@ def corrigir_peticao(caso, tipo_peticao, peticao_texto=None, peticao_arquivo=Non
|
|
| 278 |
if pet_corr_bruta.startswith(("❌", "⏱️", "⚠️")): pet_corr = f"⚠️ Falha gerar corrigida:\n{pet_corr_bruta}"
|
| 279 |
else:
|
| 280 |
markers = ["excelentíssimo", "eméritos julgadores", "meritíssimo juízo"]
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
pet_corr = pos_corrigir_peticao(pet_extr, tipo_peticao)
|
| 285 |
html_diff, res_diff, crit_diff = calcular_diff_interno(pet_cont, pet_corr)
|
| 286 |
res_cache = {"analise_formatada":analise_fmt,"peticao_corrigida":pet_corr,"resumo_diff":res_diff,"criticas_diff":crit_diff,"diff_html":html_diff}
|
|
@@ -511,7 +514,7 @@ def interface_gradio():
|
|
| 511 |
concurrency_limit=1
|
| 512 |
).then(lambda: gr.update(value="", visible=False), outputs=processing_message)
|
| 513 |
|
| 514 |
-
config_update_btn.click(atualizar_config, [temperatura_slider, max_tokens_slider], config_status)
|
| 515 |
progresso_btn.click(calcular_progresso, outputs=progresso_output)
|
| 516 |
historico_btn.click(mostrar_historico, outputs=historico_output)
|
| 517 |
|
|
|
|
| 119 |
if isinstance(file_path_or_obj, str):
|
| 120 |
with open(file_path_or_obj, 'rb') as f: content = f.read()
|
| 121 |
elif hasattr(file_path_or_obj, 'read'):
|
|
|
|
| 122 |
if hasattr(file_path_or_obj, 'seek') and callable(file_path_or_obj.seek):
|
| 123 |
+
try: file_path_or_obj.seek(0)
|
| 124 |
+
except Exception as seek_e: logger.warning(f"Não foi possível resetar ponteiro TXT: {seek_e}")
|
|
|
|
|
|
|
| 125 |
content = file_path_or_obj.read()
|
| 126 |
else: return "❌ Input TXT inválido."
|
| 127 |
for enc in encodings:
|
|
|
|
| 275 |
if pet_corr_bruta.startswith(("❌", "⏱️", "⚠️")): pet_corr = f"⚠️ Falha gerar corrigida:\n{pet_corr_bruta}"
|
| 276 |
else:
|
| 277 |
markers = ["excelentíssimo", "eméritos julgadores", "meritíssimo juízo"]
|
| 278 |
+
start_index = -1
|
| 279 |
+
p_lower = pet_corr_bruta.lower()
|
| 280 |
+
# CORRIGIDO: Bloco for com indentação correta
|
| 281 |
+
for m in markers:
|
| 282 |
+
idx = p_lower.find(m)
|
| 283 |
+
if idx != -1:
|
| 284 |
+
start_index = idx
|
| 285 |
+
break
|
| 286 |
+
pet_extr = pet_corr_bruta[start_index:] if start_index != -1 else pet_corr_bruta
|
| 287 |
pet_corr = pos_corrigir_peticao(pet_extr, tipo_peticao)
|
| 288 |
html_diff, res_diff, crit_diff = calcular_diff_interno(pet_cont, pet_corr)
|
| 289 |
res_cache = {"analise_formatada":analise_fmt,"peticao_corrigida":pet_corr,"resumo_diff":res_diff,"criticas_diff":crit_diff,"diff_html":html_diff}
|
|
|
|
| 514 |
concurrency_limit=1
|
| 515 |
).then(lambda: gr.update(value="", visible=False), outputs=processing_message)
|
| 516 |
|
| 517 |
+
config_update_btn.click(atualizar_config, [temperatura_slider, max_tokens_slider], config_status)
|
| 518 |
progresso_btn.click(calcular_progresso, outputs=progresso_output)
|
| 519 |
historico_btn.click(mostrar_historico, outputs=historico_output)
|
| 520 |
|