Tools#
Adding Custom Tools#
Tools are components that can be used in functions. Tools can include LLMs, databases, etc.
Create a New Tool Class#
Inherit from the
Tool
Class: Start by creating a new class that inherits from theTool
class. This will serve as the base for your custom tool.
from vss_ctx_rag.base.tool import Tool
class CustomTool(Tool):
def __init__(self, name: str):
super().__init__(name)
Implement Tool Methods#
Define Tool-Specific Methods: Implement any methods that your tool needs to perform its tasks. These methods can interact with external services or perform computations.
def say_hello(self):
print("Hello, world!")
Integrate the Tool into a Function#
Add the Tool to a Function: Use the add_tool
method to add your custom tool into a function. This allows the function to utilize the tool’s capabilities.
custom_tool = CustomTool("custom_tool")
CustomFunction("custom_function_2")
.add_tool("custom_tool", custom_tool)
.config(**config)
.done()
Now in our function setup, a tool can be retrieved by name.
tool = self.get_tool("custom_tool")
tool.say_hello()