Spaces:
Runtime error
Runtime error
File size: 2,471 Bytes
7bb5d6d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 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())
|