Data merging

By default, the Action Transformer automatically merges information from available data sources, evaluating and prioritizing which information to use to deliver a response. You can control this process more precisely using the merge parameter in the act() function.

You can use the merge parameter to:

  • Specify the priority for information from various sources

  • Instruct the AI agent on how to resolve conflicts between data from different corpuses

To modify how the AI agent merges information, add the act() function to the dialog script. In the merge parameter, define the transform that outlines the merging rules and prioritization of sources.

Dialog script
act({
    merge: transforms.act_merge
});

Example of use

Assume you are building an AI agent that provides information on medications from various sources. When a user asks about medication usage, the AI agent must combine information from multiple corpuses and prioritize a trusted medical source. To achieve this:

  1. To the dialog script, add data corpuses that provide information about medications:

    Dialog script
    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
    });
    
  2. In the Debugging Chat, ask a question about medication side effects and check the response.

    ../../../_images/act-merge-initial.png
  3. Under Transforms, create the act_merge transform with the following instructions:

    Dialog script
    Prioritize results from Health Direct
    
    ../../../_images/act-merge-transform.png
  4. To the dialog script, add the act() function with the merge parameter:

    Dialog script
    act({
        merge: transforms.act_merge
    });
    
  5. In the Debugging Chat, ask a question about medication side effects once again and check the response.

    ../../../_images/act-merge-result.png
  6. Under Transforms, select the act_merge transform. In the top right corner, click History and check the Query and Result fields to see the initial merge instructions and adjusted merge instructions applied to the user query.

    ../../../_images/act-merge-result-transforms.png

See also

Transforms