Update agent_manager.py
Browse files- agent_manager.py +54 -17
agent_manager.py
CHANGED
@@ -1,26 +1,63 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
from
|
4 |
-
from
|
|
|
|
|
|
|
|
|
5 |
|
6 |
class AgentManager:
|
7 |
def __init__(self, niche: str, business_type: str):
|
8 |
self.niche = niche
|
9 |
self.business_type = business_type
|
10 |
self.strategy_agent = StrategyAgent()
|
11 |
-
self.copy_agent
|
12 |
-
self.ad_agent
|
13 |
-
self.email_agent
|
|
|
|
|
|
|
14 |
|
15 |
-
def run_all(self):
|
16 |
-
"""Run each agent in sequence and return a summary dict."""
|
17 |
summary = {}
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
summary[
|
22 |
-
|
23 |
-
|
24 |
-
#
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return summary
|
|
|
1 |
+
# agent_manager.py
|
2 |
+
|
3 |
+
from strategy_agent import StrategyAgent
|
4 |
+
from copy_agent import CopyAgent
|
5 |
+
from ad_agent import AdAgent
|
6 |
+
from email_agent import EmailAgent
|
7 |
+
from shopify_client import create_shopify_product
|
8 |
+
from memory.database import init_db, log_memory
|
9 |
|
10 |
class AgentManager:
|
11 |
def __init__(self, niche: str, business_type: str):
|
12 |
self.niche = niche
|
13 |
self.business_type = business_type
|
14 |
self.strategy_agent = StrategyAgent()
|
15 |
+
self.copy_agent = CopyAgent()
|
16 |
+
self.ad_agent = AdAgent()
|
17 |
+
self.email_agent = EmailAgent()
|
18 |
+
|
19 |
+
# Ensure the DB/table exists
|
20 |
+
init_db()
|
21 |
|
22 |
+
def run_all(self) -> dict:
|
|
|
23 |
summary = {}
|
24 |
+
|
25 |
+
# 1) StrategyAgent
|
26 |
+
strat = self.strategy_agent.run(self.niche, self.business_type)
|
27 |
+
summary["strategy"] = strat
|
28 |
+
log_memory("StrategyAgent", "run", strat)
|
29 |
+
|
30 |
+
# 2) CopyAgent
|
31 |
+
copy = self.copy_agent.run(self.niche, self.business_type)
|
32 |
+
summary["copy"] = copy
|
33 |
+
log_memory("CopyAgent", "run", copy)
|
34 |
+
|
35 |
+
# 3) AdAgent
|
36 |
+
ads = self.ad_agent.run(self.niche, self.business_type)
|
37 |
+
summary["ads"] = ads
|
38 |
+
log_memory("AdAgent", "run", ads)
|
39 |
+
|
40 |
+
# 4) EmailAgent
|
41 |
+
emails = self.email_agent.run(self.niche, self.business_type)
|
42 |
+
summary["emails"] = emails
|
43 |
+
log_memory("EmailAgent", "run", emails)
|
44 |
+
|
45 |
+
# 5) Shopify Publishing
|
46 |
+
try:
|
47 |
+
title = f"{self.business_type} in {self.niche}"
|
48 |
+
description = summary["copy"]
|
49 |
+
price = "49.00"
|
50 |
+
storefront_url = create_shopify_product(
|
51 |
+
title=title,
|
52 |
+
description=description,
|
53 |
+
price=price,
|
54 |
+
image_url=None
|
55 |
+
)
|
56 |
+
summary["shopify_url"] = storefront_url
|
57 |
+
log_memory("ShopifyClient", "create_product", storefront_url)
|
58 |
+
except Exception as e:
|
59 |
+
error_str = str(e)
|
60 |
+
summary["shopify_error"] = error_str
|
61 |
+
log_memory("ShopifyClient", "error", error_str)
|
62 |
+
|
63 |
return summary
|