Spaces:
Runtime error
Runtime error
Upload 19 files
Browse files- api.py +24 -1
- client_portal.html +12 -0
- dashboard.html +22 -0
- multi_agent.py +9 -9
- self_improve.py +9 -0
api.py
CHANGED
@@ -29,4 +29,27 @@ if __name__ == "__main__":
|
|
29 |
uvicorn.run("api:app", host="0.0.0.0", port=7861)
|
30 |
|
31 |
from webhook import router as webhook_router
|
32 |
-
app.include_router(webhook_router)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
uvicorn.run("api:app", host="0.0.0.0", port=7861)
|
30 |
|
31 |
from webhook import router as webhook_router
|
32 |
+
app.include_router(webhook_router)
|
33 |
+
|
34 |
+
from fastapi import Form
|
35 |
+
from fastapi.responses import HTMLResponse
|
36 |
+
from fastapi.staticfiles import StaticFiles
|
37 |
+
from storage import save_goal
|
38 |
+
from agent import run_agent
|
39 |
+
|
40 |
+
app.mount("/static", StaticFiles(directory="."), name="static")
|
41 |
+
|
42 |
+
@app.get("/portal", response_class=HTMLResponse)
|
43 |
+
async def client_portal():
|
44 |
+
with open("client_portal.html") as f:
|
45 |
+
return f.read()
|
46 |
+
|
47 |
+
@app.post("/submit_task")
|
48 |
+
async def submit_task(goal: str = Form(...)):
|
49 |
+
save_goal(goal)
|
50 |
+
return {"status": "submitted", "result": run_agent(goal)}
|
51 |
+
|
52 |
+
@app.get("/dashboard", response_class=HTMLResponse)
|
53 |
+
async def dashboard():
|
54 |
+
with open("dashboard.html") as f:
|
55 |
+
return f.read()
|
client_portal.html
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html>
|
4 |
+
<head><title>Client Portal</title></head>
|
5 |
+
<body>
|
6 |
+
<h1>Submit a Task to the AI</h1>
|
7 |
+
<form action="/submit_task" method="post">
|
8 |
+
<input type="text" name="goal" placeholder="Enter your goal..." required />
|
9 |
+
<button type="submit">Submit</button>
|
10 |
+
</form>
|
11 |
+
</body>
|
12 |
+
</html>
|
dashboard.html
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html>
|
4 |
+
<head>
|
5 |
+
<title>AI Task Analytics</title>
|
6 |
+
<style>body { font-family: sans-serif; }</style>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>📊 Autonomous AI Analytics</h1>
|
10 |
+
<div id="goals"></div>
|
11 |
+
<div id="feedback"></div>
|
12 |
+
<script>
|
13 |
+
async function fetchData() {
|
14 |
+
const g = await fetch("/goals").then(r => r.text());
|
15 |
+
const f = await fetch("/feedback").then(r => r.text());
|
16 |
+
document.getElementById('goals').innerHTML = "<h2>Goals:</h2><pre>" + g + "</pre>";
|
17 |
+
document.getElementById('feedback').innerHTML = "<h2>Feedback:</h2><pre>" + f + "</pre>";
|
18 |
+
}
|
19 |
+
fetchData();
|
20 |
+
</script>
|
21 |
+
</body>
|
22 |
+
</html>
|
multi_agent.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
|
2 |
-
import
|
3 |
|
4 |
-
def
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
1 |
|
2 |
+
from agent import run_agent
|
3 |
|
4 |
+
def run_multi_agent_session(goal):
|
5 |
+
print("Agent 1: Interpreting goal")
|
6 |
+
result1 = run_agent(goal)
|
7 |
+
print("Agent 2: Verifying output")
|
8 |
+
result2 = run_agent(f"Evaluate and verify this result: {result1}")
|
9 |
+
print("Agent 3: Proposing improvements")
|
10 |
+
result3 = run_agent(f"Improve this: {result1}")
|
11 |
+
return result1, result2, result3
|
self_improve.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from agent import run_agent, codebase_path
|
3 |
+
from logger import logger
|
4 |
+
|
5 |
+
def self_improve():
|
6 |
+
logger.info("🔁 Self-improvement cycle started")
|
7 |
+
feedback = run_agent("Review and improve your own code.")
|
8 |
+
# Here we could add LLM logic to diff + rewrite source code
|
9 |
+
logger.info(f"Self-feedback: {feedback}")
|