content_image_file

content_image_file(path, content_type='auto', resize='low')

Encode image content from a file for chat input.

This function is used to prepare image files for input to the chatbot. It can handle various image formats and provides options for resizing.

Parameters

Name Type Description Default
path str The path to the image file to include in the chat input. required
content_type Literal['auto', ImageContentTypes] The content type of the image (e.g., "image/png"). If "auto", the content type is inferred from the file extension. 'auto'
resize Union[str, Literal['none', 'low', 'high']] Resizing option for the image. Can be: - "none": No resizing - "low": Resize to fit within 512x512 - "high": Resize to fit within 2000x768 or 768x2000 - Custom string (e.g., "200x200", "300x200>!", etc.) 'low'

Returns

Name Type Description
[](~chatlas.types.Content) Content suitable for a Turn object.

Examples

from chatlas import ChatOpenAI, content_image_file

chat = ChatOpenAI()
chat.chat(
    "What do you see in this image?",
    content_image_file("path/to/image.png"),
)

Raises

Name Type Description
FileNotFoundError If the specified file does not exist.
ValueError If the file extension is unsupported or the resize option is invalid.