Skip to content

neurotrace.core.tools.factory

neurotrace.core.tools.factory

generic_tool_factory(func, tool_name, tool_description=None, **kwargs)

Creates a LangChain Tool with the given function and configuration.

Parameters:

Name Type Description Default
func callable

The function to be wrapped as a tool.

required
tool_name str

Name of the tool.

required
tool_description str

Description of what the tool does. If None, loads description from prompt file. Defaults to None.

None
**kwargs

Additional keyword arguments to pass to Tool constructor.

{}

Returns:

Name Type Description
Tool Tool

A configured LangChain Tool instance.

Source code in neurotrace/core/tools/factory.py
def generic_tool_factory(func: callable, tool_name: str, tool_description: str = None, **kwargs) -> Tool:
    """Creates a LangChain Tool with the given function and configuration.

    Args:
        func (callable): The function to be wrapped as a tool.
        tool_name (str): Name of the tool.
        tool_description (str, optional): Description of what the tool does.
            If None, loads description from prompt file. Defaults to None.
        **kwargs: Additional keyword arguments to pass to Tool constructor.

    Returns:
        Tool: A configured LangChain Tool instance.
    """
    return Tool(name=tool_name, func=func, description=tool_description or load_prompt(tool_name), **kwargs)