You can define dynamic data corpuses for your Agentic Interface.
Dynamic data corpuses allow you to retrieve semi-structured data (JSON) from different data sources, process it using transforms and utilize the retrieved data to answer user queries in natural language. Dynamic data corpuses can be connected with various external systems, such as corporate platforms, databases, API services and other specialized data sources, to provide users with accurate, timely and contextually relevant information.
Corpus parameters
To define a dynamic corpus, use the corpus() function:
corpus({
title: `Infrastructure requests`,
description: `Corpus to answer user queries about infrastructure objects`,
input: project.objects,
query: transforms.vms_queries,
output: project.cleanObjects,
transforms: transforms.vms_answer,
priority: 1
});| Name | Type | Required/Optional | Description |
|---|---|---|---|
title | string | Optional | Corpus title. |
description | string | Optional | Corpus description. |
input | function | Optional | Function used to populate the Input field of the query transform. |
query | function | Required | Transforms function used to process user queries and generate code to retrieve necessary data. |
output | function | Optional | Function used to process obtained data, before it is passed to the transforms function. |
transforms | function | Optional | Transforms function used to process and format data obtained with the query transform. |
priority | integer | Optional | Priority level assigned to the corpus. Corpuses with higher priority are considered more relevant when user requests are processed. |
How the dynamic corpus works
The implementation of a dynamic corpus can vary depending on the specific business use case and scenario. Typically, the data flows through the following stages:
- The user makes a request to the dynamic corpus.
- Alan AI retrieves JSON data from an external system and applies the
queryfunction to it to handle the user's request and generate the code needed to retrieve the relevant information. - [Optional] Alan AI may perform additional processing on the data using the
outputfunction. - The data is passed to the
transformsfunction. Alan AI applies thetransformsfunction instructions to process and format the output for the user. - The response data is presented to the user.
Example of use
Assume you have a JSON object that lists virtual machines (VMs) in a cloud environment. You want to use this data as a dynamic source so users can ask questions about the VMs, and the Agentic Interface can provide a formatted response in natural language.
To do this, perform the following steps:
- Retrieve VM data: add a function that retrieves the VM data from the data source.
- Add a query transform: instruct the Agentic Interface on how to generate code that will get the necessary data to answer user queries.
- Add a data formatting transform: instruct the Agentic Interface on how to format the output of the corpus data.
- Add a dynamic corpus: define a dynamic corpus.
- [Advanced] Clean up the input data: process the input data before it is passed to the formatting transform.
Note:
Each function used in transforms must have an explanation formatted as a JSDoc comment preceding the function code.