def tools()

in aibond/aibond/core.py [0:0]


    def tools(obj, tools, agents):
        agent_tools = []

        for tool in tools:
            if tool in obj._tools:
                agent_tools.append(obj._tools[tool])
            elif inspect.isclass(tool):
                class_tool = obj._make_class_tool_function(obj, tool)
                a = create_schema_from_function(f"{class_tool.__name__}Schema", class_tool)
                agent_tools.append(StructuredTool.from_function(class_tool))
            elif callable(tool):
                agent_tools.append(StructuredTool.from_function(tool))
            else:
                class_funcs = [attr_name for attr_name in dir(tool) if not attr_name.startswith('_') and callable(getattr(tool, attr_name)) and getattr(tool, attr_name).__doc__]
                if len(class_funcs) > 0:
                    for fn in class_funcs:
                        agent_tools.append(StructuredTool.from_function(getattr(tool, fn)))
                else:
                    raise Exception("Tool " + tool + " not found")

        for ag in agents:
            if ag not in obj._tools:
                raise Exception("Agent " + ag + " not found")
            agent_tools.append(obj._tools[ag])

        return agent_tools