Image to B-UML

besser.utilities.image_to_buml._describe_domain_model(dm: DomainModel) str[source]

Compact textual summary of a DomainModel for use in LLM prompts.

besser.utilities.image_to_buml.image_to_buml(image_path: str, openai_token: str, existing_model: DomainModel = None, openai_model: str = 'gpt-4o')[source]

Transforms an image into a B-UML model.

Parameters:
  • image_path (str) – the path of the image to transform.

  • openai_token (str) – the OpenAI token.

  • existing_model (DomainModel, optional) – an existing B-UML model to extend with the classes and relationships shown in the image. Same-name classes are merged; new ones are added. When omitted, behaves like before and returns a fresh model from the image alone.

  • openai_model (str, optional) – the OpenAI model. Defaults to “gpt-4o”.

Returns:

the B-UML model object.

Return type:

domain (DomainModel)

besser.utilities.image_to_buml.image_to_plantuml(image_path: str, openai_token: str, existing_model: DomainModel = None, openai_model: str = 'gpt-4o')[source]

Transforms an image into a PlantUML model.

Parameters:
  • image_path (str) – the path of the image to transform.

  • openai_token (str) – the OpenAI token.

  • existing_model (DomainModel, optional) – an existing B-UML model to extend. When provided, the LLM is instructed to produce a single merged PlantUML diagram that preserves the existing classes/associations and adds what the image introduces. Classes matched by name are kept; only new attributes/methods/relationships are appended.

  • openai_model (str, optional) – the OpenAI model. Defaults to “gpt-4o”.

Returns:

the PlantUML code.

Return type:

plant_uml_chunk (str)