Adjust AI reasoning and output¶
Alan AI provides a human-in-the-loop capability, enabling you to directly intervene in the AI decision-making and fine-tune the AI reasoning process. You can adjust how the AI system arrives at its conclusions, generates code and produces data outputs. This way, you can make sure that the AI agent produces responses that are more accurate, relevant and contextually appropriate.
Note
This exercise covers basic cases of adjusting AI reasoning and output. For advanced cases, see Transforms.
Use case¶
As a developer, you can review the AI agent reasoning process and manually refine its logic. You can:
Prerequisites¶
To successfully follow this exercise, make sure the following prerequisites are met:
You have signed up for Alan AI Studio and created a project for the AI agent. For details, see Sign up for Alan AI Studio.
You have set up a dynamic corpus for the AI agent. For details, see Create a dynamic corpus.
Adjust AI reasoning¶
When Alan AI generates code, you can review and adjust the code snippets for accuracy and relevance.
In the Debugging Chat in Alan AI Studio, ask a question:
Show all stopped VMs
.Use the reasoning graph to identify the cause of the problem. In this case, the AI agent generates the code that requires fine-tuning.
In the code editor, open the
infrastructure_queries
transform. In the top right corner, click History.To the right of the
Show all stopped VMs
query, click the Plus icon to add the example to the transform examples list.In the added example, click the Magnifying glass icon in the top left corner of any cell to zoom into the example data.
Review the code generated by the AI system. To test the code, in the top right corner of the Result pane, click the Run button.
In the
<thinking></thinking>
block, adjust the AI reasoning in natural language. In this example, to fix the problem, you need to point the AI system to the correct data node. Then, remove the code below and click the Generate result button at the top of the pane.Alan AI will generate the correct code snippet using the instructions in the
<thinking></thinking>
block.To test the code, in the top right corner of the Result pane, click the Run button.
Save the transform and test the same query in the Debugging Chat:
In the Debugging Chat, try similar queries, for example:
Show all running VMs
. Alan AI will apply the added example to provide correct responses for similar queries:
Adjust the format of data output¶
Using instructions and examples in transforms, you can adjust the format of data output both for static and dynamic corpuses.
In this exercise, we will change the way the AI agent displays the infrastructure objects data. For more examples, see Transform instructions and examples.
In the
Dynamic corpus
dialog script, update thecorpus()
function to add an output transform:corpus({ title: `Infrastructure requests`, query: transforms.infrastructure_queries, // Output transform transform: transforms.infrastructure_output, priority: 2 });
Under Transforms in the left pane, click Add to add a new transform named
infrastructure_output
.In the Instruction field, provide general instructions on how to format dynamic data:
Highlight all infrastructure object names bold. Present all object data as a table including all object values.
In the Debugging Chat, test the
Show all running VMs
query:Open the
infrastructure_output
transform. In the top right corner, click History.To the right of the
Show all running VMs
query, click the Plus icon to add the example to the transform examples list. Then, zoom into the example data:At the top of the Result field, change the data format to response.
Adjust the Full answer data, for example, change the leading phrase. Then save the transform.
Validation¶
Test the Show all running VMs
query and similar queries in the Debugging Chat: