motleycrew.utils.image_utils
Utilities for working with images in LLM contexts.
Functions
|
Create a HumanMessage containing an image from ImageData. |
|
Create a HumanMessage containing an image from a local file. |
|
Create a HumanMessage containing an image from either a file path or ImageData. |
|
- motleycrew.utils.image_utils.image_file_to_human_message(image_path: str) HumanMessage
Create a HumanMessage containing an image from a local file.
- Parameters:
image_path – Path to the local image file
- Returns:
HumanMessage containing the image content
- motleycrew.utils.image_utils.image_data_to_human_message(image_data) HumanMessage
Create a HumanMessage containing an image from ImageData.
- Parameters:
image_data – ImageData object from gslides-api containing image bytes and metadata
- Returns:
HumanMessage containing the image content
- Raises:
ImportError – If gslides-api is not available
TypeError – If image_data is not an ImageData instance
- motleycrew.utils.image_utils.image_to_human_message(source) HumanMessage
Create a HumanMessage containing an image from either a file path or ImageData.
- Parameters:
source – Either a file path string or an ImageData object
- Returns:
HumanMessage containing the image content
- Raises:
ImportError – If gslides-api is not available when using ImageData
TypeError – If source is neither string nor ImageData
ValueError – If the string path doesn’t exist or ImageData is invalid
- motleycrew.utils.image_utils.is_this_a_chart(image, llm: BaseLanguageModel) bool