Update app.py
Browse files
app.py
CHANGED
|
@@ -568,8 +568,13 @@ def exportar_diferencas_html(caso, peticao_texto, correcao):
|
|
| 568 |
</html>
|
| 569 |
"""
|
| 570 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf", mode='w') as tmp:
|
| 571 |
-
|
| 572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 573 |
|
| 574 |
def interface_gradio():
|
| 575 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
@@ -641,10 +646,9 @@ def interface_gradio():
|
|
| 641 |
|
| 642 |
with gr.Row():
|
| 643 |
with gr.Column(scale=1):
|
| 644 |
-
alteracoes_texto_output = gr.Markdown(label="🔍 Alterações por Seção", visible=False)
|
| 645 |
-
with gr.Column(scale=2):
|
| 646 |
resumo_alteracoes_output = gr.Markdown(label="📊 Resumo das Alterações")
|
| 647 |
criticas_output = gr.Markdown(label="🚨 Mudanças Críticas")
|
|
|
|
| 648 |
visualizacao_detalhada_output = gr.HTML(label="📝 Alterações Detalhadas")
|
| 649 |
|
| 650 |
with gr.Row():
|
|
@@ -671,7 +675,7 @@ def interface_gradio():
|
|
| 671 |
outputs=[resultado_output]
|
| 672 |
)
|
| 673 |
clear_btn.click(
|
| 674 |
-
fn=lambda: [None, None, None, None, "", "", "", "", "",
|
| 675 |
inputs=None,
|
| 676 |
outputs=[caso_input, peticao_texto, peticao_arquivo, arquivo_preview, resultado_output, dica_contextual,
|
| 677 |
peticao_aluno_output, peticao_corrigida_output, resumo_alteracoes_output, criticas_output,
|
|
|
|
| 568 |
</html>
|
| 569 |
"""
|
| 570 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf", mode='w') as tmp:
|
| 571 |
+
try:
|
| 572 |
+
HTML(string=html_content).write_pdf(tmp.name)
|
| 573 |
+
return tmp.name
|
| 574 |
+
except Exception as e:
|
| 575 |
+
return f"❌ Erro ao gerar PDF: {str(e)}"
|
| 576 |
+
finally:
|
| 577 |
+
os.unlink(tmp.name) if os.path.exists(tmp.name) else None
|
| 578 |
|
| 579 |
def interface_gradio():
|
| 580 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 646 |
|
| 647 |
with gr.Row():
|
| 648 |
with gr.Column(scale=1):
|
|
|
|
|
|
|
| 649 |
resumo_alteracoes_output = gr.Markdown(label="📊 Resumo das Alterações")
|
| 650 |
criticas_output = gr.Markdown(label="🚨 Mudanças Críticas")
|
| 651 |
+
with gr.Column(scale=2):
|
| 652 |
visualizacao_detalhada_output = gr.HTML(label="📝 Alterações Detalhadas")
|
| 653 |
|
| 654 |
with gr.Row():
|
|
|
|
| 675 |
outputs=[resultado_output]
|
| 676 |
)
|
| 677 |
clear_btn.click(
|
| 678 |
+
fn=lambda: [None, None, None, None, "", "", "", "", "", gr.update(visible=False), gr.update(visible=False)],
|
| 679 |
inputs=None,
|
| 680 |
outputs=[caso_input, peticao_texto, peticao_arquivo, arquivo_preview, resultado_output, dica_contextual,
|
| 681 |
peticao_aluno_output, peticao_corrigida_output, resumo_alteracoes_output, criticas_output,
|