AI Designer is a comprehensive FreeCAD automation system that allows users to interact with FreeCAD using natural language commands. By leveraging Large Language Models (LLM), the application translates user input into executable commands for FreeCAD, maintaining intelligent state management and providing real-time feedback.
Key Features:
- π§ Intelligent State Management: Saves and retrieves current design state with all required data
- β‘ Low-Latency Processing: Optimized for quick decision-making and execution
- π Real-time Updates: Live progress tracking via WebSocket connections
- π― LLM-Powered Decisions: Uses AI to make intelligent next-step decisions
- π Complete Component Building: Capable of building entire design components
ai-designing-designengineer/
βββ src/
β βββ ai_designer/ # Main package
β βββ __init__.py # Package initialization
β βββ __main__.py # CLI entry point (python -m ai_designer)
β βββ cli.py # Command-line interface
β βββ core/ # Core system components
β β βββ orchestrator.py # System orchestration
β β βββ queue_manager.py # Command queue management
β β βββ intent_processor.py # Natural language processing
β β βββ state_llm_integration.py # State-aware LLM integration
β βββ freecad/ # FreeCAD API integration
β β βββ api_client.py # FreeCAD API communication
β β βββ command_executor.py # Command execution
β β βββ state_manager.py # FreeCAD state management
β β βββ state_aware_processor.py # State-aware processing
β βββ llm/ # LLM integration
β β βββ client.py # LLM client interfaces
β β βββ prompt_templates.py # LLM prompt templates
β βββ realtime/ # Real-time features
β β βββ websocket_manager.py # WebSocket connections
β βββ parsers/ # Command parsing
β β βββ command_parser.py # Natural language parsing
β βββ redis_utils/ # Redis state caching
β βββ services/ # Additional services
β βββ utils/ # Utility functions
β βββ analysis.py # Design analysis tools
β βββ validation.py # Input validation
βββ examples/ # Usage examples
β βββ demos/ # Demo scripts
β β βββ demo_continuous_updates.py # Continuous updates demo
β β βββ demo_persistent_fix.py # Persistent GUI demo
β β βββ demo_real_execution.py # Real execution demo
β β βββ demo_realtime_freecad.py # Real-time FreeCAD demo
β β βββ demo_realtime_gui.py # Real-time GUI demo
βββ tools/ # Development and utility tools
β βββ monitoring/ # Monitoring tools
β β βββ websocket_monitor.py # WebSocket connection monitor
β βββ gui/ # GUI management tools
β β βββ simple_gui_launcher.py # Persistent GUI launcher
β β βββ direct_gui_commands.py # Direct GUI command sender
β βββ debug/ # Debugging utilities
β βββ testing/ # Testing tools
β βββ utilities/ # General utilities
β βββ demo_state_management.py # State management demo
β βββ state_cli_example.py # CLI usage example
β βββ websocket_client_example.py # WebSocket client example
βββ tools/ # Development and testing tools
β βββ monitoring/ # Real-time monitoring tools
β β βββ websocket_monitor.py # WebSocket real-time monitor
β βββ gui/ # GUI management tools
β β βββ simple_gui_launcher.py # Persistent FreeCAD GUI launcher
β β βββ direct_gui_commands.py # Direct GUI command sender
β βββ debug/ # Debug and troubleshooting tools
β β βββ debug_freecad_gui.py # GUI debugging utilities
β β βββ debug_gui_communication.py # Communication debugging
β βββ testing/ # Testing and validation tools
β β βββ test_complex_workflow.py # Complex workflow tests
β β βββ test_persistent_gui_fix.py # GUI persistence tests
β β βββ test_realtime_commands.py # Real-time command tests
β β βββ test_redis_demo.py # Redis integration tests
β βββ utilities/ # General utilities
β βββ verify_real_objects.py # Object verification utility
β βββ create_gear.py # Gear creation utility
β βββ quick_test_workflow.py # Quick workflow testing
βββ scripts/ # Utility scripts
β βββ run_complex_demo.sh # Complex shapes demo
β βββ run_tests.sh # Test runner
βββ tests/ # Test suite
β βββ test_freecad.py # FreeCAD tests
β βββ test_llm.py # LLM tests
β βββ test_state_analysis.py # State analysis tests
βββ docs/ # Documentation
β βββ architecture.md # System architecture
β βββ STATE_MANAGEMENT.md # State management guide
β βββ STATE_ANALYSIS.md # State analysis guide
β βββ advanced/ # Advanced documentation
β βββ COMPLEX_SHAPES.md # Complex shapes guide
βββ config/ # Configuration files
β βββ config.yaml # Main configuration
β βββ redis.conf # Redis configuration
βββ outputs/ # Generated files
βββ pyproject.toml # Project configuration and dependencies
βββ LICENSE # MIT License
βββ CONTRIBUTING.md # Contribution guidelines
βββ README.md # This file
# Install FreeCAD (required)
sudo apt install freecad # Ubuntu/Debian
# or
brew install freecad # macOS
# Install Redis (optional, for enhanced features)
sudo apt install redis-server # Ubuntu/Debian
# or
brew install redis # macOS# Clone the repository
git clone https://github.com/your-username/ai-designing-designengineer.git
cd ai-designing-designengineer
# Install in development mode
pip install -e .[dev]pip install ai-designer-
Set your LLM API key:
export GOOGLE_API_KEY="your-api-key" # or export OPENAI_API_KEY="your-api-key"
-
Start Redis (optional but recommended for enhanced features):
redis-server
# Run AI Designer with standard features
ai-designer --interactive
# Execute a single command
ai-designer "Create a cube with dimensions 10x10x10"
# Analyze an existing FreeCAD file
ai-designer --analyze path/to/file.FCStd# Run with enhanced state management and real-time features
ai-designer --enhanced --interactive --llm-provider google --llm-api-key your-key
# Run enhanced mode with custom configuration
ai-designer --enhanced --redis-host localhost --websocket-port 8765 --max-concurrent 5from ai_designer import FreeCADCLI
# Initialize the CLI
cli = FreeCADCLI(
use_headless=True,
llm_provider='google',
llm_api_key='your-api-key'
)
# Execute commands
if cli.initialize():
cli.execute_command("Create a cube and add a cylinder next to it")from ai_designer.core.orchestrator import SystemOrchestrator
# Initialize with full configuration
config = {
'redis_host': 'localhost',
'redis_port': 6379,
'llm_provider': 'google',
'llm_api_key': 'your-api-key',
'enable_realtime': True,
'websocket_port': 8765
}
orchestrator = SystemOrchestrator(config)
orchestrator.start_system()
# Process commands with full state awareness
result = orchestrator.process_user_input_enhanced(
"Create a complex building structure with multiple floors",
session_id="my_design_session"
)
print(f"Status: {result['status']}")
print(f"Objects created: {result['execution']['objects_created']}")import asyncio
import websockets
import json
async def websocket_client():
uri = "ws://localhost:8765"
async with websockets.connect(uri) as websocket:
# Register for session updates
await websocket.send(json.dumps({
"type": "register_session",
"session_id": "my_session"
}))
# Listen for real-time updates
async for message in websocket:
data = json.loads(message)
print(f"Update: {data}")
# Run the WebSocket client
asyncio.run(websocket_client())ai-designer "Create a cube with dimensions 20x20x20"
ai-designer "Add a cylinder with radius 5 and height 15 next to the cube"
ai-designer "Change the cube color to red and the cylinder color to blue"ai-designer --enhanced "Design a simple house with walls, roof, and windows"
ai-designer --enhanced "Create a mechanical part with holes and fillets"
ai-designer --enhanced "Build a tower structure with multiple levels"ai-designer "Analyze the current design and provide dimensions"
ai-designer "Export the design as STL file"
ai-designer "What objects are currently in the document?"The system implements a comprehensive architecture with the following layers:
- Natural Language Interface: Accept user commands in plain English
- Error Handling: Comprehensive error recovery and user feedback
- Live Updates: Real-time progress tracking and notifications
- Intent Processing: Understands and categorizes user requirements
- Command Generation: Creates appropriate FreeCAD commands
- Context Analysis: Analyzes current design state for informed decisions
- Pattern Recognition: Learns from previous commands and interactions
- Queue Management: Handles command prioritization and execution order
- Load Balancing: Distributes processing load across available resources
- Safe Execution: Sandboxed command execution with timeout protection
- Design State Management: Maintains current design context and history
- Session Tracking: Persistent user sessions across interactions
- Performance Metrics: System performance and usage analytics
- WebSocket Connections: Live client connections for real-time updates
- Progress Broadcasting: Real-time command execution progress
- State Notifications: Immediate design state change notifications
- State Caching: Redis-based state storage for low-latency access
- Async Processing: Non-blocking operations for better responsiveness
- Performance Metrics: Real-time system performance monitoring
- Smart Caching: LLM decision caching to reduce API calls
metrics = orchestrator.get_performance_metrics()
# Includes: processing time, success rate, cache hit rate, connection countgit clone https://github.com/your-username/ai-designing-designengineer.git
cd ai-designing-designengineer
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# or
venv\Scripts\activate # Windows
# Install in development mode
pip install -e .[dev]# Run all tests
pytest
# Run specific test categories
pytest tests/test_freecad.py
pytest tests/test_llm.py
# Run with coverage
pytest --cov=ai_designer# Format code
black src/ tests/
# Lint code
flake8 src/ tests/
# Type checking
mypy src/We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes with tests
- Run quality checks:
black src/ && flake8 src/ && pytest - Submit a pull request
AI Designer includes comprehensive development and testing tools located in the tools/ directory:
- WebSocket Monitor (
tools/monitoring/websocket_monitor.py): Real-time monitoring of WebSocket communication - Live progress tracking and error notifications
- GUI Launcher (
tools/gui/simple_gui_launcher.py): Persistent FreeCAD GUI management - Direct Commands (
tools/gui/direct_gui_commands.py): Send commands directly to GUI via socket
- GUI Debug (
tools/debug/debug_freecad_gui.py): FreeCAD GUI debugging utilities - Communication Debug (
tools/debug/debug_gui_communication.py): Socket communication testing
- Workflow Tests (
tools/testing/test_complex_workflow.py): Complex workflow validation - GUI Tests (
tools/testing/test_persistent_gui_fix.py): GUI persistence testing - Real-time Tests (
tools/testing/test_realtime_commands.py): Real-time command execution tests
- Object Verification (
tools/utilities/verify_real_objects.py): Verify created FreeCAD objects - Gear Creation (
tools/utilities/create_gear.py): Complex gear generation utility
For detailed tool usage, see tools/README.md.
- Architecture Guide - System architecture overview
- State Management - State management details
- Complex Shapes - Advanced shape creation
- API Reference - Complete API documentation
- Command Sanitization: Prevents dangerous operations
- Execution Sandboxing: Isolated command execution environment
- State Validation: Ensures design state consistency
- Timeout Protection: Prevents infinite loops and hangs
- Resource Monitoring: Memory and CPU usage limits
For detailed information about specific components:
- Tools Guide - Complete guide to development and utility tools
- Examples Guide - Usage examples and demo scripts
- Real-time System Guide - WebSocket and real-time features
- Security Guide - Security features and best practices
- Project Summary - High-level project overview
This project is licensed under the MIT License - see the LICENSE file for details.
- FreeCAD community for the excellent CAD platform
- OpenAI and Google for LLM capabilities
- Redis for high-performance caching
- WebSocket protocol for real-time communication
Experience AI Designer in action:
# Start the enhanced system
ai-designer --enhanced --interactive
# In another terminal, connect to real-time updates
python examples/websocket_client_example.py
# Try these commands:
"Create a parametric model of a chair"
"Add a table with adjustable height"
"Design a simple house layout"
"Export the entire scene as OBJ file"The system will demonstrate:
- β Intelligent intent understanding and processing
- β State-aware LLM decision making
- β Real-time progress tracking and updates
- β Automatic state management and checkpointing
- β Comprehensive error handling and recovery
- β Performance monitoring and optimization
Experience the future of AI-powered CAD automation! π