Spaces:
Runtime error
Runtime error
Download app.py from powercoreai/PowerCore: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/spaces/powercoreai/PowerCore/resolve/main/app.py
- Command line
-
hf download hf://spaces/powercoreai/PowerCore/app.py
-
curl -L -o app.py https://huggingface.co/spaces/powercoreai/PowerCore/resolve/main/app.py
2.47 kB
| from pathlib import Path | |
| # Enhanced Gradio app with backend stub, logging, and simulated async behavior | |
| enhanced_app_py = """ | |
| import gradio as gr | |
| import requests | |
| import time | |
| import json | |
| API_ENDPOINT = "http://localhost:8001/api/agents/run" # Replace with real backend if deployed | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown(\""" | |
| # βοΈ PowerCore Forge β Agent Workflow Orchestrator | |
| **PowerCore Forge** is an AI-powered dev stack for building, managing, and monetizing intelligent automation workflows. | |
| - π Attach plugins to agents (Gumroad, GitHub, Slack) | |
| - π§ Control ContextAgent, PlannerAgent, ExecutorAgent | |
| - π Trigger workflows visually | |
| - π View live logs and status output | |
| --- | |
| \""") | |
| agent = gr.Dropdown(["ContextAgent", "PlannerAgent", "ExecutorAgent"], label="Select Agent") | |
| plugin = gr.Dropdown(["Gumroad Plugin", "GitHub Sync", "Slack Alerts"], label="Select Plugin") | |
| output = gr.Textbox(label="Execution Log", lines=10) | |
| def run_agent(agent, plugin): | |
| logs = [] | |
| logs.append(f"π’ Initializing {agent}...") | |
| time.sleep(0.5) | |
| logs.append(f"π Attaching {plugin}...") | |
| time.sleep(0.5) | |
| logs.append(f"π‘ Sending execution request to backend...") | |
| time.sleep(0.5) | |
| try: | |
| # Simulate backend call | |
| payload = {"agent": agent, "plugin": plugin} | |
| response = requests.post(API_ENDPOINT, json=payload, timeout=3) | |
| if response.status_code == 200: | |
| result = response.json() | |
| logs.append(f"β Execution complete: {result.get('message', 'Success')}") | |
| else: | |
| logs.append(f"β Backend error: HTTP {response.status_code}") | |
| except Exception as e: | |
| logs.append(f"π¨ Exception during execution: {str(e)}") | |
| logs.append("π Workflow execution finished.") | |
| # Save to log file | |
| log_file = { | |
| "agent": agent, | |
| "plugin": plugin, | |
| "logs": logs, | |
| "timestamp": time.time() | |
| } | |
| with open("execution_log.json", "w") as f: | |
| json.dump(log_file, f, indent=2) | |
| return "\\n".join(logs) | |
| run_button = gr.Button("βΆοΈ Run Workflow") | |
| run_button.click(fn=run_agent, inputs=[agent, plugin], outputs=output) | |
| demo.launch() | |
| """ | |
| # Save the file | |
| Path("/mnt/data/app.py").write_text(enhanced_app_py.strip()) | |