Skip to main content

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

  1. Install the package from PyPI:

    pip install uml-generator
    
  2. Set up your API keys in a .env file 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:

  1. Clone the repository:

    git clone https://github.com/milind-nair/uml-generator.git
    cd uml-generator
    
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  3. Install the package in editable mode:

    pip install -e .
    
  4. Run the tests:

    python -m unittest discover -s tests
    

Configuration

  • Change the model by editing UML_AGENT_MODEL in your .env file.
  • Supported models: gemini-pro, openai/gpt-4, etc.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_uml_generator-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_uml_generator-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

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

Hashes for python_uml_generator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 224e300c7294f8216b25cd1ae5bf0e48bcc0a4af21ba8ea32e764a948d794132
MD5 8a52bc568d1bfcdff0cb68ef7b1d3c53
BLAKE2b-256 b18b7146868b738e4d72a364e9b2787bf467249a82011b645cfececfb9033e34

See more details on using hashes here.

File details

Details for the file python_uml_generator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_uml_generator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd3491288438a62a8f228aa8fb20b1484f6539a2f1ece94df257052fe24340d8
MD5 5c2d06b7f71e282a6e01466bb122610d
BLAKE2b-256 dae9e7d655a3c839c8b56097ec697dfb0971e9ff77fc9a5fc18fc026f2f44217

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page