Adjust AI reasoning and output¶
The Alan AI Platform empowers developers with a human-in-the-loop capability, enabling them to fine-tune the AI agent reasoning and output by directly intervening in the decision-making process. This enables you to adjust how the AI system arrives at its conclusions, generates code and produces data outputs.
Note
This exercise covers basic cases of adjusting AI reasoning and output. For advanced cases, see Data transformation.
Use case¶
As a developer, you can review the AI agent reasoning process and manually refine its logic. This involves:
By intervening in this way, you can ensure that the AI agent produces responses that are more accurate, relevant and contextually appropriate.
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 working with the dynamic corpus, you can make necessary changes to the algorithms or rules that guide the AI reasoning. When Alan AI generates code as part of its output, 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 generate 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 natural language 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 to other queries of the same type:
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 if necessary.
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: