""" CivicAI Analyst Agent Interfaces with the environment to summarize real-world context, historical trends, and current emergencies for the Policy maker. """ from __future__ import annotations from civicai.models import SocietyState, AgentMessage class AnalystAgent: def __init__(self, name: str = "AnalystAgent", role: str = "📊 Chief Analyst"): self.name = name self.role = role def analyze_state(self, state: SocietyState) -> AgentMessage: """Analyze current state and active events.""" warnings = [] if state.inflation > 0.08: warnings.append(f"Inflation is extremely high ({state.inflation:.1%}). Fiscal tightening needed.") if state.employment_rate < 0.80: warnings.append(f"High unemployment ({1-state.employment_rate:.1%}). Consider stimulus or education.") if state.public_satisfaction < 0.40: warnings.append("Public satisfaction critically low. Risk of severe unrest.") events_str = ", ".join(state.active_events) if state.active_events else "None" reasoning = ( f"GDP Growth: {state.gdp_growth:.2%}, Inflation: {state.inflation:.2%}, " f"Active Events: {events_str}. " f"Warnings: {' '.join(warnings) if warnings else 'None.'}" ) return AgentMessage( agent_name=self.name, agent_role=self.role, proposal="Data Analysis Complete. Awaiting Policy action.", reasoning=reasoning )