Create task recommendations
Red Hat Ansible Lightspeed is integrated into Visual Studio (VS) Code through the Ansible VS Code extension. You can request code recommendations for your task intent by using Ansible VS Code extension.
You can perform the following tasks from the Ansible VS Code extension:
- Create single task or multitask requests by using natural language prompts
- Create a single task prompt
Write a description of your task in the
- name:key of a new task line in your Ansible file. For example, to automate a task of installing PostgreSQL server, you can enter the prompt- name: Install postgresql-server. - Create a multitask prompt
Place your cursor on a new line in your Ansible YAML file at the correct indentation, and start your prompt with a Pound key (#).
Write the descriptions of your tasks, separating each prompt by using Ampersand symbols (&). For example, to automate a multitask of installing PostgreSQL server and running the initial PostgreSQL setup command, you can enter the prompt
# Install postgresql-server & run postgresql-setup command.The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates Ansible task recommendations based on your natural language prompt.
Note Currently, Red Hat Ansible Lightspeed supports user prompts in English language only. However, there could be instances where the training data that was used to train the IBM watsonx Code Assistant models included non-English language. In such scenarios, the model can generate code recommendations for prompts made in the same non-English language, but the generated code recommendations might or might not be accurate.
- Create a single task prompt
- View the content source matching results
For each generated code recommendation, Red Hat Ansible Lightspeed lists content source matches, including details such as potential source, content author, and relevant licenses. You can use this data to gain insight into potential training data sources used to generate the code recommendations.
- Provide feedback on the Ansible Lightspeed service
The Ansible Lightspeed service learns your organizational patterns and improves the code recommendation experience over time. You can provide feedback on whether the generated code recommendations were suitable for your task intent. This feedback enables Red Hat Ansible Lightspeed with IBM watsonx Code Assistant to improve on the quality of its suggestions.
Best practices to improve the recommended guidance Copy linkLink copied!
Follow these guidelines to improve the likelihood of a quality code recommendation.
- Ensure that your YAML file is properly formatted.
- Avoid context switching within a single playbook file.
The Ansible Lightspeed service attempts to correlate earlier tasks to the active recommendation, and the entire contents of the file before the cursor position are used as context by the model. If the earlier task is not relevant to your prompt, VS code provides inline suggestions instead of code recommendations.
- Reword your natural language prompts to get code recommendations that match your task intent.
If you get a recommendation that does not align with the intent of your task name, then rewording your prompt to provide more information about what is desired can lead to improved results.
- Use descriptive prompts and provide additional content to improve the code recommendations.
Red Hat Ansible Lightspeed reads the full Ansible YAML file when generating a code recommendation. Using descriptive prompts and having additional YAML file content related to the desired task improves the code recommendation. For example, you can add the previous Ansible tasks and appropriate playbook and variable names to improve the code recommendations.
Create single task recommendations Copy linkLink copied!
You can request code recommendations for a single task by entering natural language prompts in Ansible VS Code extension. The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates the code recommendations.
Before you begin Copy linkLink copied!
- You meet one of the following requirements:
- Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
- Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
- You have installed and configured the Ansible VS Code extension.
Procedure Copy linkLink copied!
Create multitask recommendations Copy linkLink copied!
You can request multitask code recommendations by entering a sequence of natural language task prompts in Ansible VS Code extension. In a YAML file, start your prompt with a pound symbol (#), and separate each prompt by using the ampersand symbol (&).
Before you begin Copy linkLink copied!
- You meet one of the following requirements:
- Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
- Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
- You have installed and configured the Ansible VS Code extension.
About this task Copy linkLink copied!
Example of a multitask prompt
# Install postgresql-server & run postgresql-setup command
For better readability, you can split your multitask inline prompts over multiple lines. To achieve this, end your current line with an ampersand symbol (&) and start the next line with the hash symbol (#).
Example of a multitask prompt split over multiple lines
# Create a keypair called lightspeed-keypair & create a vpc & create vpc_id var &
# create a security group that allows SSH & create subnet with 10.0.1.0/24 cidr &
# create an internet gateway & create a route table
The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates the code recommendations.
While entering a multitask prompt, the Ansible VS Code extension might display a warning if you have long lines in your prompt based on your ansible-lint settings. This warning is a minor readability error and does not impact the quality of your code recommendation output. To resolve the error, you can either ignore it or fix it by splitting your multitask inline prompt over multiple lines.
Procedure Copy linkLink copied!
View the Ansible Lightspeed training matches Copy linkLink copied!
The Red Hat Ansible Lightspeed with IBM watsonx Code Assistant machine learning model is trained on the following content:
- Existing public or private Git repositories
- Content from Ansible Galaxy
IBM watsonx Code Assistant uses generative AI technology and various types of Ansible content to train the model. Therefore, it is not possible to trace the specific training data that produced a given code recommendation.
For each generated code recommendation, Red Hat Ansible Lightspeed lists the content source matches, including details such as potential source, content author, and relevant licenses. You can use this data to gain insight into potential training data sources used to generate the code recommendations.
After you enter a natural language prompt in VS Code and see the generated code recommendations, you can view the content source matches on the ANSIBLE: LIGHTSPEED TRAINING MATCHES tab.
For example, the following illustration shows the training matches for the multitask recommendation Install postgresql-server & run postgresql-setup command:
This capability enables you to find out the open source license terms that are associated with related training data. However, it is unlikely that either the training data used in fine-tuning the code or the output recommendations themselves are protected by copyright, or that the output reproduces training data that is controlled by copyright licensing terms.
Red Hat does not claim any copyright or other intellectual property rights in the suggestions generated by Red Hat Ansible Lightspeed with IBM watsonx Code Assistant.