Introduction
LLM Tools in SERMAS are used to trigger specific actions from user requests.
As an example we have tool called request for appointment.
If the user ask I want an appointment the tool will trigger, creating an internal tool-related event that can be used by other connect systems.
Considering a third-party service connected to the Toolkit API, receiving such event would trigger an agent response offering a list of calendar availability.
Tools repositories
Tools are grouped by repositories, an aggregation that allow to apply logical operations to control availability of certain tools during an interaction.
A repository is composed of the following fields
-
appIdstring reference to the application -
sessionIdstring Track the interaction session, if available -
repositoryIdstring Unique tools repository ID -
optionsTool repository options dictionary, with the following propertiestriggerOnceboolean Trigger one of the tools in the list once, then remove the tools. Useful to offer a list of options and have on selcted.exclusiveboolean Alter the normal chat flow, assuming one of the available tools will provide an answer.
-
toolsTools list
Tools granularity
Tools can be enabled at application level or at session level.
- Application level tools can trigger anytime during the interaction.
- Session level tools can be created, updated or removed during a session, creating more flexibility during the user interaction.
Tool configuration
Following the SERMAS CLI structure to configure an application, create a tools.yaml file to create your tools.
Note Refer to the OpenAPI model (local link) or source code for the full model definition.
- name: request-for-appointment
description: User need an appointment
returnDirect: true
skipResponse: true
The field for a tool are as follow
nametool name, used as reference when the tool triggerdescriptionadditional context used to better match the tool from user messageschemaa list of parameters to extract from the user context. Described in detail later.requestconfigure an HTTP request when a tool trigger, detailed laterurlAPI url to call on tool match, defaults to unauthenticated POST if norequestconfiguration are provided.emitteremit an event on the broker, in the formresource.scope.
Tools Parameters (schema)
The schema field provides a list of parameters to infer from the user messages. Tools are inferred from the chat history, thus can collect different contextual information from the context.
Note Parameters collected from the chat history are subject to allucinations and should not be used without proper validation.
parametername of the parametertypedata type of the parameter, possible options arestring,number,booleanandobject(as key-value dictionary)descriptiondescription of the parameter (currently not used for inference)ignoreindicate if the parameter should be ignored from inference. This is to be used in conjuction withvalueto provide precalculated valuevalueA static value for this parameter. This is useful to popoulate values that are available when creating a session tool.
Request configuration
To trigger an HTTP request when a tool matches, the url and request field should be configured.
url is an http endpoint to call. By default a POST request with the tool triggering details will be sent.
request can provide those details
-
descriptionProvide details to trigger an HTTP API call on tool match -
authSupported options arebasic,bearerandmodule. Defaults to module if not specified. -
basican object withusernameandpasswordfields -
bearerand object with the following fieldsclientTypeSupported options are "client_credentials" or "password".clientIdClient ID. Required for client type "client_credentials"clientSecretClient secret. Required for client type "client_credentials"usernameRequired for client type "password"passwordRequired for client type "password"audiencetoken audiencetokenUrlURL to call to retrieve the access tokenrefreshUrlURL to call to refresh the token before expiration
-
moduleIdReference to one of the modules (or clients) ids available in the app -
headersa key-value dictionary with additional headers
Tool matching event
When a tool trigger, an event is generated with the following payload
appIdID of the applicationsessionIdID of the sessionrepositoryIdID of the repositorysourceone of message, ui, task, agentnamename of the toolschemaschema of the toolvaluesvalues extracted from the schema and inferred by the LLM