Metadata-Version: 2.2
Name: cicada-agent
Version: 0.6.0
Summary: A Python package for the Cicada project
Home-page: https://github.com/Oaklight/cicada
Author: Oaklight
Author-email: Oaklight <oaklight@gmx.com>
License: MIT License
        
        Copyright (c) 2024 Peng Ding
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/Oaklight/cicada
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests==2.32.3
Requires-Dist: pyyaml==6.0.2
Requires-Dist: tenacity==9.0.0
Requires-Dist: cascadio==0.0.14
Requires-Dist: gmsh==4.13.1
Requires-Dist: plyfile==1.1
Requires-Dist: trimesh==4.5.1
Requires-Dist: pyglet<2
Requires-Dist: pyrender==0.1.45
Requires-Dist: openai==1.55.3
Requires-Dist: build123d==0.8.0
Requires-Dist: flake8==7.1.1
Requires-Dist: psycopg2-binary==2.9.10
Requires-Dist: sqlalchemy==2.0.36
Requires-Dist: pgvector==0.3.6
Requires-Dist: sqlite-vec==0.1.6
Requires-Dist: questionary==2.1.0
Requires-Dist: blessed==1.20.0
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# CICADA: Collaborative Intelligent CAD Automation Design Agent

[中文](./README_zh.md) | [English](./README_en.md)

Welcome to **CICADA**, the Collaborative Intelligent CAD Automation Design Agent. CICADA is a cutting-edge framework designed to streamline and enhance the CAD design process through intelligent automation and collaboration. This repository contains the core modules and utilities that power CICADA, enabling seamless integration with CAD workflows.

📖 **Documentation**: For detailed documentation and tutorials, visit [CICADA Documentation](https://cicada.lab.oaklight.cn).

---

## Repository Structure

The repository is organized into the following main modules:

- **common**: Core utilities and shared functionalities across the framework.
- **geometry_pipeline**: Tools for processing and converting 3D models, including point cloud generation and snapshots.
- **describe**: Components for generating and managing descriptive metadata for 3D models.
- **coding**: Code generation, execution, and debugging tools for CAD automation.
- **feedbacks**: Modules for analyzing and providing feedback on design iterations.
- **retrieval**: Tools for retrieving and management of documentation, model data, and design resources.
- **workflow**: Orchestration of CICADA's automation workflows and agent management.

---

## Setting Up the Environment

### Prerequisites

Before setting up CICADA, ensure you have the following installed:

- **Python 3.9+**
- **Conda** or **pip** (for dependency management)

### Installation Steps (Quick Start)

```bash
# activate your venv or conda env first
pip install cicada-agent
```

### Installation Steps (For Developers)

#### 1. Clone the Repository

```bash
git clone https://github.com/Oaklight/cicada.git
cd cicada
```

#### 2. Install Dependencies

**Option 1: Using Conda (Recommended)**

```bash
conda env create -f environment.yml
conda activate cicada
```

**Option 2: Using pip**

```bash
python -m venv cicada
source cicada/bin/activate
pip install -r requirements.txt
```

#### 3. Update API Keys

The provided API keys in the config files are deprecated. Update the `api_key` and `api_base_url` in `config.yaml` or `config/*.yaml` in each module:

---

## Key Modules and Usage

### `geometry_pipeline`

- **`convert.py`**: Converts 3D models (STEP, OBJ, STL) to point cloud data (PLY) or other formats.

  ```bash
  python geometry_pipeline/convert.py --step_file <path_to_step_file> --convert_step2obj
  ```

  **Options**:  
  `--convert_step2obj`, `--convert_obj2pc`, `--convert_step2stl`, `--convert_obj2stl`, `--convert_stl2obj`, `--convert_stl2pc`, `--reaxis_gravity`

- **`snapshots.py`**: Generates preview snapshots of 3D models from multiple angles.
  ```bash
  python geometry_pipeline/snapshots.py --step_file <path_to_step_file> --snapshots
  ```
  **Options**:  
  `--obj_file`, `--step_file`, `--stl_file`, `-o OUTPUT_DIR`, `-r RESOLUTION`, `-d DIRECTION`, `-p`, `--reaxis_gravity`

### `describe`

- **`describer_v2.py`**: Generates descriptive metadata for 3D models using advanced language models.
  ```bash
  python describe/describer_v2.py "Describe the 3D model" --config <path_to_config> --prompts <path_to_prompts>
  ```
  **Options**:  
  `--config CONFIG`, `--prompts PROMPTS`, `-img REF_IMAGES`, `-o OUTPUT`

### `coding`

- **`coder.py`**: Generates CAD scripts based on design goals.
  ```bash
  python coding/coder.py "Design a mechanical part" --config <path_to_config> --prompts <path_to_prompts>
  ```
  **Options**:  
  `--config CONFIG`, `--master_config_path MASTER_CONFIG_PATH`, `--prompts PROMPTS`, `-o OUTPUT_DIR`

### `feedbacks`

- **`visual_feedback.py`**: Analyzes rendered images of a design against the design goal.
  ```bash
  python feedbacks/visual_feedback.py --design_goal "Design a mechanical part" --rendered_images <path_to_images>
  ```
  **Options**:  
  `--config CONFIG`, `--prompts PROMPTS`, `--reference_images REFERENCE_IMAGES`, `--rendered_images RENDERED_IMAGES`

### `retrieval`

- **`tools/build123d_retriever.py`**: Retrieves and manages documentation for CAD tools and libraries.

  ```bash
  python retrieval/tools/build123d_retriever.py [--force-rebuild] [--interactive] [--metric {l2,cosine}] [--query QUERY] [--debug]
  ```

  **Options**:  
  `--force-rebuild`: Force rebuild the database.  
  `--interactive`: Run in interactive mode to ask multiple questions.  
  `--metric {l2,cosine}`: Distance metric to use for similarity search.  
  `--query QUERY`: Query text to search in the database.  
  `--debug`: Enable debug mode for detailed logging.

  **Examples**:  
  Interactive mode:

  ```bash
  python retrieval/tools/build123d_retriever.py --interactive
  ```

  Single query:

  ```bash
  python retrieval/tools/build123d_retriever.py --query "How to extrude a shape?"
  ```

### `workflow`

- **`codecad_agent.py`**: Orchestrates the automation workflows for CAD design.

  ```bash
  python workflow/codecad_agent.py "Design a mechanical part" --config <path_to_config> --prompts <path_to_prompts>
  ```

  **Options**:  
  `--config CONFIG`: Path to the configuration file.  
  `--prompts PROMPTS`: Path to the prompts file.  
  `-img REF_IMAGES`: Path to reference images (optional).  
  `-o OUTPUT_DIR`: Directory to save output files (optional).

  **Example**:

  ```bash
  python workflow/codecad_agent.py "Design a mechanical part" --config workflow/config/code-llm.yaml --prompts workflow/prompts/code-llm.yaml -o output/
  ```

---

## Contributing

We welcome contributions from the community! If you'd like to contribute to CICADA, please follow these steps:

1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Submit a pull request with a detailed description of your changes.

---

## License

CICADA is licensed under the **MIT License**. For more details, see the [LICENSE](./LICENSE) file.

---

## Contact

For questions, feedback, or support, please post via [GitHub Issues](https://github.com/Oaklight/cicada/issues) or contact us at **[dingpeng]@@uchicago[dot]edu**.

---

**CICADA** — Revolutionizing CAD Design with Intelligent Automation. 🚀
