A LangChain-based AI agent that converts natural language to UML diagrams (PlantUML)
Project description
UML Generator AI Agent
A Python-based AI agent that converts natural language descriptions into UML diagrams using a configurable LLM (default: Gemini Pro). The output is PlantUML code, which is rendered as an image.
Features
- Configurable LLM backend (Gemini Pro, OpenAI, etc.)
- Converts human input to PlantUML code
- Renders PlantUML code to PNG image
Installation
-
Install the package from PyPI:
pip install uml-generator
-
Set up your API keys in a
.envfile in your project directory:# Set the model to 'gemini-pro' or an OpenAI model like 'gpt-4' UML_AGENT_MODEL=gemini-pro # Add your API keys GEMINI_API_KEY=your_gemini_api_key OPENAI_API_KEY=your_openai_api_key
CLI Usage
Run the uml-generator command with your prompt.
To print the PlantUML code to the console:
uml-generator "A simple class diagram for a Dog"
To save the generated diagram to a file:
uml-generator "A simple class diagram for a Dog" -o dog_diagram.png
Library Usage
You can also use uml-generator as a library in your own Python code:
import uml_generator
# Generate PlantUML code and save the diagram to a file
prompt = "A class diagram for a simple shopping cart"
plantuml_code = uml_generator.generate(prompt, "shopping_cart.png")
print("--- Generated PlantUML Code ---")
print(plantuml_code)
# Or, generate the code without saving a file
prompt2 = "An activity diagram for making coffee"
plantuml_code_only = uml_generator.generate(prompt2)
print(plantuml_code_only)
Developer Setup
If you want to contribute to the project, follow these steps:
-
Clone the repository:
git clone https://github.com/milind-nair/uml-generator.git cd uml-generator
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the package in editable mode:
pip install -e .
-
Run the tests:
python -m unittest discover -s tests
Configuration
- Change the model by editing
UML_AGENT_MODELin your.envfile. - Supported models:
gemini-pro,openai/gpt-4, etc.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_uml_generator-0.1.1.tar.gz.
File metadata
- Download URL: python_uml_generator-0.1.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
224e300c7294f8216b25cd1ae5bf0e48bcc0a4af21ba8ea32e764a948d794132
|
|
| MD5 |
8a52bc568d1bfcdff0cb68ef7b1d3c53
|
|
| BLAKE2b-256 |
b18b7146868b738e4d72a364e9b2787bf467249a82011b645cfececfb9033e34
|
File details
Details for the file python_uml_generator-0.1.1-py3-none-any.whl.
File metadata
- Download URL: python_uml_generator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd3491288438a62a8f228aa8fb20b1484f6539a2f1ece94df257052fe24340d8
|
|
| MD5 |
5c2d06b7f71e282a6e01466bb122610d
|
|
| BLAKE2b-256 |
dae9e7d655a3c839c8b56097ec697dfb0971e9ff77fc9a5fc18fc026f2f44217
|