Merge branch 'review/pr-359'
This commit is contained in:
@@ -24,7 +24,11 @@ from services.intelligence.agents.core_agent_framework import (
|
||||
BaseALwrityAgent, AgentAction, AgentPerformance, StrategyOrchestratorAgent
|
||||
)
|
||||
from services.intelligence.agents.specialized_agents import (
|
||||
ContentStrategyAgent, CompetitorResponseAgent, SEOOptimizationAgent, SocialAmplificationAgent
|
||||
ContentStrategyAgent,
|
||||
CompetitorResponseAgent,
|
||||
SEOOptimizationAgent,
|
||||
SocialAmplificationAgent,
|
||||
StrategyArchitectAgent,
|
||||
)
|
||||
from services.intelligence.agents.trend_surfer_agent import TrendSurferAgent
|
||||
from services.intelligence.agents.market_signal_detector import (
|
||||
@@ -157,6 +161,13 @@ class ALwrityAgentOrchestrator:
|
||||
self.social_agent = SocialAmplificationAgent(self.user_id, self.config.shared_llm, llm=self.llm)
|
||||
self.agents['social'] = self.social_agent
|
||||
|
||||
# Strategy Architect Agent
|
||||
if enabled_by_key.get("strategy_architect", True):
|
||||
from services.intelligence.txtai_service import TxtaiIntelligenceService
|
||||
intel_service = TxtaiIntelligenceService(self.user_id)
|
||||
self.strategy_agent = StrategyArchitectAgent(intel_service, self.user_id)
|
||||
self.agents['strategy'] = self.strategy_agent
|
||||
|
||||
# Trend Surfer Agent
|
||||
if enabled_by_key.get("trend_surfer", True):
|
||||
# TrendSurferAgent needs TxtaiIntelligenceService, which we might need to get from SIF or initialize
|
||||
|
||||
@@ -29,6 +29,19 @@ def _coerce_status(value: Any) -> str:
|
||||
return "pending"
|
||||
|
||||
|
||||
def _proposal_priority_rank(priority: str) -> int:
|
||||
return {"low": 0, "medium": 1, "high": 2}.get(str(priority or "").lower(), 1)
|
||||
|
||||
|
||||
def _proposal_order_key(proposal: Any) -> tuple:
|
||||
return (
|
||||
str(getattr(proposal, "source_agent", "") or "").lower(),
|
||||
str(getattr(proposal, "title", "") or "").lower(),
|
||||
str(getattr(proposal, "description", "") or "").lower(),
|
||||
str(getattr(proposal, "action_url", "") or "").lower(),
|
||||
)
|
||||
|
||||
|
||||
def _fallback_tasks(date: str) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
{
|
||||
@@ -282,7 +295,7 @@ async def generate_agent_enhanced_plan(db: Session, user_id: str, date: str) ->
|
||||
orchestrator.agents.get('seo'), # SEOOptimizationAgent
|
||||
orchestrator.agents.get('social'), # SocialAmplificationAgent
|
||||
orchestrator.agents.get('competitor'), # CompetitorResponseAgent
|
||||
# Add StrategyArchitect if available in orchestrator.agents
|
||||
orchestrator.agents.get('strategy'), # StrategyArchitectAgent
|
||||
]
|
||||
|
||||
# Filter out None agents (disabled/failed init)
|
||||
@@ -313,7 +326,18 @@ async def generate_agent_enhanced_plan(db: Session, user_id: str, date: str) ->
|
||||
key = f"{p.pillar_id}:{p.title}"
|
||||
if key not in unique_map:
|
||||
unique_map[key] = p
|
||||
elif p.priority == "high": # Overwrite with higher priority
|
||||
continue
|
||||
|
||||
existing = unique_map[key]
|
||||
if _proposal_priority_rank(p.priority) > _proposal_priority_rank(existing.priority):
|
||||
unique_map[key] = p
|
||||
continue
|
||||
|
||||
# Deterministic tie-breaker for equal priority proposals.
|
||||
if (
|
||||
_proposal_priority_rank(p.priority) == _proposal_priority_rank(existing.priority)
|
||||
and _proposal_order_key(p) < _proposal_order_key(existing)
|
||||
):
|
||||
unique_map[key] = p
|
||||
|
||||
agent_tasks = list(unique_map.values())
|
||||
|
||||
Reference in New Issue
Block a user