Skip to content

tools

Class info

Classes

Name Children Inherits
BaseToolConfig
llmling_agent.models.tools
Base configuration for agent tools.
CrewAIToolConfig
llmling_agent.models.tools
Configuration for CrewAI-based tools.
    ImportToolConfig
    llmling_agent.models.tools
    Configuration for importing tools from Python modules.
      LangChainToolConfig
      llmling_agent.models.tools
      Configuration for LangChain tools.
        ToolCallInfo
        llmling_agent.models.tools
        Information about an executed tool call.
          ToolInfo
          llmling_agent.tools.base
          Information about a registered tool.

            🛈 DocStrings

            Models for tools.

            BaseToolConfig

            Bases: BaseModel

            Base configuration for agent tools.

            Source code in src/llmling_agent/models/tools.py
            15
            16
            17
            18
            19
            20
            21
            22
            23
            24
            25
            26
            27
            28
            29
            30
            31
            32
            33
            34
            35
            36
            37
            38
            39
            40
            41
            42
            43
            44
            45
            46
            47
            48
            49
            class BaseToolConfig(BaseModel):
                """Base configuration for agent tools."""
            
                type: str = Field(init=False)
                """Type discriminator for tool configs."""
            
                name: str | None = None
                """Optional override for the tool name."""
            
                description: str | None = None
                """Optional override for the tool description."""
            
                enabled: bool = True
                """Whether this tool is initially enabled."""
            
                requires_confirmation: bool = False
                """Whether tool execution needs confirmation."""
            
                requires_capability: str | None = None
                """Optional capability needed to use the tool."""
            
                priority: int = 100
                """Execution priority (lower = higher priority)."""
            
                cache_enabled: bool = False
                """Whether to enable result caching."""
            
                metadata: dict[str, str] = Field(default_factory=dict)
                """Additional tool metadata."""
            
                model_config = ConfigDict(frozen=True, use_attribute_docstrings=True)
            
                def get_tool(self) -> ToolInfo:
                    """Convert config to ToolInfo instance."""
                    raise NotImplementedError
            

            cache_enabled class-attribute instance-attribute

            cache_enabled: bool = False
            

            Whether to enable result caching.

            description class-attribute instance-attribute

            description: str | None = None
            

            Optional override for the tool description.

            enabled class-attribute instance-attribute

            enabled: bool = True
            

            Whether this tool is initially enabled.

            metadata class-attribute instance-attribute

            metadata: dict[str, str] = Field(default_factory=dict)
            

            Additional tool metadata.

            name class-attribute instance-attribute

            name: str | None = None
            

            Optional override for the tool name.

            priority class-attribute instance-attribute

            priority: int = 100
            

            Execution priority (lower = higher priority).

            requires_capability class-attribute instance-attribute

            requires_capability: str | None = None
            

            Optional capability needed to use the tool.

            requires_confirmation class-attribute instance-attribute

            requires_confirmation: bool = False
            

            Whether tool execution needs confirmation.

            type class-attribute instance-attribute

            type: str = Field(init=False)
            

            Type discriminator for tool configs.

            get_tool

            get_tool() -> ToolInfo
            

            Convert config to ToolInfo instance.

            Source code in src/llmling_agent/models/tools.py
            47
            48
            49
            def get_tool(self) -> ToolInfo:
                """Convert config to ToolInfo instance."""
                raise NotImplementedError
            

            CrewAIToolConfig

            Bases: BaseToolConfig

            Configuration for CrewAI-based tools.

            Source code in src/llmling_agent/models/tools.py
             76
             77
             78
             79
             80
             81
             82
             83
             84
             85
             86
             87
             88
             89
             90
             91
             92
             93
             94
             95
             96
             97
             98
             99
            100
            101
            102
            103
            104
            class CrewAIToolConfig(BaseToolConfig):
                """Configuration for CrewAI-based tools."""
            
                type: Literal["crewai"] = Field("crewai", init=False)
                """CrewAI tool configuration."""
            
                import_path: ImportString
                """Import path to CrewAI tool class."""
            
                params: dict[str, Any] = Field(default_factory=dict)
                """Tool-specific parameters."""
            
                def get_tool(self) -> ToolInfo:
                    """Import and create CrewAI tool."""
                    try:
                        return ToolInfo.from_crewai_tool(
                            self.import_path(**self.params),
                            name_override=self.name,
                            description_override=self.description,
                            enabled=self.enabled,
                            requires_confirmation=self.requires_confirmation,
                            requires_capability=self.requires_capability,
                            priority=self.priority,
                            cache_enabled=self.cache_enabled,
                            metadata={"type": "crewai", **self.metadata},
                        )
                    except ImportError as e:
                        msg = "CrewAI not installed. Install with: pip install crewai-tools"
                        raise ImportError(msg) from e
            

            import_path instance-attribute

            import_path: ImportString
            

            Import path to CrewAI tool class.

            params class-attribute instance-attribute

            params: dict[str, Any] = Field(default_factory=dict)
            

            Tool-specific parameters.

            type class-attribute instance-attribute

            type: Literal['crewai'] = Field('crewai', init=False)
            

            CrewAI tool configuration.

            get_tool

            get_tool() -> ToolInfo
            

            Import and create CrewAI tool.

            Source code in src/llmling_agent/models/tools.py
             88
             89
             90
             91
             92
             93
             94
             95
             96
             97
             98
             99
            100
            101
            102
            103
            104
            def get_tool(self) -> ToolInfo:
                """Import and create CrewAI tool."""
                try:
                    return ToolInfo.from_crewai_tool(
                        self.import_path(**self.params),
                        name_override=self.name,
                        description_override=self.description,
                        enabled=self.enabled,
                        requires_confirmation=self.requires_confirmation,
                        requires_capability=self.requires_capability,
                        priority=self.priority,
                        cache_enabled=self.cache_enabled,
                        metadata={"type": "crewai", **self.metadata},
                    )
                except ImportError as e:
                    msg = "CrewAI not installed. Install with: pip install crewai-tools"
                    raise ImportError(msg) from e
            

            ImportToolConfig

            Bases: BaseToolConfig

            Configuration for importing tools from Python modules.

            Source code in src/llmling_agent/models/tools.py
            52
            53
            54
            55
            56
            57
            58
            59
            60
            61
            62
            63
            64
            65
            66
            67
            68
            69
            70
            71
            72
            73
            class ImportToolConfig(BaseToolConfig):
                """Configuration for importing tools from Python modules."""
            
                type: Literal["import"] = Field("import", init=False)
                """Import path based tool."""
            
                import_path: ImportString[Callable[..., Any]]
                """Import path to the tool function."""
            
                def get_tool(self) -> ToolInfo:
                    """Import and create tool from configuration."""
                    return ToolInfo.from_callable(
                        self.import_path,
                        name_override=self.name,
                        description_override=self.description,
                        enabled=self.enabled,
                        requires_confirmation=self.requires_confirmation,
                        requires_capability=self.requires_capability,
                        priority=self.priority,
                        cache_enabled=self.cache_enabled,
                        metadata=self.metadata,
                    )
            

            import_path instance-attribute

            import_path: ImportString[Callable[..., Any]]
            

            Import path to the tool function.

            type class-attribute instance-attribute

            type: Literal['import'] = Field('import', init=False)
            

            Import path based tool.

            get_tool

            get_tool() -> ToolInfo
            

            Import and create tool from configuration.

            Source code in src/llmling_agent/models/tools.py
            61
            62
            63
            64
            65
            66
            67
            68
            69
            70
            71
            72
            73
            def get_tool(self) -> ToolInfo:
                """Import and create tool from configuration."""
                return ToolInfo.from_callable(
                    self.import_path,
                    name_override=self.name,
                    description_override=self.description,
                    enabled=self.enabled,
                    requires_confirmation=self.requires_confirmation,
                    requires_capability=self.requires_capability,
                    priority=self.priority,
                    cache_enabled=self.cache_enabled,
                    metadata=self.metadata,
                )
            

            LangChainToolConfig

            Bases: BaseToolConfig

            Configuration for LangChain tools.

            Source code in src/llmling_agent/models/tools.py
            107
            108
            109
            110
            111
            112
            113
            114
            115
            116
            117
            118
            119
            120
            121
            122
            123
            124
            125
            126
            127
            128
            129
            130
            131
            132
            133
            134
            135
            136
            137
            class LangChainToolConfig(BaseToolConfig):
                """Configuration for LangChain tools."""
            
                type: Literal["langchain"] = Field("langchain", init=False)
                """LangChain tool configuration."""
            
                tool_name: str
                """Name of LangChain tool to use."""
            
                params: dict[str, Any] = Field(default_factory=dict)
                """Tool-specific parameters."""
            
                def get_tool(self) -> ToolInfo:
                    """Import and create LangChain tool."""
                    try:
                        from langchain.tools import load_tool
            
                        return ToolInfo.from_langchain_tool(
                            load_tool(self.tool_name, **self.params),
                            name_override=self.name,
                            description_override=self.description,
                            enabled=self.enabled,
                            requires_confirmation=self.requires_confirmation,
                            requires_capability=self.requires_capability,
                            priority=self.priority,
                            cache_enabled=self.cache_enabled,
                            metadata={"type": "langchain", **self.metadata},
                        )
                    except ImportError as e:
                        msg = "LangChain not installed. Install with: pip install langchain"
                        raise ImportError(msg) from e
            

            params class-attribute instance-attribute

            params: dict[str, Any] = Field(default_factory=dict)
            

            Tool-specific parameters.

            tool_name instance-attribute

            tool_name: str
            

            Name of LangChain tool to use.

            type class-attribute instance-attribute

            type: Literal['langchain'] = Field('langchain', init=False)
            

            LangChain tool configuration.

            get_tool

            get_tool() -> ToolInfo
            

            Import and create LangChain tool.

            Source code in src/llmling_agent/models/tools.py
            119
            120
            121
            122
            123
            124
            125
            126
            127
            128
            129
            130
            131
            132
            133
            134
            135
            136
            137
            def get_tool(self) -> ToolInfo:
                """Import and create LangChain tool."""
                try:
                    from langchain.tools import load_tool
            
                    return ToolInfo.from_langchain_tool(
                        load_tool(self.tool_name, **self.params),
                        name_override=self.name,
                        description_override=self.description,
                        enabled=self.enabled,
                        requires_confirmation=self.requires_confirmation,
                        requires_capability=self.requires_capability,
                        priority=self.priority,
                        cache_enabled=self.cache_enabled,
                        metadata={"type": "langchain", **self.metadata},
                    )
                except ImportError as e:
                    msg = "LangChain not installed. Install with: pip install langchain"
                    raise ImportError(msg) from e
            

            ToolCallInfo

            Bases: BaseModel

            Information about an executed tool call.

            Source code in src/llmling_agent/models/tools.py
            147
            148
            149
            150
            151
            152
            153
            154
            155
            156
            157
            158
            159
            160
            161
            162
            163
            164
            165
            166
            167
            168
            169
            170
            171
            172
            173
            174
            175
            176
            177
            178
            179
            180
            181
            182
            183
            class ToolCallInfo(BaseModel):
                """Information about an executed tool call."""
            
                tool_name: str
                """Name of the tool that was called."""
            
                args: dict[str, Any]
                """Arguments passed to the tool."""
            
                result: Any
                """Result returned by the tool."""
            
                agent_name: str
                """Name of the calling agent."""
            
                tool_call_id: str = Field(default_factory=lambda: str(uuid4()))
                """ID provided by the model (e.g. OpenAI function call ID)."""
            
                timestamp: datetime = Field(default_factory=datetime.now)
                """When the tool was called."""
            
                message_id: str | None = None
                """ID of the message that triggered this tool call."""
            
                context_data: Any | None = None
                """Optional context data that was passed to the agent's run() method."""
            
                error: str | None = None
                """Error message if the tool call failed."""
            
                timing: float | None = None
                """Time taken for this specific tool call in seconds."""
            
                agent_tool_name: str | None = None
                """If this tool is agent-based, the name of that agent."""
            
                model_config = ConfigDict(use_attribute_docstrings=True, extra="forbid")
            

            agent_name instance-attribute

            agent_name: str
            

            Name of the calling agent.

            agent_tool_name class-attribute instance-attribute

            agent_tool_name: str | None = None
            

            If this tool is agent-based, the name of that agent.

            args instance-attribute

            args: dict[str, Any]
            

            Arguments passed to the tool.

            context_data class-attribute instance-attribute

            context_data: Any | None = None
            

            Optional context data that was passed to the agent's run() method.

            error class-attribute instance-attribute

            error: str | None = None
            

            Error message if the tool call failed.

            message_id class-attribute instance-attribute

            message_id: str | None = None
            

            ID of the message that triggered this tool call.

            result instance-attribute

            result: Any
            

            Result returned by the tool.

            timestamp class-attribute instance-attribute

            timestamp: datetime = Field(default_factory=now)
            

            When the tool was called.

            timing class-attribute instance-attribute

            timing: float | None = None
            

            Time taken for this specific tool call in seconds.

            tool_call_id class-attribute instance-attribute

            tool_call_id: str = Field(default_factory=lambda: str(uuid4()))
            

            ID provided by the model (e.g. OpenAI function call ID).

            tool_name instance-attribute

            tool_name: str
            

            Name of the tool that was called.