wasmdashai commited on
Commit
8a28289
·
verified ·
1 Parent(s): 8cb5640

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
app.py CHANGED
@@ -316,6 +316,7 @@ def process_validator_request(model_name, model_structure, template_instructions
316
  # demo.launch()
317
 
318
  import gradio as gr
 
319
  @spaces.GPU
320
  def process_multiple_validators(model_names_str, model_structure, template_instructions):
321
  model_names = [name.strip() for name in model_names_str.split(",") if name.strip()]
@@ -328,11 +329,25 @@ def process_multiple_validators(model_names_str, model_structure, template_instr
328
  return files_output
329
 
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  with gr.Blocks(title="C# Validator Generator") as demo:
332
  gr.Markdown("## 🧠 C# Validator Code Generator")
333
 
334
  with gr.Tabs():
335
- # Tab 1: Single Model
336
  with gr.Tab("Single Validator"):
337
  with gr.Row():
338
  with gr.Column():
@@ -350,7 +365,7 @@ with gr.Blocks(title="C# Validator Generator") as demo:
350
  outputs=[single_code_output],
351
  )
352
 
353
- # Tab 2: Batch Mode
354
  with gr.Tab("Batch Validators"):
355
  with gr.Row():
356
  with gr.Column():
@@ -363,26 +378,15 @@ with gr.Blocks(title="C# Validator Generator") as demo:
363
  batch_generate_btn = gr.Button("Generate All")
364
 
365
  with gr.Column():
366
- generated_editors = gr.Accordion("Generated Files", open=True)
367
- editors_output = gr.Group()
368
-
369
- def render_outputs(files_dict):
370
- outputs = []
371
- for name, code in files_dict.items():
372
- editor = gr.Code(value=code, label=f"{name}.Validator.cs", lines=20)
373
- outputs.append(editor)
374
- return outputs
375
 
376
  batch_generate_btn.click(
377
- fn=process_multiple_validators,
378
  inputs=[model_names_input, shared_model_structure_input, shared_template_input],
379
- outputs=editors_output,
380
- preprocess=False,
381
- postprocess=True,
382
- show_progress=True
383
  )
384
 
385
- generated_editors.children.append(editors_output)
 
386
 
387
 
388
- demo.launch()
 
316
  # demo.launch()
317
 
318
  import gradio as gr
319
+
320
  @spaces.GPU
321
  def process_multiple_validators(model_names_str, model_structure, template_instructions):
322
  model_names = [name.strip() for name in model_names_str.split(",") if name.strip()]
 
329
  return files_output
330
 
331
 
332
+ def render_outputs(model_names_str, model_structure, template_instructions):
333
+ files = process_multiple_validators(model_names_str, model_structure, template_instructions)
334
+ components = []
335
+
336
+ for name, code in files.items():
337
+ components.append(
338
+ gr.Accordion(f"{name}.Validator.cs", open=False).render()(
339
+ gr.Code(value=code, lines=20, label=name)
340
+ )
341
+ )
342
+
343
+ return components
344
+
345
+
346
  with gr.Blocks(title="C# Validator Generator") as demo:
347
  gr.Markdown("## 🧠 C# Validator Code Generator")
348
 
349
  with gr.Tabs():
350
+ # Tab 1: Single
351
  with gr.Tab("Single Validator"):
352
  with gr.Row():
353
  with gr.Column():
 
365
  outputs=[single_code_output],
366
  )
367
 
368
+ # Tab 2: Batch
369
  with gr.Tab("Batch Validators"):
370
  with gr.Row():
371
  with gr.Column():
 
378
  batch_generate_btn = gr.Button("Generate All")
379
 
380
  with gr.Column():
381
+ dynamic_outputs = gr.Column()
 
 
 
 
 
 
 
 
382
 
383
  batch_generate_btn.click(
384
+ fn=render_outputs,
385
  inputs=[model_names_input, shared_model_structure_input, shared_template_input],
386
+ outputs=[dynamic_outputs],
 
 
 
387
  )
388
 
389
+ demo.launch()
390
+
391
 
392