Static corpus transforms

You can transform AI assistant’s responses from the corpus() function to meet your requirements.

Assume you have information on a webpage and want Alan AI to use it to answer questions. The AI assistant’s responses should be formatted in a specified manner.

For this, you can do the following:

  1. To the dialog script in Alan AI Studio, add the corpus() function, specify the data source and the name of the transform that will be used to format the answer. In this example, we will use a transform named events.

    Dialog script
    corpus({
        urls: [
            `https://developer.mozilla.org/en-US/docs/Web/HTTP/Status`,
       ],
       transforms: transforms.events
    });
    
  2. Under Transforms, create a transform named events. Leave it empty for now.

  3. Use the Debugging Chat to ask questions you want to be transformed, for example: What does code 304 mean?

  4. In the code editor, to the left of the transforms function, click the magnifying glass icon. This will open the Transforms Explorer.

    ../../../_images/transforms-corpus.png
  5. The Transforms Explorer displays the results of data transformation. To the right of an example, click the plus icon to add the result to the events transform.

    ../../../_images/transforms-corpus-adding.png
  6. Under Transforms, select events. The added transform result can be found under Examples. In the Result field, edit the Full Answer and Links sections to format the corpus() output as needed.

    ../../../_images/transforms-corpus-result.png

Now, you can ask questions about the status codes and see how the set formatting rules are applied to the corpus() output:

../../../_images/transforms-corpus-testing.png