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.uiUI content shown in the client when the tool matches, detailed laterlabelbutton text in the welcome menu, detailed lateroptionswelcome menu options (list,ask), detailed later
Showing UI content (ui)
A tool can show something on screen when it matches: an image, a link, a video, a
quiz, buttons, a web page. contentType and content follow the UI content types;
the content is shown in the session where the tool was triggered.
- name: show-architecture
description: The user asks how SERMAS works or wants to see its architecture
ui:
contentType: image
content:
src: https://example.org/images/architecture.png
alt: The SERMAS architecture
- name: open-documentation
description: The user wants to read the documentation
ui:
contentType: link
content:
url: https://sermas-eu.github.io
label: SERMAS documentation
The agent still answers as usual; add skipResponse: true to show the content only.
When the visitor asks for it in conversation, the content never replaces the answer: the avatar answers the question, then says one short sentence about what is now on the screen (for a link, it points at the QR code the kiosk shows). A tool just shown is not matched again unless the visitor asks for it again.
A tool that shows a link is matched only when the visitor explicitly asks for a website,
a link or the documentation; a request to explain something is answered in words. Write
a link tool's description for explicit requests only ("The user asks for the project
website or a link to it"): a broad one ("more about the project") turns questions into
links.
Welcome menu (label, options)
At the start of a session the avatar shows a menu with one button per application tool
and task. A tool's label is the button text, translated to the session language but not
rephrased; without a label, the LLM rephrases the tool's description into one,
differently at each session.
options.list: falsekeeps the tool out of the menu; it stays usable from the conversation (tasks take the same option).options.ask: truemakes it a question button: its label, as shown, is sent as the visitor's message and the avatar answers it from the application's documents. Such a tool is not offered to the chat as a tool.
- name: who-funds-it
description: Who funds the project
label: Who funds SERMAS?
options:
ask: true
- name: internal-handoff
description: The user asks to talk to a person
options:
list: false
A button can be clicked once; to choose again, the visitor asks by voice or by typing.
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