Skip to content

marvin.utilities.tools

Module for LLM tool utilities.

call_function_tool

Helper function for calling a function tool from a list of tools, using the arguments provided by an LLM as a JSON string. This function handles many common errors.

custom_partial

Returns a new function with partial application of the given keyword arguments. The new function has the same name and docstring as the original, and its signature excludes the provided kwargs.

output_to_string

Function outputs must be provided as strings

tool_from_function

Creates an OpenAI-compatible tool from a Python function.

If any kwargs are provided, they will be stored and provided at runtime. Provided kwargs will be removed from the tool's parameter schema.

tool_from_model

Creates an OpenAI-compatible tool from a Pydantic model class.

tool_from_type

Creates an OpenAI-compatible tool from a Python type.