Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 988 |
-
""
|
| 989 |
-
<
|
| 990 |
-
|
| 991 |
-
|
| 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)
|
|
|
|
|
|