PowerCore / app.py
M
PowerCore
7bb5d6d verified
Raw History Blame Contribute Delete
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())