ToolsContainer

Overview

A tool container is essentially a class that houses the methods representing the tools (referred to as plugins in Semantic Kernel). This class does not need to extend any other class; it can simply be a Plain Old CLR Object (POCO) or extend any other class within an application.

However, if your tools class extends the Wisej.AI.Tools.ToolsContainer class, it gains additional integration and context when used by an adapter. If you need to extend a pre-existing class in your code and still require this additional contextual integration, you can implement the IToolsContainer interface instead of inheriting from ToolsContainer.

Inheriting from ToolsContainer provides the following additional features to your code:

  • Automatic service injection

  • Reference to the current Hub

  • Reference to the Adapter utilizing the tools

  • Parameters collection to replace the placeholders in the tools' prompts

The Parameters collection is a particularly interesting feature, as it allows the tool to set the values of placeholders in its own prompts. This enables more dynamic tool implementations.

Parameters

Below is the description of the DatabaseTools. You will notice two placeholders that remain unresolved until the class instance is created and initialized. If the description were merely fixed text in a [Description] attribute, it would offer limited flexibility.

#
# DatabaseTools
#
[DatabaseTools]
Provides tools to access the database.
Unless instructed otherwise, use it before the web search tools.

Instructions:
- Use only the tables defined in the Database Schema.
- The generated SQL statement MUST be valid for "{{server-type}}".
- Define column aliases within single quotes.
- Enclose column names in [].

```Database Schema
{{database-schema}}
```

When inheriting from the ToolsContainer or implementing IToolsContainer, you have the flexibility to set parameters at any time before sending a request to the AI. You can do this as follows:

this.Parameters.Add("server-type", serverType);
this.Parameters.Add("database-schema", schema);

It can also replace parameters that are not directly related to the tool, as well as parameters used in the tool's description and all the arguments of the methods within the tools container.

Last updated