Using SmartTools
Overview
The flexibility of the tools (also known as skills) system in Wisej.AI is one of its most powerful and important features. For an introduction to the tools architecture, please refer to the SmartTools page.
In Wisej.AI, tools can take various forms, providing developers with significant flexibility. Tools can be implemented as:
Local functions
Anonymous functions (lambdas)
Asynchronous functions (async/await)
Plain Old CLR Objects (POCOs)
Objects that derive from the ToolsContainer class
Objects that implement the IToolsContainer interface
This versatility allows you to choose the most appropriate approach for your application's needs when defining and integrating tools within Wisej.AI.
There are two ways to provide a tool to the AI model in Wisej.AI:
Decorate the function using the
[SmartTool.Tool]attribute By applying the[SmartTool.Tool]attribute to a function, you allow Wisej.AI to automatically discover it as a tool when it is defined within a container class. When the container is associated with aSmartHub, all adapters linked to that hub will have access to the discovered tools.Register the function directly using the
UseTools()method You can explicitly register a tool by passing it directly to theUseTools()method. This method accepts an instance of a tools container object or individual functions.
In both cases, Wisej.AI will identify and make available all functions marked with the [SmartTool.Tool] attribute within the provided container.
Examples
The following samples provide practical demonstrations of how to define, register, and utilize tools within Wisej.AI. Each example is designed to highlight a specific aspect of the tools system
Defining the Simplest Tool: Demonstrates how to create and register a basic tool using Wisej.AI. This typically involves a straightforward function, such as a method that performs a simple calculation or returns static data, and shows how it can be exposed to the AI model for use.
Implementing an Asynchronous Tool: Shows how to define a tool that performs asynchronous operations, such as tasks that involve I/O-bound work (e.g., reading from a database or making external API calls). The example highlights how to structure asynchronous functions and register them so that the AI model can execute them correctly using async/await patterns.
Enabling the AI Model to Create and Use Its Own Tools from Scratch: Illustrates the advanced capability of Wisej.AI, where the AI model is empowered to define new tools at runtime or dynamically utilize new tool functions.
Last updated
