Action Transformer API¶
The Action Transformer uses built-in API methods to make informed decisions while interacting with users. You can leverage these methods to control how the Action Transformer manages queries, processes data and generates responses.
API method name |
Description |
---|---|
|
Queries data corpuses to retrieve relevant information for the user query. |
|
Combines information from different corpuses into a unified response and prioritizes data. |
|
Applies a specified transform to modify or enhance the collected data before delivering the final output. |
|
Returns the final output from the Action Transformer after processing a query. |
Example of use¶
Assume you want to provide detailed instructions to the Action Transformer and control every step of making a decision. To achieve this:
To the dialog script, add data corpuses:
corpus({ title: `Cleveland Clinic`, urls: [`https://my.clevelandclinic.org/health/treatments/penicillin`], depth: 1, maxPages: 1 }); corpus({ title: `Health Direct`, urls: [`https://www.healthdirect.gov.au/penicillin`], depth: 1, maxPages: 1 });
Under Transforms, create the
act_execute
transform with the following instructions:#import alan.actQueryCorpus, alan.actMergeResponses, alan.actApplyTransform, alan.ActResult The [[Input]] field contains a list of corpuses to answer the query. The [[Query]] field contains the user query. 1. Analyze the user query and build a detailed plan how to answer the query. 2. Find information in corpuses using the actQueryCorpus API. 3. Prioritize information from the Health Direct corpus and merge results using the actMergeResponses API. 4. Generate a JavaScript async function answerQuestion() with no arguments that follows the plan. The function must return Promise<ActResult>. If it is not possible to generate the function, generate null with a comment explaining why it is not possible.
To the dialog script, add the
act()
function with theexecution
parameter:act({ execution: transforms.act_execute });
In the Debugging Chat, ask a question, for example:
What are side effects of penicillin?
Under Transforms, click the
act_execute
transform and in the top right corner, click History. In the top left corner of any cell of the query, click the Magnifying glass icon to zoom into the query. Make sure the Action Transformer has followed the instructions provided in theact_execute
transform.