motleycrew.tools.html_render_tool
Functions
|
Classes
|
Tool for rendering HTML as image. |
|
Input for the HTMLRenderTool. |
|
Helper for rendering HTML code as an image. |
- class motleycrew.tools.html_render_tool.HTMLRenderer(work_dir: str, chromedriver_path: str | None = None, headless: bool = True, window_size: Tuple[int, int] | None = None)
Bases:
objectHelper for rendering HTML code as an image.
- __init__(work_dir: str, chromedriver_path: str | None = None, headless: bool = True, window_size: Tuple[int, int] | None = None)
- render_image(html: str, file_name: str | None = None)
Create a PNG image from HTML code.
- Parameters:
html (str) – HTML code for rendering image.
file_name (str) – File name without extension.
- Returns:
Path to the rendered image.
- build_file_paths(file_name: str | None = None) Tuple[str, str]
Builds paths to html and image files
- class motleycrew.tools.html_render_tool.HTMLRenderTool(work_dir: str, chromedriver_path: str | None = None, headless: bool = True, window_size: Tuple[int, int] | None = None, return_direct: bool = False, exceptions_to_reflect: List[Exception] | None = None)
Bases:
MotleyToolTool for rendering HTML as image.
- __init__(work_dir: str, chromedriver_path: str | None = None, headless: bool = True, window_size: Tuple[int, int] | None = None, return_direct: bool = False, exceptions_to_reflect: List[Exception] | None = None)
- Parameters:
work_dir – Directory for saving images and HTML files.
chromedriver_path – Path to the ChromeDriver executable.
- class motleycrew.tools.html_render_tool.HTMLRenderToolInput(*, html: str)
Bases:
BaseModelInput for the HTMLRenderTool.
- html: str
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'html': FieldInfo(annotation=str, required=True, description='HTML code for rendering')}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- motleycrew.tools.html_render_tool.create_render_tool(renderer: HTMLRenderer)