Create modules/agents.py
Browse files- modules/agents.py +105 -0
modules/agents.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import random
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
from ai_engine import engine
|
| 5 |
+
from jarvis_links import get_link, get_random_template
|
| 6 |
+
|
| 7 |
+
class TrendHijacker:
|
| 8 |
+
name = "TrendHijacker"
|
| 9 |
+
icon = "🔥"
|
| 10 |
+
TREND_SEEDS = [
|
| 11 |
+
"website gratis 2025", "cara bikin toko online", "hosting murah Indonesia",
|
| 12 |
+
"bisnis online modal kecil", "tips freelancer Indonesia", "kerja remote dari rumah",
|
| 13 |
+
"jualan online shopee tips", "produk viral shopee", "diskon shopee hari ini",
|
| 14 |
+
]
|
| 15 |
+
async def run(self, custom_topic=None, **kwargs):
|
| 16 |
+
topic = custom_topic or random.choice(self.TREND_SEEDS)
|
| 17 |
+
prompt = f"""Kamu adalah content strategist viral Indonesia.
|
| 18 |
+
Topik trending: "{topic}"
|
| 19 |
+
Buat 3 ide konten viral untuk promosi affiliate Hostinger dan Shopee.
|
| 20 |
+
Format: JUDUL | PLATFORM | HOOK | KONTEN | CTA dengan link affiliate.
|
| 21 |
+
Bahasa Indonesia casual."""
|
| 22 |
+
result = await engine.think(prompt)
|
| 23 |
+
return {"module": self.name, "topic": topic, "timestamp": datetime.now().isoformat(), "output": result["response"], "provider": result["provider"]}
|
| 24 |
+
|
| 25 |
+
class ViralPredictor:
|
| 26 |
+
name = "ViralPredictor"
|
| 27 |
+
icon = "📊"
|
| 28 |
+
async def run(self, content="contoh konten affiliate", **kwargs):
|
| 29 |
+
prompt = f"""Analisa potensi viral konten ini di Indonesia:
|
| 30 |
+
KONTEN: {content}
|
| 31 |
+
Berikan: VIRAL SCORE (0-100) | PLATFORM TERBAIK | KEKUATAN | KELEMAHAN | REKOMENDASI
|
| 32 |
+
Bahasa Indonesia."""
|
| 33 |
+
result = await engine.think(prompt)
|
| 34 |
+
return {"module": self.name, "timestamp": datetime.now().isoformat(), "output": result["response"], "provider": result["provider"]}
|
| 35 |
+
|
| 36 |
+
class GhostNetwork:
|
| 37 |
+
name = "GhostNetwork"
|
| 38 |
+
icon = "👻"
|
| 39 |
+
async def run(self, content="konten affiliate default", **kwargs):
|
| 40 |
+
hostinger_link = get_link("hostinger")
|
| 41 |
+
shopee_link = get_link("shopee")
|
| 42 |
+
prompt = f"""Adaptasi konten ini untuk Instagram, TikTok, Twitter, Facebook, WhatsApp, Telegram:
|
| 43 |
+
KONTEN: {content}
|
| 44 |
+
Embed link natural: Hostinger: {hostinger_link} | Shopee: {shopee_link}
|
| 45 |
+
Sertakan hashtag dan waktu posting optimal WIB."""
|
| 46 |
+
result = await engine.think(prompt)
|
| 47 |
+
return {"module": self.name, "timestamp": datetime.now().isoformat(), "output": result["response"], "provider": result["provider"]}
|
| 48 |
+
|
| 49 |
+
class Scout:
|
| 50 |
+
name = "Scout"
|
| 51 |
+
icon = "🔍"
|
| 52 |
+
async def run(self, target="hostinger competitor indonesia", **kwargs):
|
| 53 |
+
prompt = f"""Riset mendalam: "{target}"
|
| 54 |
+
Berikan: OVERVIEW | PAIN POINTS | KOMPETITOR | PELUANG | KEYWORDS (10) | CONTENT IDEAS (5)
|
| 55 |
+
Fokus pasar Indonesia."""
|
| 56 |
+
result = await engine.think(prompt)
|
| 57 |
+
return {"module": self.name, "target": target, "timestamp": datetime.now().isoformat(), "output": result["response"], "provider": result["provider"]}
|
| 58 |
+
|
| 59 |
+
class Writer:
|
| 60 |
+
name = "Writer"
|
| 61 |
+
icon = "✍️"
|
| 62 |
+
async def run(self, topic="hosting murah", content_type="social_caption", platform="hostinger", **kwargs):
|
| 63 |
+
link = get_link(platform)
|
| 64 |
+
prompt = f"""Tulis {content_type} bahasa Indonesia tentang: "{topic}"
|
| 65 |
+
Affiliate: {platform.upper()} | Link: {link}
|
| 66 |
+
Syarat: casual, embed link natural, hook kuat, CTA tidak memaksa, tambah emojis."""
|
| 67 |
+
result = await engine.think(prompt)
|
| 68 |
+
return {"module": self.name, "topic": topic, "timestamp": datetime.now().isoformat(), "output": result["response"], "provider": result["provider"]}
|
| 69 |
+
|
| 70 |
+
class Publisher:
|
| 71 |
+
name = "Publisher"
|
| 72 |
+
icon = "📢"
|
| 73 |
+
async def run(self, content="konten affiliate", **kwargs):
|
| 74 |
+
prompt = f"""Buat jadwal publishing 7 hari untuk konten:
|
| 75 |
+
{content[:300]}
|
| 76 |
+
Format tabel: HARI | PLATFORM | JAM WIB | TIPE KONTEN | CATATAN
|
| 77 |
+
Tambahkan checklist sebelum posting."""
|
| 78 |
+
result = await engine.think(prompt)
|
| 79 |
+
return {"module": self.name, "timestamp": datetime.now().isoformat(), "output": result["response"], "provider": result["provider"]}
|
| 80 |
+
|
| 81 |
+
class Analyst:
|
| 82 |
+
name = "Analyst"
|
| 83 |
+
icon = "📈"
|
| 84 |
+
async def run(self, metrics=None, **kwargs):
|
| 85 |
+
metrics_str = str(metrics) if metrics else "Belum ada data. Buat rekomendasi KPI awal untuk affiliate marketing."
|
| 86 |
+
prompt = f"""Analisa performa affiliate marketing:
|
| 87 |
+
DATA: {metrics_str}
|
| 88 |
+
Berikan: OVERVIEW | TOP PERFORMING | UNDERPERFORMING | INSIGHT | 5 LANGKAH OPTIMASI | TARGET MINGGU DEPAN"""
|
| 89 |
+
result = await engine.think(prompt)
|
| 90 |
+
return {"module": self.name, "timestamp": datetime.now().isoformat(), "output": result["response"], "provider": result["provider"]}
|
| 91 |
+
|
| 92 |
+
MODULES = {
|
| 93 |
+
"trend": TrendHijacker(),
|
| 94 |
+
"viral": ViralPredictor(),
|
| 95 |
+
"ghost": GhostNetwork(),
|
| 96 |
+
"scout": Scout(),
|
| 97 |
+
"writer": Writer(),
|
| 98 |
+
"publisher": Publisher(),
|
| 99 |
+
"analyst": Analyst(),
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
async def run_module(module_name: str, **kwargs) -> dict:
|
| 103 |
+
if module_name not in MODULES:
|
| 104 |
+
return {"error": f"Module '{module_name}' not found"}
|
| 105 |
+
return await MODULES[module_name].run(**kwargs)
|