Fallback transforms

A fallback transform can be useful when the AI agent needs more details to accurately respond to a user query. It activates a fallback mechanism to gather additional information and make sure the user receives more accurate responses.

A fallback transform can also be used to avoid responding to sensitive or biased queries, such as queries related to politics, gender or other controversial topics.

How fallback transforms work

The fallback transform workflow involves the following steps:

  1. You set up a fallback transform in the AI agent project and specify how the AI agent must handle error situations and what additional information it needs.

  2. When the AI agent encounters a query that requires clarification or a query that involves a sensitive subject, it triggers the fallback transform.

  3. The user provides the requested details that are then passed to the Action Transformer.

  4. The Action Transformer uses additional information to query appropriate corpuses or trigger intents to complete the action. In case of sensitive or biased questions, the Action Transformer avoids providing responses that may involve controversial topics.

Example of use

To set up a fallback transform:

  1. To the dialog script, add the code for the fallback transform:

    Dialog script
    corpus({
        title: `HTTP corpus`,
        urls: [
            `https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview`,
            `https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages`,
            `https://developer.mozilla.org/en-US/docs/Web/HTTP/Session`],
        depth: 1,
        maxPages: 5,
        priority: 1,
    });
    
    // Fallback transform
    act({
        fallback: transforms.act_fallback
    });
    
  2. Under Transforms, click Add.

  3. Create the act_fallback transform with the following data:

    1. In the Instruction field, provide general instructions on how to handle error situations:

      Transform instruction
      You are an expert in HTTP requests and responses.
      Provide guidance and ask necessary questions to help users with their issues.
      
      ../../../_images/fallback-transform-instruction.png
    2. In the Examples section, add an example for the I am getting an error query. At the bottom of the view, click Add Row and create a transform example:

      • At the top of the Query field, select the data format: text. In the field below, enter the user query: I am getting an error.

      • At the top of the Result field, select the data format: markdown. In the field below, add steps in natural language

        Transform example
        <thinking>
        1. The query is requesting a solution for troubleshooting issues.
        2. The input lacks specific details about the error encountered.
        3. To provide useful advice, more context about the problem is needed.
        4. I should ask the user to supply additional information about the error they are facing.
        </thinking>
        
      • At the top of the Result field, click the Generate result button to automatically generate code for the instructions specified in the <thinking></thinking> block:

        ../../../_images/fallback-transform-example.png
  4. Save the transform.

To make sure the fallback transform is triggered, in the Debugging Chat, ask broad questions about errors and troubleshooting, for example:

  • I am getting an error, what should I do?

  • What is wrong with my request?

../../../_images/fallback-transform-result.png