motleycrew.common.utils

Various helpers and utility functions used throughout the project.

Functions

ensure_module_is_installed(module_name[, ...])

Ensure that the given module is installed.

generate_hex_hash(data[, length])

Generate a SHA256 hex digest from the given data.

is_http_url(url)

Check if the URL is an HTTP URL.

print_passthrough(x)

A helper function useful for debugging LCEL chains.

to_str(value)

Converts a message to a string.

motleycrew.common.utils.to_str(value: str | BaseMessage | Sequence[str] | Sequence[BaseMessage]) str

Converts a message to a string.

motleycrew.common.utils.is_http_url(url)

Check if the URL is an HTTP URL.

motleycrew.common.utils.generate_hex_hash(data: str, length: int | None = None)

Generate a SHA256 hex digest from the given data.

motleycrew.common.utils.print_passthrough(x)

A helper function useful for debugging LCEL chains. It just returns the input value.

You can put a breakpoint in this function to debug a chain.

motleycrew.common.utils.ensure_module_is_installed(module_name: str, install_command: str = None) None

Ensure that the given module is installed.