Spaces:
Sleeping
Sleeping
Commit ·
a26fb14
1
Parent(s): 249942d
refactor: load agent definitions from config.yaml
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- agents/definitions.py +24 -63
agents/definitions.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
| 1 |
-
"""Multi-agent definitions for NeuralCAD collaborative design chat.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
from dataclasses import dataclass
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
@dataclass
|
|
@@ -15,69 +20,25 @@ class AgentDef:
|
|
| 15 |
backstory: str
|
| 16 |
|
| 17 |
|
| 18 |
-
|
| 19 |
-
"
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
"
|
| 28 |
-
"
|
| 29 |
-
"
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
id="engineering",
|
| 36 |
-
name="Engineering Agent",
|
| 37 |
-
role="Mechanical Engineer",
|
| 38 |
-
color="#00b4d8",
|
| 39 |
-
avatar="EA",
|
| 40 |
-
goal="Ensure parts are structurally sound with correct dimensions, tolerances, materials, and fastener specifications.",
|
| 41 |
-
backstory=(
|
| 42 |
-
"You are a senior mechanical engineer with deep knowledge of materials science, "
|
| 43 |
-
"stress analysis, and fastener standards. You specify wall thicknesses, fillet radii, "
|
| 44 |
-
"clearance holes (M3=3.4mm, M4=4.5mm, M5=5.5mm, M6=6.6mm, M8=9.0mm), and material "
|
| 45 |
-
"recommendations. You flag structural concerns and suggest reinforcements like ribs "
|
| 46 |
-
"or gussets when loads are significant."
|
| 47 |
-
),
|
| 48 |
-
),
|
| 49 |
-
"cnc": AgentDef(
|
| 50 |
-
id="cnc",
|
| 51 |
-
name="CNC Agent",
|
| 52 |
-
role="CNC Manufacturing Advisor",
|
| 53 |
-
color="#00e676",
|
| 54 |
-
avatar="CA",
|
| 55 |
-
goal="Advise on manufacturability: tool access, wall thickness limits, pocket ratios, axis requirements, and cost implications.",
|
| 56 |
-
backstory=(
|
| 57 |
-
"You are a CNC machinist with 20 years of shop floor experience. You know what "
|
| 58 |
-
"tool geometries can reach, what aspect ratios cause chatter, and when to recommend "
|
| 59 |
-
"3-axis vs 3+2 vs 5-axis. You flag undercuts, thin walls (<1.5mm), deep pockets "
|
| 60 |
-
"(>4:1 ratio), and features that need special fixturing. You think about setup count "
|
| 61 |
-
"and machining time."
|
| 62 |
-
),
|
| 63 |
-
),
|
| 64 |
-
"cad": AgentDef(
|
| 65 |
-
id="cad",
|
| 66 |
-
name="CAD Coder",
|
| 67 |
-
role="CadQuery Code Generator",
|
| 68 |
-
color="#ffab40",
|
| 69 |
-
avatar="CC",
|
| 70 |
-
goal="Generate valid CadQuery Python code that produces the agreed-upon 3D model.",
|
| 71 |
-
backstory=(
|
| 72 |
-
"You are an expert CadQuery programmer. You only speak when asked to generate "
|
| 73 |
-
"a preview or produce code. You take the design specifications agreed upon by the "
|
| 74 |
-
"team and translate them into precise CadQuery Python code. Your code always assigns "
|
| 75 |
-
"the result to a variable called `result` as a cq.Workplane object."
|
| 76 |
-
),
|
| 77 |
-
),
|
| 78 |
-
}
|
| 79 |
|
| 80 |
-
#
|
| 81 |
AGENT_COLORS = {agent.id: agent.color for agent in AGENTS.values()}
|
| 82 |
AGENT_AVATARS = {agent.id: agent.avatar for agent in AGENTS.values()}
|
| 83 |
AGENT_NAMES = {agent.id: agent.name for agent in AGENTS.values()}
|
|
|
|
| 1 |
+
"""Multi-agent definitions for NeuralCAD collaborative design chat.
|
| 2 |
+
|
| 3 |
+
Agent data is loaded from config.yaml. The AGENTS dict, AGENT_COLORS,
|
| 4 |
+
AGENT_NAMES, and AGENT_AVATARS are kept for backward compatibility.
|
| 5 |
+
"""
|
| 6 |
|
| 7 |
from dataclasses import dataclass
|
| 8 |
+
from config.settings import settings
|
| 9 |
|
| 10 |
|
| 11 |
@dataclass
|
|
|
|
| 20 |
backstory: str
|
| 21 |
|
| 22 |
|
| 23 |
+
def _load_agents() -> dict[str, AgentDef]:
|
| 24 |
+
"""Load agent definitions from config.yaml."""
|
| 25 |
+
agents = {}
|
| 26 |
+
for agent_id, cfg in settings.agents.items():
|
| 27 |
+
agents[agent_id] = AgentDef(
|
| 28 |
+
id=agent_id,
|
| 29 |
+
name=cfg.get("name", agent_id.title()),
|
| 30 |
+
role=cfg.get("role", ""),
|
| 31 |
+
color=cfg.get("color", "#888888"),
|
| 32 |
+
avatar=cfg.get("avatar", agent_id[0].upper()),
|
| 33 |
+
goal=cfg.get("goal", ""),
|
| 34 |
+
backstory=cfg.get("backstory", ""),
|
| 35 |
+
)
|
| 36 |
+
return agents
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
AGENTS: dict[str, AgentDef] = _load_agents()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
# Backward-compatible convenience dicts
|
| 42 |
AGENT_COLORS = {agent.id: agent.color for agent in AGENTS.values()}
|
| 43 |
AGENT_AVATARS = {agent.id: agent.avatar for agent in AGENTS.values()}
|
| 44 |
AGENT_NAMES = {agent.id: agent.name for agent in AGENTS.values()}
|