neuralcad / agents /definitions.py
CallMeDaniel's picture
refactor: convert AgentDef from dataclass to Pydantic BaseModel
b20b4ef
"""Multi-agent definitions for NeuralCAD collaborative design chat.
Agent data is loaded from config.yaml. The AGENTS dict, AGENT_COLORS,
AGENT_NAMES, and AGENT_AVATARS are kept for backward compatibility.
"""
from pydantic import BaseModel
from config.settings import settings
class AgentDef(BaseModel):
"""Definition of a chat agent."""
id: str
name: str
role: str
color: str
avatar: str
goal: str
backstory: str
def _load_agents() -> dict[str, AgentDef]:
"""Load agent definitions from config.yaml."""
agents = {}
for agent_id, cfg in settings.agents.items():
agents[agent_id] = AgentDef(
id=agent_id,
name=cfg.name or agent_id.title(),
role=cfg.role,
color=cfg.color,
avatar=cfg.avatar or agent_id[0].upper(),
goal=cfg.goal,
backstory=cfg.backstory,
)
return agents
AGENTS: dict[str, AgentDef] = _load_agents()
# Backward-compatible convenience dicts
AGENT_COLORS = {agent.id: agent.color for agent in AGENTS.values()}
AGENT_AVATARS = {agent.id: agent.avatar for agent in AGENTS.values()}
AGENT_NAMES = {agent.id: agent.name for agent in AGENTS.values()}