Calling a subordinate bot

Work Description

Suppose, within the task of setting up a sales bot, you have the following initial data:

  • The company sells windows.

  • The company has 5 price tables from different suppliers.

  • Two CRM requests need to be called: for order placement and order status.

  • The instruction has lengthy descriptions over 3 A4 pages.

  • The knowledge base contains at least 50 files.

In such a situation, we get quite a large volume of context, as we have extensive instructions with their own conditions + 5 described functions for tables + 2 described functions for web-hook calls and a knowledge base processing function. With such a volume, a model is 100% likely to forget important points in instructions, or have issues working with tables and web-hooks, sometimes making insignificant, and sometimes significant, errors. Due to errors, all the "magic" of working with the model will be lost.

Problems of attention loss can be resolved in this situation by the following solution:

  1. A separate bot is created for working with tables, in which these tables exist. The main bot will not have tables.

  2. A separate bot is also created for working with web-hooks.

  3. For some blocks, specific bots are also created.

  4. In instances when specific bots need to be called, they are invoked by writing standard function calls (more in the article on functions).

Thus, instead of 8 large functions for the main bot, we get only 3 concise ones (or slightly more if we decide to allocate pieces of the instruction into separate blocks).

This will immediately increase the model's accuracy with 100% probability, and also reduce costs. Before optimization, we would transmit a large volume of functions with each request. After optimization, separate pieces are called only at specific moments.

Creating a Subordinate Bot

Initially, we need to create a standard bot:

Remove the standard instruction for the subordinate bot, as greeting elements, tonality, general information, etc., may not have functional significance, and it should focus only on performing a specific task. Based on the example above, describe its personal instruction:

  1. Set Wait time in seconds to 0 since we don't need delays here.

  2. Inside the instruction, describe the essence of the specific task as concisely as possible, which the bot should perform. You can even add that it is a technical bot, and its task is to return a response in a specific format, for example, in JSON.

In this case, we described the bot’s task as calculating the cost in tables.

Next, let’s understand how the main bot will call the subordinate, described further below.

Adding a Subordinate Bot to the Main Bot

In the main bot, you need to add the subordinate bot through the Actions section:

Action name - simply the name for display in the list.

Function name - the name of the function that the LLM model will see. This name is specified in English without spaces. The name should reflect the general essence of the action.

Function description - a more detailed description of the essence of the action. Based on this description, Suvvy will understand when it needs to be called.

Error message - a message that Suvvy will receive from the action if an error occurs on the webhook side. It can be empty, in which case Suvvy will receive the error text from the URL to which the webhook is sent.

Adding a Step

Within Actions, you can call a sequence of actions using different types of calls; therefore, it's called steps.

Upon adding a step, you can choose from three options: webhook call, subordinate bot call, or table call. We discussed the first option in the previous chapter; in this case, we are interested in Call of a subordinate bot:

When filling in the step form, your task is only to choose the subordinate bot:

Call of a Subordinate Bot

Overall, having filled in the description and names of the action, this is enough for the bot to be automatically called from the main bot. But just in case, to level potential non-obvious instances for the main bot, we can explicitly state in the instruction the moment when we need to call the subordinate bot, referring to it by the function name specified in the Action:

Analysis of Subordinate Bot Calls

When implementing Suvvy, the longest process is debugging and tweaking instructions. Detailed work with debugging was discussed in a separate section. Debugging of subordinate bots operates on a similar principle, and we will consider two methods: through chat and via an export file.

Analysis through Chat

In the response, which was expectedly formed by the subordinate bot, click the button with the i icon and examine the opened modal window:

Here we see:

  • function - the name of the function that was called

  • arguments - the parameters that were passed to the function

  • response - response from the function - in this case from the subordinate bot

The response received from the subordinate bot is modified by the main bot - this is normal and correct.

Analysis through Export File

  1. Find the needed dialogue with the main bot through the History tab and export the file through Actions -> Export:

The file is saved into the Downloads folder; open it as a regular file:

In the export file, function calls are displayed in a more convenient form.

By clicking the i button, you can get information about the function response results:

And if the function represents a call to a subordinate bot, we will see an icon of a robot head next to the i icon. Clicking on it will open a separate modal window with a dedicated export specifically for this bot:

Further analysis proceeds similarly; if it called anything, or any functions inside itself, we will see it in the form of service labels (which are absent in the screenshot above).

Last updated