-
Notifications
You must be signed in to change notification settings - Fork 3
Functions_and_Collections
Frags allows you to provide your LLM of choice with functions and collections of functions. Contrary to MCP, functions and collections must be built in a program using Frags. Functions are provided to the plan runner at instantiation time, but this is not enough for the LLM to use them. Each session requires explicit and selective enablement. This makes sure that the LLM does not have access to functions that are not meant to be used for each specific session.
The CLI obviously has a limited set of functions and collections and cannot be extended by the user, so we will focus
on activating them.
First off, we first need to enable the collection at the runner level. Again, functions can be sensitive, so as a
default, everything is disabled.
Create a file called tools.json in the root directory of frags like this:
{
"collections": {
"fs": {
"disabled": true
},
"pg1": {
"tool_type": "postgres",
"params": {
"postgres_url": "postgresql://dbmcp:dbmcp@host.docker.internal:5432/dbmcp"
},
"disabled": false
}
}
}In this example, we declared both the fs (disabled) and postgres collections. The postgres collection requires a
postgres_url parameter.
Next we need to enable the collection for a specific session, and use it.
sessions:
db1:
prePrompt: Select 3 rows from the users table in the database
prompt: present the results as a Markdown list
tools:
- name: pg1
type: collectionIn this example we're enabling the postgres collection for the db1 session, and activating it in the prompt.
If, instead of a whole collection, we're enabling a spare function just, put the name of the function in name and
set the type to function.
If you want to enable a collection but want to limit the functions that can be invoked, the allowlist parameter can
be used, as in:
tools:
- name: pg1
type: collection
allowlist:
- postgres_queryFS and Postgres are the only two collections currently available.
TIP: you can see the full list of enabled functions at bootstrap, in the logs messages, or issuing the config
command.
Functions are actually managed by the AI implementation. You are required to implement and put together the
Functions object and give it to the AI.
Each function contains the definition of the function (name, input etc.), and the implementation. Please make sure to
to also indicate a Colleciton in case the function belongs to one.
Once you're set, you can assign the functions to the AI implementation of choice with:
ai.SetFunctions(functions)For what concerns the session enablement, simply add the Tools array to the session as seen in the YAML example, you
know the drill.