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:
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 namedevents
.corpus({ urls: [ `https://developer.mozilla.org/en-US/docs/Web/HTTP/Status`, ], transforms: transforms.events });
Under Transforms, create a transform named
events
. Leave it empty for now.Use the Debugging Chat to ask questions you want to be transformed, for example:
What does code 304 mean?
In the code editor, to the left of the
transforms
function, click the magnifying glass icon. This will open the Transforms Explorer.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.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 thecorpus()
output as needed.
Now, you can ask questions about the status codes and see how the set formatting rules are applied to the corpus()
output: