Update app.py
Browse files
app.py
CHANGED
|
@@ -224,7 +224,7 @@ def estruturar_prompt_peticao_corrigida(caso, peticao_original, tipo_peticao):
|
|
| 224 |
elif tipo_peticao == "Impugnação à Contestação":
|
| 225 |
prompt += "1.Endereçamento, proc, autor, tempestividade. 2.Tópico: DA(S) PRELIMINAR(ES) - Rebater. 3.Tópico: DO MÉRITO E FATOS NOVOS - Manifestar. 4.Tópico: DA RATIFICAÇÃO INICIAL. 5.Tópico: DAS PROVAS - Especificar. 6.Pedidos: Rejeitar prelim., refutar defesa, proceder inicial. 7.Fechamento OAB."
|
| 226 |
elif tipo_peticao == "Embargos de Declaração":
|
| 227 |
-
prompt += "1.Endereçamento juízo prolator. Proc, Partes. Decisão embargada ID. Tempestividade (5d). 2.Tópico para cada vício (Art.1022): DA OMISSÃO/CONTRADIÇÃO/OBSCURIDADE/ERRO MATERIAL. 3.Dentro: Transcrever trecho + explicar vício OBJETIVAMENTE. NÃO REJULGAR. 4.Pedido: Conhecimento e ACOLHIMENTO p/ sanar vício(s). 5.Fechamento OAB."
|
| 228 |
elif tipo_peticao == "Recurso de Apelação":
|
| 229 |
prompt += "1.Interposição: Juízo a quo. Proc, Partes. Pressupostos (cabim., temp., prep./JG). Pedido receb./remessa. 2.Razões: Tribunal. Relato. FUNDAMENTOS REFORMA/ANULAÇÃO (Error in proc./judic.). DIALETICIDADE. 3.Pedidos: Conhec.; PROVIMENTO (anular/reformar); Inversão sucumb. 4.Fechamento OAB."
|
| 230 |
elif tipo_peticao == "Agravo de Instrumento":
|
|
@@ -421,10 +421,16 @@ def calcular_diff_interno(texto_original, texto_corrigido):
|
|
| 421 |
for linha in diff:
|
| 422 |
txt = linha[2:]; txt_esc = escape(txt)
|
| 423 |
if linha.startswith(' '): res_html.append(f"<div class='linha-igual'>{txt_esc}</div>")
|
| 424 |
-
elif linha.startswith('- '):
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
resumo = f"**Resumo:** Rem={l_rem}, Add={l_add}, Saldo={l_add - l_rem}"
|
| 429 |
crit_txt = "### 🚨 Mudanças Críticas:\n" + "\n".join(crit) if crit else "*Nenhuma mudança crítica detectada.*"
|
| 430 |
css = "<style>.diff-container{font-family:monospace;white-space:pre-wrap;border:1px solid #ccc;padding:10px;background-color:#f9f9f9;max-height:600px;overflow-y:auto}.linha-igual{color:#555}.linha-removida{background-color:#ffebee;color:#c62828}.linha-adicionada{background-color:#e8f5e9;color:#2e7d32}.linha-removida del,.linha-adicionada ins{text-decoration:none;padding:0 2px;border-radius:2px}.linha-removida del{background-color:#ffcdd2}.linha-adicionada ins{background-color:#c8e6c9}</style>"
|
|
@@ -492,7 +498,7 @@ def estruturar_prompt_geracao_caso(tipo_peticao="Petição Inicial"):
|
|
| 492 |
elif tipo_peticao == "Agravo de Instrumento": prompt += "* Caso em andamento. * DECISÃO INTERLOCUTÓRIA. * Enquadrar Art.1015/mitigação. * ELEMENTOS indicando ERRO + URGÊNCIA. * Indique cliente (agravante)."
|
| 493 |
elif tipo_peticao == "Petição de Tutela Provisória": prompt += "* Situação URGENTE ou EVIDENTE. * ELEMENTOS: Urgência=Fumus+Periculum; Evidência=Hipótese Art.311. * Medida específica. * Antecedente ou Incidental."
|
| 494 |
else: prompt += "* Crie cenário cível com conflito claro."
|
| 495 |
-
prompt += f'\n**Finalize:**\n"**Situação-Problema:** Advogado(a) de [Nome Cliente], elabore a peça cabível ({tipo_peticao})."\n**Importante:** Temas comuns. Seja criativo!'
|
| 496 |
return prompt
|
| 497 |
|
| 498 |
def gerar_caso_ficticio(tipo_peticao="Petição Inicial"):
|
|
@@ -512,7 +518,6 @@ def gerar_caso_ficticio(tipo_peticao="Petição Inicial"):
|
|
| 512 |
return caso_gerado
|
| 513 |
except Exception as e: logger.exception("Erro gerar_caso:"); return f"❌ Erro gerar caso: {e}"
|
| 514 |
|
| 515 |
-
# Função para atualizar config (faltante no traceback anterior)
|
| 516 |
def atualizar_config(temp, timeout, tokens):
|
| 517 |
CONFIG["temperatura"] = temp
|
| 518 |
CONFIG["timeout"] = timeout
|
|
@@ -574,7 +579,6 @@ def interface_gradio():
|
|
| 574 |
with gr.Column(scale=3): visualizacao_detalhada_output = gr.HTML(label="Detalhes")
|
| 575 |
clear_btn = gr.Button("🗑️ Limpar Tudo")
|
| 576 |
|
| 577 |
-
# --- Eventos ---
|
| 578 |
caso_btn.click(lambda: gr.update(value="⏳ Gerando...", visible=True), outputs=processing_message).then(
|
| 579 |
fn=gerar_caso_ficticio, inputs=[tipo_peticao_input], outputs=[caso_input]
|
| 580 |
).then(lambda: gr.update(value="", visible=False), outputs=processing_message)
|
|
|
|
| 224 |
elif tipo_peticao == "Impugnação à Contestação":
|
| 225 |
prompt += "1.Endereçamento, proc, autor, tempestividade. 2.Tópico: DA(S) PRELIMINAR(ES) - Rebater. 3.Tópico: DO MÉRITO E FATOS NOVOS - Manifestar. 4.Tópico: DA RATIFICAÇÃO INICIAL. 5.Tópico: DAS PROVAS - Especificar. 6.Pedidos: Rejeitar prelim., refutar defesa, proceder inicial. 7.Fechamento OAB."
|
| 226 |
elif tipo_peticao == "Embargos de Declaração":
|
| 227 |
+
prompt += "1.Endereçamento juízo prolator. Proc, Partes. Decisão embargada ID. Tempestividade (5d). 2.Tópico para cada vício (Art.1022): DA OMISSÃO / DA CONTRADIÇÃO / DA OBSCURIDADE / DO ERRO MATERIAL. 3.Dentro: Transcrever trecho + explicar vício OBJETIVAMENTE. NÃO REJULGAR. 4.Pedido: Conhecimento e ACOLHIMENTO p/ sanar vício(s). 5.Fechamento OAB."
|
| 228 |
elif tipo_peticao == "Recurso de Apelação":
|
| 229 |
prompt += "1.Interposição: Juízo a quo. Proc, Partes. Pressupostos (cabim., temp., prep./JG). Pedido receb./remessa. 2.Razões: Tribunal. Relato. FUNDAMENTOS REFORMA/ANULAÇÃO (Error in proc./judic.). DIALETICIDADE. 3.Pedidos: Conhec.; PROVIMENTO (anular/reformar); Inversão sucumb. 4.Fechamento OAB."
|
| 230 |
elif tipo_peticao == "Agravo de Instrumento":
|
|
|
|
| 421 |
for linha in diff:
|
| 422 |
txt = linha[2:]; txt_esc = escape(txt)
|
| 423 |
if linha.startswith(' '): res_html.append(f"<div class='linha-igual'>{txt_esc}</div>")
|
| 424 |
+
elif linha.startswith('- '):
|
| 425 |
+
l_rem += 1
|
| 426 |
+
res_html.append(f"<div class='linha-removida'><del>{txt_esc}</del></div>")
|
| 427 |
+
if txt.strip() and any(kw in txt.lower() for kw in kw_rem): # CORRIGIDO: if em nova linha
|
| 428 |
+
crit.append(f"<span style='color:red'>🔴 REMOVIDO:</span> {txt_esc}")
|
| 429 |
+
elif linha.startswith('+ '):
|
| 430 |
+
l_add += 1
|
| 431 |
+
res_html.append(f"<div class='linha-adicionada'><ins>{txt_esc}</ins></div>")
|
| 432 |
+
if txt.strip() and any(kw in txt.lower() for kw in kw_add): # CORRIGIDO: if em nova linha
|
| 433 |
+
crit.append(f"<span style='color:green'>🟢 ADICIONADO:</span> {txt_esc}")
|
| 434 |
resumo = f"**Resumo:** Rem={l_rem}, Add={l_add}, Saldo={l_add - l_rem}"
|
| 435 |
crit_txt = "### 🚨 Mudanças Críticas:\n" + "\n".join(crit) if crit else "*Nenhuma mudança crítica detectada.*"
|
| 436 |
css = "<style>.diff-container{font-family:monospace;white-space:pre-wrap;border:1px solid #ccc;padding:10px;background-color:#f9f9f9;max-height:600px;overflow-y:auto}.linha-igual{color:#555}.linha-removida{background-color:#ffebee;color:#c62828}.linha-adicionada{background-color:#e8f5e9;color:#2e7d32}.linha-removida del,.linha-adicionada ins{text-decoration:none;padding:0 2px;border-radius:2px}.linha-removida del{background-color:#ffcdd2}.linha-adicionada ins{background-color:#c8e6c9}</style>"
|
|
|
|
| 498 |
elif tipo_peticao == "Agravo de Instrumento": prompt += "* Caso em andamento. * DECISÃO INTERLOCUTÓRIA. * Enquadrar Art.1015/mitigação. * ELEMENTOS indicando ERRO + URGÊNCIA. * Indique cliente (agravante)."
|
| 499 |
elif tipo_peticao == "Petição de Tutela Provisória": prompt += "* Situação URGENTE ou EVIDENTE. * ELEMENTOS: Urgência=Fumus+Periculum; Evidência=Hipótese Art.311. * Medida específica. * Antecedente ou Incidental."
|
| 500 |
else: prompt += "* Crie cenário cível com conflito claro."
|
| 501 |
+
prompt += f'\n**Finalize:**\n"**Situação-Problema:** Advogado(a) de [Nome Cliente], elabore a peça processual cabível ({tipo_peticao})."\n**Importante:** Temas comuns. Seja criativo!'
|
| 502 |
return prompt
|
| 503 |
|
| 504 |
def gerar_caso_ficticio(tipo_peticao="Petição Inicial"):
|
|
|
|
| 518 |
return caso_gerado
|
| 519 |
except Exception as e: logger.exception("Erro gerar_caso:"); return f"❌ Erro gerar caso: {e}"
|
| 520 |
|
|
|
|
| 521 |
def atualizar_config(temp, timeout, tokens):
|
| 522 |
CONFIG["temperatura"] = temp
|
| 523 |
CONFIG["timeout"] = timeout
|
|
|
|
| 579 |
with gr.Column(scale=3): visualizacao_detalhada_output = gr.HTML(label="Detalhes")
|
| 580 |
clear_btn = gr.Button("🗑️ Limpar Tudo")
|
| 581 |
|
|
|
|
| 582 |
caso_btn.click(lambda: gr.update(value="⏳ Gerando...", visible=True), outputs=processing_message).then(
|
| 583 |
fn=gerar_caso_ficticio, inputs=[tipo_peticao_input], outputs=[caso_input]
|
| 584 |
).then(lambda: gr.update(value="", visible=False), outputs=processing_message)
|