Module python

Source
Expand description

Python parser for tool definitions from function docstrings.

This parser extracts a ToolDefinition from a Python function named run. It expects a specific format for the docstring, including sections for arguments, environment variables, and metadata.

The docstring should be formatted as follows:

def run(param1: str, param2: bool = False):
    """
    A multiline description of what the tool does.

    Args:
        param1: The description for the first parameter.
        param2: The description for the second parameter.

    Envs:
        API_KEY: A required API key.
        ENDPOINT: The API endpoint to use. (optional)

    Meta:
        require-tools: tool1 tool2
    """
    pass

Functions§

parse
Parses a Python source file and extracts a ToolDefinition from the run function’s docstring.