Transform instructions and examples¶
In Alan AI, transforms include a set of guidelines, rules and examples that dictate the logic and conditions under which data should be transformed.
Note
Alan AI does not apply empty transforms to corpuses and functions and does not keep history for such transforms.
To add a transform:
In the AI agent project, under Transforms, click Add and provide a transform name.
Provide the transform data:
General instruction: in the Instruction field, enter general guidelines for the transform. For details, see General instructions.
Examples: in the Examples list, define one or more examples that the AI agent can use for AI reasoning and as samples for data formatting. You can add examples manually or use the Transforms Explorer to quickly add and adjust examples. For details, see Transforms Explorer.
[Optionally] Instructions at the example level: add instructions to examples to adjust responses for specific types of queries. For details, see Instructions at the example level.
Apply the transform to a data corpus or function.
General instructions¶
The Instruction field sets the general guidelines for how data should be transformed or formatted. Here, you specify the basic logic that the AI agent should apply when processing queries covered by the transform.
The Instruction field may contain:
Rules on how the input data should be processed
Details about the data provided in example fields and more
Assume you have the Boolean Algebra Operations
corpus:
corpus({
title: `Boolean Algebra Operations`,
urls: [`https://byjus.com/maths/boolean-algebra/`],
transforms: transforms.output,
depth: 1,
maxPages: 10,
priority: 1,
});
To make sure that the AI agent presents answers with equations and formulas formatted correctly, add the following instruction for the output
transform:
If an answer includes equations or formulas, use MathJax to display them.
By following this instruction, the AI agent will utilize the MathJax engine for proper data formatting:
Instructions at the example level¶
In addition to general transform instructions, you can provide instructions at the example level. These types of instructions indicate how the AI agent should handle particular types of queries.
Assume you have the Boolean Algebra Operations
corpus:
corpus({
title: `Boolean Algebra Operations`,
urls: [`https://byjus.com/maths/boolean-algebra/`],
transforms: transforms.output,
depth: 1,
maxPages: 10,
priority: 1,
});
When the user asks: What are the basic operations in Boolean algebra?
, you want the AI agent not only provide the list of operations, but also display a table defining symbols for these operations. To do this:
In the Debugging Chat, ask:
What are the basic operations in Boolean algebra?
In the left pane, select the
output
transform and in the top right corner, click History.To the right of the
What are the basic operations in Boolean algebra?
query, click the plus button to add it to transform examples.Edit the added example:
At the top of the Instruction field, select the data format: text. In the field below, enter instructions for the query:
In the answer: 1. Provide basic operations of Boolean Algebra. 2. Provide a table defining the symbols for all three basic operations.
At the top of the Result field, select the data format: response and save the project. Then, remove the content from the field below and at the top of the field, click the Generate result button. Alan AI will automatically generate the response using the instructions provided in the Instruction field for this query.
By following this instruction, the AI agent will provide a more detailed answer:
Keywords in instructions¶
You can use the following keywords in general instructions of transforms:
#extend
: this keyword allows you to extend existing transforms, both built-in and those added to the AI agent project. Use#extend
to inherit the rules and logic of an existing transform and customize it further, without the need to redefine the transform from scratch.#import
: this keyword lets you import functions defined in the dialog script. Use#import
when you want to reuse specific functions or logic already available in your dialog script within your transform. For details, see Query transforms.