File size: 1,706 Bytes
1a0daaa 835b371 158b3a2 835b371 158b3a2 835b371 158b3a2 835b371 158b3a2 835b371 158b3a2 835b371 158b3a2 835b371 158b3a2 835b371 158b3a2 835b371 158b3a2 835b371 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# app.py
import gradio as gr
from logic.generator import generate_code
from logic.fixer import fix_code
from logic.refactor import refactor_code
from logic.file_reader import read_uploaded_file
with gr.Blocks(title="Python Code Assistant") as demo:
gr.Markdown("# 🧠 Python Code Assistant\nUma IA especializada em programação Python — gere, corrija, refatore e interprete arquivos.")
with gr.Tab("📌 Gerar Código"):
with gr.Row():
prompt = gr.Textbox(label="Descreva o que o código deve fazer", placeholder="Ex: Ler um CSV e plotar um gráfico", lines=3)
output_gen = gr.Code(label="Código gerado")
btn_gen = gr.Button("Gerar")
btn_gen.click(fn=generate_code, inputs=prompt, outputs=output_gen)
with gr.Tab("🛠️ Corrigir Código"):
buggy_code = gr.Code(label="Cole o código com erro")
output_fix = gr.Code(label="Código corrigido")
btn_fix = gr.Button("Corrigir")
btn_fix.click(fn=fix_code, inputs=buggy_code, outputs=output_fix)
with gr.Tab("🧹 Refatorar Código"):
original_code = gr.Code(label="Cole o código para refatorar")
output_refac = gr.Code(label="Código refatorado")
btn_refac = gr.Button("Refatorar")
btn_refac.click(fn=refactor_code, inputs=original_code, outputs=output_refac)
with gr.Tab("📂 Interpretar Arquivo"):
file_input = gr.File(label="Envie um .py, .txt ou .zip com códigos")
file_content = gr.Textbox(label="Conteúdo interpretado", lines=25, interactive=False)
btn_file = gr.Button("Ler arquivo")
btn_file.click(fn=read_uploaded_file, inputs=file_input, outputs=file_content)
demo.launch()
|