Skip to content

Toolkit

autogen.beta.tools.final.toolkit.Toolkit #

Toolkit(*tools)

Bases: Tool

Source code in autogen/beta/tools/final/toolkit.py
def __init__(self, *tools: Tool | Callable[..., Any]) -> None:
    self.tools: list[Tool] = [FunctionTool.ensure_tool(t) for t in tools]

tools instance-attribute #

tools = [(ensure_tool(t)) for t in tools]

tool #

tool(function: Callable[..., Any], *, name: str | None = None, description: str | None = None, schema: FunctionParameters | None = None, sync_to_thread: bool = True) -> Tool
tool(function: None = None, *, name: str | None = None, description: str | None = None, schema: FunctionParameters | None = None, sync_to_thread: bool = True) -> Callable[[Callable[..., Any]], Tool]
tool(function=None, *, name=None, description=None, schema=None, sync_to_thread=True)
Source code in autogen/beta/tools/final/toolkit.py
def tool(
    self,
    function: Callable[..., Any] | None = None,
    *,
    name: str | None = None,
    description: str | None = None,
    schema: FunctionParameters | None = None,
    sync_to_thread: bool = True,
) -> Tool | Callable[[Callable[..., Any]], Tool]:
    def make_tool(f: Callable[..., Any]) -> Tool:
        t = FunctionTool.ensure_tool(
            tool(f, name=name, description=description, schema=schema, sync_to_thread=sync_to_thread)
        )
        self.tools.append(t)
        return t

    if function:
        return make_tool(function)

    return make_tool

schemas async #

schemas(context)
Source code in autogen/beta/tools/final/toolkit.py
async def schemas(self, context: "Context") -> Iterable[ToolSchema]:
    schemas: list[ToolSchema] = []
    for t in self.tools:
        schemas.extend(await t.schemas(context))
    return schemas

register #

register(stack, context, *, middleware=())
Source code in autogen/beta/tools/final/toolkit.py
def register(
    self,
    stack: "ExitStack",
    context: "Context",
    *,
    middleware: Iterable["BaseMiddleware"] = (),
) -> None:
    for t in self.tools:
        t.register(stack, context, middleware=middleware)