An intelligent RAG-powered agent that generates complete engineering solutions using ANSA Python API with mathematical reasoning and problem-solving capabilities.
This system combines:
- Mathematical Analysis: Break down engineering problems into mathematical components
- ANSA API Intelligence: Retrieve and apply appropriate ANSA Python functions
- Complete Solution Generation: Create executable Python scripts for complex engineering tasks
- Quality-Driven Approach: Incorporate engineering best practices and validation
The system transforms from simple code generation to comprehensive engineering problem solving with mathematical rigor and ANSA API expertise.
- Analyzes engineering requirements mathematically
- Calculates optimal parameters (mesh sizing, element counts, etc.)
- Applies geometric and numerical methods
- Considers constraints and optimization criteria
- Function-Specific Search: Find exact ANSA API functions needed
- Module-Based Organization: Search within specific ANSA modules (base, mesh, morph, etc.)
- Example-Driven Learning: Retrieve complete usage examples
- Workflow Generation: Create multi-step engineering processes
- Mesh Generation: Structured/unstructured meshing with quality criteria
- Geometry Processing: CAD manipulation and transformation
- Material & Properties: Assignment and validation
- Boundary Conditions: Setup and optimization
- Morphing & Optimization: Shape optimization workflows
- Analysis Setup: Complete preprocessing pipelines
- Post-Processing: Results analysis and validation
- Metadata-Aware: Tracks source file, chunk index, and content type for traceability.
src/
├── app.py # Streamlit Web Interface
├── ansa_rag/ # Main Package
│ ├── __init__.py
│ ├── chroma_db.py # ChromaDB handler for insertion and retrieval
│ ├── cli.py # CLI Entry points
│ └── database/ # Database Operations
│ ├── __init__.py
│ ├── db_insert.py # Document processing and insertion
│ └── query_db.py # Interactive querying utilities
├── chroma_db/ # Vector database storage
├── pyproject.toml # Package configuration
├── requirements.txt # Python dependencies
├── .env # Environment variables
└── README.md # This file
- Clone the repository
git clone <repository-url>
cd ANSA_Docs_RAG- Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install the package
pip install -e .- Configure environment variables
Create a
.envfile:
# Database
DB_NAME=ansa_docs_collection
EMBEDDING_MODEL=sentence-transformers/all-mpnet-base-v2
# API Keys (optional)
ANTHROPIC_API_KEY=your_key_here
OLLAMA_BASE_URL=http://localhost:11434The package provides three CLI commands after installation:
ansa-rag- Opens Streamlit web interface at
http://localhost:8501 - Interactive chat interface for engineering problems
- Support for multiple LLM backends (Ollama, Claude)
- Real-time documentation retrieval and code generation
ansa-db-insert- Processes ANSA documentation from
ansa_docs_html/ - Extracts and indexes API functions, code examples, and documentation
- Creates vector embeddings for semantic search
- One-time setup (run when adding new documentation)
ansa-query- Command-line interface for database queries
- Test documentation retrieval capabilities
- Debug search functionality
- Useful for development and testing
Ollama (Local)
- Install Ollama:
curl -fsSL https://ollama.com/install.sh | sh - Pull models:
ollama pull qwen2.5-coder - Start service:
ollama serve
Claude (Cloud)
- Set
ANTHROPIC_API_KEYin.env - Requires API credits from Anthropic
Supported embedding models (configure in .env):
sentence-transformers/all-mpnet-base-v2(default)BAAI/bge-large-en-v1.5intfloat/e5-large-v2nomic-ai/nomic-embed-text-v1.5
- Launch:
ansa-rag - Select LLM model (Ollama/Claude)
- Choose engineering domain and complexity
- Ask questions like:
- "Create a hex mesh for a cylindrical geometry with quality criteria"
- "Set up contact interfaces with friction coefficients"
- "Generate morphing controls for shape optimization"
# Populate database with documentation
ansa-db-insert
# Query specific topics
ansa-query
# Enter search terms like: "mesh generation quality"- Modular design with clear separation of concerns
- CLI entry points for easy access to functionality
- Configurable backends for different LLM providers
- Extensible architecture for adding new features
- Extend
src/ansa_rag/modules - Update CLI commands in
src/ansa_rag/cli.py - Add new dependencies to
pyproject.toml - Test with
pip install -e .
- Python 3.9+
- ChromaDB for vector storage
- Streamlit for web interface
- LangChain for LLM integration
- Sentence Transformers for embeddings
- Optional: Ollama (local) or Anthropic API (cloud)
- Fork the repository
- Create feature branch:
git checkout -b feature/new-feature - Make changes and test thoroughly
- Submit pull request with detailed description
This project is licensed under the MIT License - see the LICENSE file for details.