Overview
Image-to-mermaid modules for generating mermaid syntax from chart images.
LMBasedImageToMermaid(lm_request_processor)
Bases: BaseImageToMermaid, UsesLM
LM-based implementation for converting an image into Mermaid diagram syntax.
This class leverages a language model (LM) pipeline to generate structured Mermaid syntax from image inputs and optional metadata. It uses prompt builders, LM invokers, and output parsers defined via a preset system to streamline model usage.
Inherits
BaseImageToMermaid: Base class defining the image-to-mermaid interface. UsesLM: Mixin providing shared logic for components using language models.
Attributes:
| Name | Type | Description |
|---|---|---|
lm_request_processor |
LMRequestProcessor
|
Handles prompt creation, LM invocation, and output parsing. Core component that orchestrates the image-to-mermaid pipeline. |
Initializes the LMBasedImageToMermaid instance with a language model request processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lm_request_processor
|
LMRequestProcessor
|
The processor handling prompt creation, LM invocation, and output parsing. |
required |
from_preset(preset_name='default', lm_invoker_kwargs=None, prompt_builder_kwargs=None, **kwargs)
classmethod
Constructs an LMBasedImageToMermaid instance using a named preset configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preset_name
|
str | None
|
Name of the predefined preset configuration to use. Defaults to "default". |
'default'
|
lm_invoker_kwargs
|
dict | None
|
dict | None: Additional arguments for lm invoker. |
None
|
prompt_builder_kwargs
|
dict | None
|
dict | None: Additional arguments for prompt builder. |
None
|
**kwargs
|
Any
|
Additional keyword arguments passed to the constructor. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
LMBasedImageToMermaid |
LMBasedImageToMermaid
|
An instance initialized with the preset's components. |