Update app.py
Browse files
app.py
CHANGED
|
@@ -496,11 +496,13 @@ def exportar_diferencas_html(caso, peticao_texto, correcao):
|
|
| 496 |
</body>
|
| 497 |
</html>
|
| 498 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 499 |
|
| 500 |
nome_arquivo = f"diferencas_peticao_{datetime.now().strftime('%Y%m%d_%H%M%S')}.html"
|
| 501 |
-
|
| 502 |
-
f.write(html_content)
|
| 503 |
-
return nome_arquivo
|
| 504 |
|
| 505 |
def interface_gradio():
|
| 506 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
@@ -621,8 +623,8 @@ def interface_gradio():
|
|
| 621 |
inputs=[caso_input, peticao_texto, resultado_output],
|
| 622 |
outputs=[download_file]
|
| 623 |
).then(
|
| 624 |
-
fn=lambda x:
|
| 625 |
-
outputs=[download_file
|
| 626 |
)
|
| 627 |
|
| 628 |
with gr.Accordion("📘 Critérios Detalhados", open=False):
|
|
|
|
| 496 |
</body>
|
| 497 |
</html>
|
| 498 |
"""
|
| 499 |
+
# Gerar o arquivo em memória usando BytesIO
|
| 500 |
+
buffer = io.BytesIO()
|
| 501 |
+
buffer.write(html_content.encode('utf-8'))
|
| 502 |
+
buffer.seek(0)
|
| 503 |
|
| 504 |
nome_arquivo = f"diferencas_peticao_{datetime.now().strftime('%Y%m%d_%H%M%S')}.html"
|
| 505 |
+
return gr.File(value=buffer, label=nome_arquivo)
|
|
|
|
|
|
|
| 506 |
|
| 507 |
def interface_gradio():
|
| 508 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 623 |
inputs=[caso_input, peticao_texto, resultado_output],
|
| 624 |
outputs=[download_file]
|
| 625 |
).then(
|
| 626 |
+
fn=lambda x: gr.update(visible=True, value=x),
|
| 627 |
+
outputs=[download_file]
|
| 628 |
)
|
| 629 |
|
| 630 |
with gr.Accordion("📘 Critérios Detalhados", open=False):
|