ValdeciRodrigues commited on
Commit
07f0e01
·
verified ·
1 Parent(s): 7c4ed8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -16
app.py CHANGED
@@ -1,11 +1,9 @@
1
  # app.py
2
  import gradio as gr
3
- from logic.generator import generate_code
4
  from logic.fixer import fix_code
5
  from logic.refactor import refactor_code
6
  from logic.file_reader import read_uploaded_file
7
-
8
- from logic.generator import tokenizer, model
9
  import torch
10
 
11
  def process_file_command(arquivos, prompt):
@@ -58,23 +56,41 @@ with gr.Blocks(title="Python Code Assistant", css="#file-output textarea { overf
58
  btn_refac = gr.Button("Refatorar")
59
  btn_refac.click(fn=refactor_code, inputs=original_code, outputs=output_refac)
60
 
61
- with gr.Tab("📂 Interpretar Arquivos"):
62
- file_input = gr.File(label="Envie arquivos .py, .txt ou .zip", file_types=[".py", ".txt", ".zip"], file_count="multiple")
63
- file_content = gr.Textbox(
64
- label="Conteúdo interpretado",
65
- lines=30,
 
 
 
 
 
66
  max_lines=1000,
67
  interactive=False,
68
- show_copy_button=True,
69
- elem_id="file-output"
 
 
 
 
70
  )
71
- btn_file = gr.Button("Ler arquivos")
72
- btn_file.click(fn=lambda files: "\n\n".join(read_uploaded_file(f) for f in files), inputs=file_input, outputs=file_content)
73
 
74
- with gr.Tab("🤖 Comando com base nos arquivos"):
75
- command_file = gr.Textbox(label="Diga o que quer que a IA faça com os arquivos enviados", placeholder="Ex: Corrija e aplique boas práticas")
76
- command_output = gr.Code(label="Resultado")
77
  btn_command = gr.Button("Executar comando")
78
- btn_command.click(fn=process_file_command, inputs=[file_input, command_file], outputs=command_output)
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  demo.launch()
 
1
  # app.py
2
  import gradio as gr
3
+ from logic.generator import generate_code, tokenizer, model
4
  from logic.fixer import fix_code
5
  from logic.refactor import refactor_code
6
  from logic.file_reader import read_uploaded_file
 
 
7
  import torch
8
 
9
  def process_file_command(arquivos, prompt):
 
56
  btn_refac = gr.Button("Refatorar")
57
  btn_refac.click(fn=refactor_code, inputs=original_code, outputs=output_refac)
58
 
59
+ with gr.Tab("📂 Interpretar e Comandar Arquivos"):
60
+ file_input = gr.File(
61
+ label="Arraste ou selecione arquivos (.py, .txt, .zip)",
62
+ file_types=[".py", ".txt", ".zip"],
63
+ file_count="multiple"
64
+ )
65
+
66
+ file_summary = gr.Textbox(
67
+ label="📄 Resumo dos arquivos enviados",
68
+ lines=15,
69
  max_lines=1000,
70
  interactive=False,
71
+ show_copy_button=True
72
+ )
73
+
74
+ command_file = gr.Textbox(
75
+ label="💬 O que deseja fazer com os arquivos?",
76
+ placeholder="Ex: Corrija todos e transforme em uma API com FastAPI"
77
  )
 
 
78
 
79
+ command_output = gr.Code(label="⚙️ Resultado gerado pela IA")
 
 
80
  btn_command = gr.Button("Executar comando")
81
+
82
+ # Resumo automático dos arquivos
83
+ file_input.change(
84
+ fn=lambda files: "\n\n".join(read_uploaded_file(f)[:1000] for f in files),
85
+ inputs=file_input,
86
+ outputs=file_summary
87
+ )
88
+
89
+ # Executa comando com base nos arquivos carregados
90
+ btn_command.click(
91
+ fn=process_file_command,
92
+ inputs=[file_input, command_file],
93
+ outputs=command_output
94
+ )
95
 
96
  demo.launch()