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.0.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.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file python_uml_generator-0.1.0.tar.gz.

File metadata

  • Download URL: python_uml_generator-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 6e72b1ba790b7fe95905bed6c5ba4650e5f962867ff5ad96ac321a3969d6acee
MD5 7ad52ea0b9ab51c08c2409b583e48e5d
BLAKE2b-256 2b467d4c52f11df576f0d85e852b7115caa6ff874bd4c81b33a318fb304f8df3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_uml_generator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a963fdc26db97b26e8819b15e8ea337b60725f0732d03643d51f85498ceca9bb
MD5 da73f99ce65596ad695955096864563a
BLAKE2b-256 6b68e68c55258d7d6f2dd9d01d9fadd481a63850371edc7c83cfaed0867cbd86

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