An AI-powered orchestration system for architectural, urban, and spatial design that treats design problems as constraint satisfaction and structural exploration problems (SEP). The system coordinates interaction between AI components (for interpretation and orchestration), deterministic computational engines (for validation and exploration), and human decision makers (for final accountability).
- π€ LLM-Powered Intelligence - Natural language requirement interpretation using GPT-4, Claude, or local models
- π LangGraph Workflow - Advanced workflow orchestration with conditional routing and state management
- π Multi-Language Support - Process requirements in English, Chinese, Japanese, Spanish, and more
- π Conflict Detection - Automatic identification and resolution of conflicting constraints
- π Task Decomposition - Intelligent breakdown of complex design problems
- β Deterministic Validation - Computational engines guarantee correctness
- π§© SEP_Solver Integration - Structural exploration and constraint satisfaction solving with web UI support
- π Human-in-the-Loop - AI outputs require human approval for critical decisions
- π Cost Tracking - Real-time monitoring of LLM usage and costs
- β‘ Response Caching - 90%+ cost reduction for repeated requests
- π Automatic Fallback - Falls back to rule-based mode on LLM failures
- π Complete Audit Trail - Full traceability from requirements to decisions
- π Extensible Architecture - Integrate RAG, MCP tools, or company-specific knowledge sources
The system follows a three-layer architecture with strict separation of concerns:
AI thinks about the design (interpretation, planning, analysis):
- Requirement Interpreter - Converts natural language to structured constraints
- Task Decomposer - Breaks down complex problems into manageable tasks
- Conflict Analyzer - Identifies and suggests resolutions for conflicts
- LLM Providers - OpenAI, Anthropic, Local (Ollama), Mock
Computers prove correctness (validation, exploration, simulation):
- Geometry Engine - Spatial validation and calculations
- Rule Checker - Regulatory compliance verification
- Structural Analyzer - Engineering constraint validation
- Environmental Simulator - Performance analysis
- Aesthetic Evaluator - Design quality assessment
- SEP_Solver - Structural exploration and constraint satisfaction solving
Humans take responsibility (approval gates, decision making):
- Approval Gates - Human confirmation for AI outputs
- Decision Tracking - Complete audit trail
- Stakeholder Management - Multi-stakeholder coordination
- Design State Management - Persistent state tracking
# Clone the repository
git clone <repository-url>
cd design_configulator
# Install dependencies
pip install -r requirements.txt- Set up LLM providers - See docs/README_LLM_SETUP.md
- Configure llm_config.json with your API keys
- Optional: Set up environment variables in
.env
python web_app.pyThen open your browser to:
- Manual Workflow: http://localhost:5000
- Automated Workflow: http://localhost:5000/automated
- Integrated Workflow (with SEP_Solver): http://localhost:5000/integrated
# Interactive CLI
python examples/interactive_cli.py
# Batch processing
python examples/batch_workflow.py
# SEP_Solver integration
python examples/sep_solver_integration_example.pyAll documentation is in the docs/ directory:
- Setup Guide - LLM provider configuration
- Automated Workflow - Workflow automation guide
- Web App Guide - Web interface documentation
- SEP_Solver Quick Start - Get started with SEP_Solver integration
- Architecture - System design and architecture
- Project Structure - Directory organization
- Extending LLM Providers - RAG, MCP, and custom knowledge integration
- Adding New Solvers - Solver extensibility guide
- SEP_Solver Integration - Complete SEP_Solver integration guide
- Constraint Evaluation Examples - Working with constraint expressions
- SEP_Solver Troubleshooting - Common issues and solutions
cd design-configurator
pip install -r requirements.txt
pip install openai # For OpenAI (GPT-4, GPT-3.5) pip install anthropic # For Anthropic (Claude) pip install requests # For local models (Ollama)
pip install -e ".[dev]"
### LLM Setup
1. **Get an API key** from [OpenAI](https://platform.openai.com/api-keys) (recommended)
2. **Configure** `llm_config.json`:
```json
{
"enabled": true,
"provider": "openai",
"openai_api_key": "sk-proj-YOUR-KEY-HERE",
"openai_model": "gpt-4o-mini",
"fallback_to_rules": true,
"max_cost_per_day": 10.0,
"enable_response_caching": true
}
- Test the setup:
python examples/llm_quickstart.pyExpected output:
β LLM Enabled: True
β Provider: openai
β All examples completed successfully!
Total Cost: $0.0011
See README_LLM_SETUP.md for detailed LLM configuration.
from design_configurator.orchestration import WorkflowEngine, WorkflowConfig
from design_configurator.llm_integration import (
RequirementInterpreter,
ConflictAnalyzer,
TaskDecomposer,
)
from design_configurator.llm_integration.provider_factory import create_llm_provider
# Create LLM provider
provider = create_llm_provider(config)
# Initialize components
interpreter = RequirementInterpreter(llm_provider=provider)
analyzer = ConflictAnalyzer(llm_provider=provider)
decomposer = TaskDecomposer(llm_provider=provider)
# Create workflow engine (powered by LangGraph)
engine = WorkflowEngine(
interpreter=interpreter,
analyzer=analyzer,
decomposer=decomposer,
translator=translator,
config=WorkflowConfig()
)
# Run complete pipeline with conditional routing
requirements = [
"The building must have at least 3 floors",
"Total height must not exceed 15 meters",
"Maximize natural light"
]
result = engine.run_full_pipeline(requirements)
print(f"Success: {result['success']}")
print(f"Constraints: {result['constraints_count']}")
for stage in result['stages']:
print(f" {stage['stage']}: {stage['duration_ms']:.2f}ms")See docs/LANGGRAPH_INTEGRATION.md for advanced features.
from design_configurator.llm_integration import (
LLMConfiguration,
RequirementInterpreter,
RequirementInput,
)
from design_configurator.llm_integration.provider_factory import create_llm_provider
import json
# Load configuration
with open('llm_config.json', 'r') as f:
config = LLMConfiguration.from_dict(json.load(f))
# Create LLM provider
provider = create_llm_provider(config)
# Create interpreter with LLM support
interpreter = RequirementInterpreter(
llm_provider=provider
)
# Interpret a requirement
requirement = RequirementInput(
text="The building height must not exceed 50 meters",
stakeholder_id="architect_001",
context="Urban residential project"
)
candidates = interpreter.interpret_requirement(requirement)
for candidate in candidates:
print(f"Type: {candidate.constraint_type.value}")
print(f"Confidence: {candidate.confidence:.2f}")
print(f"Source: {candidate.source}")
print(f"Explanation: {candidate.explanation}")
print(f"Axes: {', '.join(candidate.evaluation_axes)}")# English
requirement_en = RequirementInput(
text="The building must have parking for 100 vehicles",
stakeholder_id="developer_001"
)
# Chinese (δΈζ)
requirement_zh = RequirementInput(
text="ε»ΊηεΏ
ι‘»ζ100δΈͺε车δ½",
stakeholder_id="developer_002"
)
# Japanese (ζ₯ζ¬θͺ)
requirement_ja = RequirementInput(
text="ι§θ»ε ΄γ―100ε°εεΏ
θ¦γ§γ",
stakeholder_id="developer_003"
)
# All work identically!
for req in [requirement_en, requirement_zh, requirement_ja]:
candidates = interpreter.interpret_requirement(req)
print(f"Interpreted: {candidates[0].explanation}")from design_configurator.llm_integration import ConflictAnalyzer
from design_configurator.core.models import Constraint, ConstraintSource
from design_configurator.core.types import ConstraintType
analyzer = ConflictAnalyzer(
llm_provider=provider
)
constraints = [
Constraint(
natural_language="Building height must not exceed 50 meters",
type=ConstraintType.HARD,
source=ConstraintSource(stakeholder_id="city_planner")
),
Constraint(
natural_language="Building must be at least 60 meters tall",
type=ConstraintType.HARD,
source=ConstraintSource(stakeholder_id="developer")
),
]
conflicts = analyzer.analyze_conflicts(constraints)
for conflict in conflicts:
print(f"Conflict Type: {conflict.conflict_type}")
print(f"Severity: {conflict.severity}")
print(f"Explanation: {conflict.explanation}")
print(f"Resolution Strategies:")
for strategy in conflict.resolution_strategies:
print(f" - {strategy}")# Get real-time usage statistics
stats = provider.get_usage_stats()
print(f"Total Requests: {stats.request_count}")
print(f"Total Tokens: {stats.total_tokens:,}")
print(f"Total Cost: ${stats.total_cost_usd:.4f}")
print(f"Average Latency: {stats.average_latency_ms:.2f}ms")
print(f"Cache Hit Rate: {stats.cache_hits / (stats.cache_hits + stats.cache_misses) * 100:.1f}%")The system integrates with SEP_Solver for structural exploration and constraint satisfaction:
from design_configurator.solvers import SEPSolverAdapter
from design_configurator.core.models import DesignProblem, Constraint
from design_configurator.core.types import ConstraintType
from design_configurator.core.expressions import InequalityExpression, ExpressionValue
# Create a design problem with constraints
problem = DesignProblem(
problem_id="building_001",
constraints=[
Constraint(
id="c1",
natural_language="Height must not exceed 15 meters",
type=ConstraintType.HARD,
layer="regulation",
expression=InequalityExpression(
operator="<=",
left=ExpressionValue(type="var", value="height"),
right=ExpressionValue(type="const", value=15)
)
)
]
)
# Define variables
variables = {
"height": {
"type": "number",
"domain": {"min": 0, "max": 20},
"unit": "meters"
}
}
# Solve with SEP_Solver
adapter = SEPSolverAdapter()
result = adapter.solve_problem(problem, variables)
if result.success:
print(f"Found {len(result.solutions)} solutions")
for solution in result.solutions:
print(f" Height: {solution.variable_assignments['height']} meters")
else:
print(f"No solutions found: {result.error_message}")Web UI Integration:
The integrated workflow page provides a "Solve with SEP_Solver" button that:
- Collects problem definition from the web form
- Sends it to the
/api/solve-with-sependpoint - Displays solutions in a formatted table
- Shows solve time, iterations, and metadata
See docs/SEP_SOLVER_INTEGRATION.md for complete documentation.
For an interactive experience, use the CLI tools:
# Full-featured CLI with session management
python examples/interactive_cli.py
# Simple one-requirement-at-a-time mode
python examples/simple_interactive.pyInteractive CLI Features:
- π― Add requirements interactively
- π List and manage requirements
β οΈ Analyze conflicts in real-time- οΏ½ Decompose problems into tasks
- οΏ½πΎ Save/load sessions
- π Track usage and costs
- π Multi-language support
- π Alternative interpretations
See examples/INTERACTIVE_DEMO.md for detailed usage guide.
# Run all tests
pytest
# Run unit tests only
pytest -m unit
# Run property-based tests only
pytest -m property
# Run LLM integration tests
pytest tests/unit/llm_integration/
# Run with coverage
pytest --cov=design_configurator --cov-report=html# Quick start (all features)
python examples/llm_quickstart.py
# Japanese language test
python examples/japanese_test.py
# Interactive CLI (full-featured)
python examples/interactive_cli.py
# Simple interactive mode
python examples/simple_interactive.pySee examples/INTERACTIVE_DEMO.md for interactive usage guide.
design-configurator/
βββ src/design_configurator/
β βββ core/ # Core data models and types
β β βββ models.py # Constraint, Task, Conflict models
β β βββ types.py # Enums and type definitions
β β βββ expressions.py # Constraint expression types
β β
β βββ llm_integration/ # LLM-powered AI components
β β βββ requirement_interpreter.py # Natural language β constraints
β β βββ task_decomposer.py # Problem β tasks
β β βββ conflict_analyzer.py # Conflict detection & resolution
β β βββ openai_provider.py # OpenAI (GPT-4, GPT-3.5)
β β βββ anthropic_provider.py # Anthropic (Claude)
β β βββ local_provider.py # Local models (Ollama)
β β βββ mock_provider.py # Testing provider
β β βββ cached_provider.py # Response caching wrapper
β β βββ configuration.py # LLM configuration
β β βββ pricing.py # Cost tracking
β β βββ usage_tracker.py # Usage statistics
β β βββ validator.py # Output validation
β β βββ security.py # API key encryption
β β βββ audit_logging.py # Audit trail
β β
β βββ solvers/ # Solver integrations
β β βββ sep_adapter.py # SEP_Solver adapter
β β βββ sep_solver_client.py # SEP_Solver client
β β βββ constraint_evaluator.py # Constraint expression evaluator
β β
β βββ deterministic_engines/ # Computational validation
β β βββ geometry_engine.py # Spatial validation
β β βββ rule_checker.py # Regulatory compliance
β β βββ structural_analyzer.py # Engineering validation
β β βββ environmental_simulator.py # Performance analysis
β β
β βββ human_interface/ # Human decision gates
β β βββ approval_gates.py # Human confirmation
β β βββ decision_tracking.py # Audit trail
β β
β βββ state_management/ # Design state persistence
β βββ design_state.py # State management
β
βββ tests/
β βββ unit/ # Unit tests
β β βββ llm_integration/ # LLM component tests
β β βββ solvers/ # Solver integration tests
β β βββ core/ # Core model tests
β βββ test_properties.py # Property-based tests
β βββ conftest.py # Test fixtures
β
βββ examples/
β βββ llm_quickstart.py # Quick start demo
β βββ japanese_test.py # Multi-language demo
β βββ sep_solver_integration_example.py # SEP_Solver demo
β
βββ docs/
β βββ SEP_SOLVER_INTEGRATION.md # SEP_Solver integration guide
β βββ SEP_SOLVER_QUICK_START.md # SEP_Solver quick start
β βββ CONSTRAINT_EVALUATION_EXAMPLES.md # Constraint examples
β βββ SEP_SOLVER_TROUBLESHOOTING.md # Troubleshooting guide
β
βββ llm_config.json # LLM configuration
βββ README.md # This file
βββ README_LLM_SETUP.md # Detailed LLM setup guide
βββ requirements.txt # Python dependencies
AI outputs are never executed directly - they require validation or human approval:
# All AI outputs require human confirmation
for candidate in candidates:
assert candidate.requires_human_confirmation is TrueDeterministic engines guarantee identical results for identical inputs:
# Same input always produces same output
result1 = geometry_engine.validate(constraint)
result2 = geometry_engine.validate(constraint)
assert result1 == result2Complete audit trail from requirements to final design decisions:
# Every decision is logged
audit_logger.log_llm_request(prompt, response, cost)
audit_logger.log_human_decision(decision, justification)Human decision gates for all critical operations:
# Critical decisions require human approval
if candidate.constraint_type == ConstraintType.HARD:
approval = await human_interface.request_approval(candidate)
if not approval.approved:
continueReal-time monitoring and daily limits prevent unexpected charges:
# Automatic cost limits
config.max_cost_per_day = 10.0 # $10 daily limit
config.enable_cost_tracking = True
# Falls back to rule-based mode when limit reached
if stats.total_cost_usd >= config.max_cost_per_day:
use_llm = False| Provider | Model | Cost/Request | Quality | Speed | Best For |
|---|---|---|---|---|---|
| OpenAI | gpt-4o-mini | $0.0001-0.0007 | ββββ | β‘β‘β‘ | Recommended |
| OpenAI | gpt-4o | $0.002-0.01 | βββββ | β‘β‘ | Critical apps |
| OpenAI | gpt-3.5-turbo | $0.0001-0.0003 | βββ | β‘β‘β‘β‘ | Development |
| Anthropic | claude-3-sonnet | $0.001-0.005 | ββββ | β‘β‘β‘ | Alternative |
| Local | llama2 | $0 | ββ | β‘ | Privacy/offline |
| Mock | - | $0 | β | β‘β‘β‘β‘β‘ | Testing |
Recommendation: Start with gpt-4o-mini - best balance of quality, speed, and cost.
- Never commit API keys to version control
- Use environment variables or encrypted config
- Add
llm_config.jsonto.gitignore
- Set daily spending limits
- Enable real-time cost tracking
- Automatic fallback when limits reached
- All LLM requests logged
- Complete traceability
- Human decision tracking
- Use local models for sensitive data
- API key encryption support
- Configurable data retention
Enable caching to reduce costs by 90%+:
{
"enable_response_caching": true,
"cache_ttl_hours": 24
}- Development:
gpt-4o-miniormock - Production:
gpt-4o-mini(recommended) - Critical:
gpt-4o(only when needed)
- Set appropriate
max_tokenslimits - Use concise prompts
- Batch similar requests
"Model not found"
- Use
gpt-4o-miniinstead ofgpt-4 - Verify you have access to the model
"Insufficient quota"
- Add credits to your OpenAI account
- System automatically falls back to rule-based mode
"Authentication failed"
- Check API key in
llm_config.json - Verify key hasn't been revoked
Slow responses
- Enable caching for repeated requests
- Use faster models like
gpt-4o-mini - Reduce
max_tokens
See README_LLM_SETUP.md for detailed troubleshooting.
- README_LLM_SETUP.md - Complete LLM setup guide
- LLM_INTEGRATION_DESIGN.md - Technical design document
- .kiro/specs/llm-integration/ - Requirements and design specs
- Follow the established architecture patterns
- Maintain strict layer separation (AI / Deterministic / Human)
- Add property-based tests for new functionality
- Ensure all AI outputs require human confirmation
- Update documentation for new components
- Test with multiple LLM providers
# Install development dependencies
pip install -e ".[dev]"
# Set up pre-commit hooks
pre-commit install
# Run code quality checks
black src/ tests/
isort src/ tests/
mypy src/
flake8 src/ tests/
# Run tests
pytestThis implementation covers all requirements with comprehensive testing:
- β Requirements 1-19: Complete implementation with traceability
- β Properties 1-39: Property-based testing using Hypothesis
- β Layer Separation: Strict boundaries between AI, deterministic, and human layers
- β Safety Guarantees: AI outputs never execute without validation/approval
- β Multi-Language: Support for English, Chinese, Japanese, Spanish, and more
- β Cost Controls: Real-time monitoring and daily limits
- β Audit Trail: Complete traceability from requirements to decisions
- Core constraint satisfaction framework
- LLM integration (OpenAI, Anthropic, Local)
- Multi-language support
- Conflict detection and resolution
- Task decomposition
- Cost tracking and optimization
- Response caching
- Audit logging
- SEP_Solver integration with constraint evaluation
- Web UI for SEP_Solver integration
- Web UI for human approval gates
- Advanced visualization tools
- Integration with CAD systems
- Real-time collaboration features
MIT License - see LICENSE file for details.
Built with:
- OpenAI GPT-4 for natural language understanding
- Anthropic Claude for alternative LLM support
- Hypothesis for property-based testing
- Pydantic for data validation
Ready to get started?
- Install dependencies:
pip install -r requirements.txt - Set up LLM: See README_LLM_SETUP.md
- Run quick start:
python examples/llm_quickstart.py - Try SEP_Solver:
python examples/sep_solver_integration_example.py - Start building! π