openfree commited on
Commit
681e68f
ยท
verified ยท
1 Parent(s): c8bd65e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -29
app.py CHANGED
@@ -332,6 +332,7 @@ def create_sample_workflow(example_type="basic"):
332
  # ๊ธฐ๋ณธ๊ฐ’์€ basic
333
  return create_sample_workflow("basic")
334
 
 
335
  def generate_standalone_app(workflow_data: dict, app_name: str, app_description: str) -> str:
336
  """์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ ๋…๋ฆฝ์ ์ธ Gradio ์•ฑ์œผ๋กœ ๋ณ€ํ™˜"""
337
 
@@ -475,7 +476,7 @@ def execute_workflow(*input_values):
475
  elif provider == "VIDraft":
476
  results[node_id] = "[VIDraft API key not found. Please set FRIENDLI_TOKEN in Space secrets]"
477
  else:
478
- results[node_id] = f"[No API key found for {provider}. Using simulated response: {input_text[:50]}...]"
479
 
480
  elif node_type in ["ChatOutput", "textOutput", "Output"]:
481
  # Get connected result
@@ -984,14 +985,11 @@ with gr.Blocks(title="๐Ÿญ MOUSE Workflow", theme=gr.themes.Soft(), css=CSS) as
984
  gr.Markdown("**Visual Workflow Builder with Interactive UI Execution**")
985
  gr.HTML('<p class="powered-by">@Powered by VIDraft & Huggingface gradio</p>')
986
 
987
- gr.HTML(
988
- """
989
- <div class="component-description">
990
- <p style="font-size:16px;margin:0;">Build sophisticated workflows visually โ€ข Import/Export JSON โ€ข Generate interactive UI for end-users โ€ข Default LLM: VIDraft (Gemma-3-r1984-27B)</p>
991
- <p style="font-size:14px;margin-top:8px;color:#64748b;">๐Ÿ’ก Tip: Your workflow is automatically saved as you make changes. The JSON preview updates in real-time!</p>
992
- </div>
993
- """
994
- )
995
 
996
  # API Status Display
997
  with gr.Accordion("๐Ÿ”Œ API Status", open=False):
@@ -1431,20 +1429,6 @@ with gr.Blocks(title="๐Ÿญ MOUSE Workflow", theme=gr.themes.Soft(), css=CSS) as
1431
 
1432
  # Download workflow๋Š” ์ด๋ฏธ loaded_data.change์—์„œ ์ฒ˜๋ฆฌ๋จ
1433
 
1434
- # Generate UI execution - ํ˜„์žฌ ์›Œํฌํ”Œ๋กœ์šฐ ์‚ฌ์šฉ
1435
- def prepare_ui_execution(current_data):
1436
- """ํ˜„์žฌ ์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ UI ์‹คํ–‰์šฉ์œผ๋กœ ์ค€๋น„"""
1437
- if not current_data or not current_data.get("nodes"):
1438
- gr.Warning("Please create a workflow first!")
1439
- return None
1440
- return current_data
1441
-
1442
- btn_execute_ui.click(
1443
- fn=prepare_ui_execution,
1444
- inputs=loaded_data,
1445
- outputs=ui_workflow_data
1446
- )
1447
-
1448
  # Auto-update export preview when workflow changes
1449
  def update_preview_and_download(data):
1450
  """์›Œํฌํ”Œ๋กœ์šฐ ๋ณ€๊ฒฝ์‹œ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์™€ ๋‹ค์šด๋กœ๋“œ ์—…๋ฐ์ดํŠธ"""
@@ -1457,15 +1441,26 @@ with gr.Blocks(title="๐Ÿญ MOUSE Workflow", theme=gr.themes.Soft(), css=CSS) as
1457
  return preview, download_file, status
1458
  return "No workflow data", None, "๐Ÿ“Š Empty workflow"
1459
 
1460
- # Status display for workflow info
1461
- workflow_info = gr.Markdown("๐Ÿ“Š Empty workflow", elem_classes=["workflow-info"])
1462
-
1463
  loaded_data.change(
1464
  fn=update_preview_and_download,
1465
  inputs=loaded_data,
1466
  outputs=[export_preview, btn_download, workflow_info]
1467
  )
1468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1469
  # โ”€โ”€โ”€ Deploy Event Handlers โ”€โ”€โ”€
1470
 
1471
  # Preview generated code
@@ -1608,6 +1603,4 @@ The app is configured to prioritize VIDraft (Gemma-3-r1984-27B) for optimal perf
1608
  # ๐Ÿš€ ์‹คํ–‰
1609
  # -------------------------------------------------------------------
1610
  if __name__ == "__main__":
1611
- demo.launch(server_name="0.0.0.0", show_error=True)
1612
-
1613
-
 
332
  # ๊ธฐ๋ณธ๊ฐ’์€ basic
333
  return create_sample_workflow("basic")
334
 
335
+ # ๋ฐฐํฌ๋ฅผ ์œ„ํ•œ ๋…๋ฆฝ ์•ฑ ์ƒ์„ฑ ํ•จ์ˆ˜
336
  def generate_standalone_app(workflow_data: dict, app_name: str, app_description: str) -> str:
337
  """์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ ๋…๋ฆฝ์ ์ธ Gradio ์•ฑ์œผ๋กœ ๋ณ€ํ™˜"""
338
 
 
476
  elif provider == "VIDraft":
477
  results[node_id] = "[VIDraft API key not found. Please set FRIENDLI_TOKEN in Space secrets]"
478
  else:
479
+ results[node_id] = f"[No API key found for {{provider}}. Using simulated response: {{input_text[:50]}}...]"
480
 
481
  elif node_type in ["ChatOutput", "textOutput", "Output"]:
482
  # Get connected result
 
985
  gr.Markdown("**Visual Workflow Builder with Interactive UI Execution**")
986
  gr.HTML('<p class="powered-by">@Powered by VIDraft & Huggingface gradio</p>')
987
 
988
+ html_content = """<div class="component-description">
989
+ <p style="font-size:16px;margin:0;">Build sophisticated workflows visually โ€ข Import/Export JSON โ€ข Generate interactive UI for end-users โ€ข Default LLM: VIDraft (Gemma-3-r1984-27B)</p>
990
+ <p style="font-size:14px;margin-top:8px;color:#64748b;">๐Ÿ’ก Tip: Your workflow is automatically saved as you make changes. The JSON preview updates in real-time!</p>
991
+ </div>"""
992
+ gr.HTML(html_content)
 
 
 
993
 
994
  # API Status Display
995
  with gr.Accordion("๐Ÿ”Œ API Status", open=False):
 
1429
 
1430
  # Download workflow๋Š” ์ด๋ฏธ loaded_data.change์—์„œ ์ฒ˜๋ฆฌ๋จ
1431
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1432
  # Auto-update export preview when workflow changes
1433
  def update_preview_and_download(data):
1434
  """์›Œํฌํ”Œ๋กœ์šฐ ๋ณ€๊ฒฝ์‹œ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์™€ ๋‹ค์šด๋กœ๋“œ ์—…๋ฐ์ดํŠธ"""
 
1441
  return preview, download_file, status
1442
  return "No workflow data", None, "๐Ÿ“Š Empty workflow"
1443
 
 
 
 
1444
  loaded_data.change(
1445
  fn=update_preview_and_download,
1446
  inputs=loaded_data,
1447
  outputs=[export_preview, btn_download, workflow_info]
1448
  )
1449
 
1450
+ # Generate UI execution - ํ˜„์žฌ ์›Œํฌํ”Œ๋กœ์šฐ ์‚ฌ์šฉ
1451
+ def prepare_ui_execution(current_data):
1452
+ """ํ˜„์žฌ ์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ UI ์‹คํ–‰์šฉ์œผ๋กœ ์ค€๋น„"""
1453
+ if not current_data or not current_data.get("nodes"):
1454
+ gr.Warning("Please create a workflow first!")
1455
+ return None
1456
+ return current_data
1457
+
1458
+ btn_execute_ui.click(
1459
+ fn=prepare_ui_execution,
1460
+ inputs=loaded_data,
1461
+ outputs=ui_workflow_data
1462
+ )
1463
+
1464
  # โ”€โ”€โ”€ Deploy Event Handlers โ”€โ”€โ”€
1465
 
1466
  # Preview generated code
 
1603
  # ๐Ÿš€ ์‹คํ–‰
1604
  # -------------------------------------------------------------------
1605
  if __name__ == "__main__":
1606
+ demo.launch(server_name="0.0.0.0", show_error=True)