Spaces:
Sleeping
Sleeping
File size: 6,423 Bytes
72052d3 1de2c87 72052d3 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 7cd9df8 6e3b051 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | ---
title: NeuralCAD
emoji: ⚙️
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
---
# NeuralCAD — Multi-Agent CAD Design
A multi-agent AI system that converts natural language descriptions of mechanical parts into CNC-machinable 3D models (STEP/STL). Four specialized AI agents collaborate with you in a shared chat to design, engineer, validate, and generate CadQuery code.
## How It Works
```
User ──→ Chat Interface ──→ Agent Orchestrator
│
┌───────────────┼───────────────┐
│ │ │
Design Agent Engineering CNC Agent
(form/shape) Agent (manufacturability)
│ (specs/dims) │
└───────────────┼───────────────┘
│
CAD Coder Agent
(CadQuery code)
│
Execute in Sandbox
│
3D Solid (B-rep)
╱ ╲
CNC Validator Exporter
(machinability (STEP + STL)
checks)
```
## Agents
| Agent | Role | Expertise |
|-------|------|-----------|
| **Design Agent** | Industrial Designer | Form, aesthetics, ergonomics, shape proposals |
| **Engineering Agent** | Mechanical Engineer | Dimensions, tolerances, materials, fastener specs |
| **CNC Agent** | Manufacturing Advisor | Tool access, wall thickness, axis requirements, cost |
| **CAD Coder** | CadQuery Programmer | Generates valid CadQuery Python code on demand |
## Quick Start
```bash
# Install dependencies
pip install -r requirements.txt
# Run the web app (mock backend, no API key needed)
python -m server.web --port 5000
# Open http://localhost:5000 in your browser
```
### With LLM Backends
```bash
# Gemini (free tier)
export GOOGLE_API_KEY=...
# Select GEMINI in the web UI backend toggle
# Claude (recommended for quality)
export ANTHROPIC_API_KEY=sk-ant-...
# Select CLAUDE in the web UI backend toggle
# GPT-4o
export OPENAI_API_KEY=sk-...
```
### CLI Pipeline (Direct)
```bash
# Mock backend
python -m core.pipeline "A mounting bracket with four M6 holes"
# With Claude
python -m core.pipeline "A flanged bearing housing" --backend anthropic
```
## Architecture
```
NeuralCAD/
├── agents/ # Multi-agent orchestration
│ ├── definitions.py # Agent roles, colors, personas
│ ├── orchestrator.py # Single-call + Mock orchestrators
│ ├── crew_orchestrator.py # CrewAI multi-call orchestrator
│ ├── prompts.py # System prompts, routing, JSON parsing
│ ├── design_state.py # Design decision accumulator
│ └── llm_adapter.py # CrewAI LLM adapter
├── core/ # CAD generation pipeline
│ ├── backends.py # LLM backends (Mock, Anthropic, OpenAI, Gemini)
│ ├── pipeline.py # Text-to-CNC orchestrator + CLI
│ ├── executor.py # Sandboxed CadQuery execution + export
│ ├── validator.py # CNC manufacturability checker
│ └── cadquery_prompts.py # CadQuery system prompt + few-shot examples
├── server/ # Web + MCP servers
│ ├── web.py # FastAPI app, static serving
│ ├── routes.py # Chat API endpoints
│ └── mcp.py # MCP server (Claude Desktop / Claude Code)
├── web/
│ └── index.html # Frontend: Three.js viewer + chat panel
└── tests/ # Test suite
```
### Orchestration Modes
| Backend | Mode | API Calls/Turn | Use Case |
|---------|------|----------------|----------|
| Mock | Template-based | 0 | UI development, demos |
| Gemini | Single-call | 1 | Free tier, rate-limited |
| Anthropic | CrewAI multi-call | 2-4 | Best quality |
| OpenAI | CrewAI multi-call | 2-4 | Best quality |
### Chat API
**POST /api/chat** — Multi-agent chat turn
```json
{
"message": "Make it 60mm wide with M4 base mounting",
"history": [{"role": "user", "content": "I need a servo bracket"}],
"mentions": [],
"backend": "mock"
}
```
**POST /api/report** — Generate design report from conversation
**GET /api/agents** — List available agents and metadata
## Features
- **Multi-agent chat** — 4 specialist agents collaborate on part design
- **@mention system** — Direct messages to specific agents (`@design`, `@engineering`, `@cnc`, `@cad`)
- **3D preview** — Real-time STL rendering with Three.js (orbit, zoom, pan)
- **Design state tracking** — Accumulates decisions across turns (localStorage persistence)
- **CNC validation** — Checks wall thickness, pocket ratios, tool access, axis requirements
- **Model gallery** — Browse and reload previously generated models
- **STEP + STL export** — Download CAM-ready files
- **MCP server** — Use from Claude Desktop or Claude Code
## MCP Server
```bash
# Connect to Claude Code
claude mcp add text-to-cnc python3 -m server.mcp
# Run standalone (SSE for remote integrations)
python -m server.mcp --transport sse --port 8000
```
### MCP Tools
| Tool | Description |
|------|-------------|
| `generate_cnc_model` | Text to CadQuery code to 3D solid to STEP/STL |
| `validate_cnc_model` | Run manufacturability checks on CadQuery code |
| `execute_cadquery_code` | Execute arbitrary CadQuery code |
| `chat_turn` | Multi-agent chat turn |
| `list_models` | List generated models |
## Testing
```bash
# All tests
python -m pytest
# Pure logic tests only (no CadQuery needed)
python -m pytest -m "not requires_cadquery"
# Integration tests
python -m pytest -m requires_cadquery
# Verbose
python -m pytest -v
```
## Docker
```bash
docker compose up --build
# Open http://localhost:7860
```
## Key Research
- **Text-to-CadQuery** (2025) — LLM generates CadQuery code directly
- **GenCAD** (2024) — Transformer + diffusion for image to CAD
- **NURBGen** (2025) — NURBS-based B-rep from text via LLM
|