Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 6. Requesting task recommendations

download PDF

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.

6.1. Overview

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.

  • 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.

6.2. Requesting code recommendations for a single task

You can request code recommendations for a single task by entering natural language prompts in Ansible VS Code extension. For example, to automate a task of installing a PostgreSQL server, you can enter the prompt - name: Install postgresql-server. The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates the code recommendations.

Prerequisites

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. Create a new YAML file or use an existing YAML file:

    • Create a YAML file:

      1. Select File New Text File.
      2. From the lower right of the screen, click Plain Text, and in the language mode, select Ansible.
      3. Save the file as a YAML file format extension (.yml or .yaml).
    • Use an existing YAML file:

      1. On the bottom right of the screen, click the existing language mode, and in the language mode settings, select Ansible.

        Note

        If you do not see the language mode section in your VS Code editor, from the Command Palette, select Configure Langauge Mode Ansible.

  3. Verify that you see an entry for Lightspeed on the status bar at the lower right of VS Code.

    If Ansible is already selected as the desired language but the Lightspeed entry is not displayed, re-select Ansible as the language mode. The following illustration shows Lightspeed and Ansible entries on the VS Code status bar.

    Figure 6.1. Ansible and Lightspeed set as selected language mode

    Settings show Ansible and Lightspeed as selected language mode
  4. Optional: If you see an error message about missing Ansible lint, you can install the missing module or disable it. Perform any one of the following tasks:

    • Install Ansible lint: For installation information, see the Installing section of the Ansible Lint documentation.
    • Disable Ansible lint:

      1. From the Activity bar, click the Extensions icon Extensions .
      2. From the Installed extensions list, select Ansible.
      3. From the Ansible extension page, click the Settings icon and select Extension Settings.
      4. Clear the Ansible › Validation › Lint: Enabled checkbox.
  5. Create a playbook or use an existing playbook.

    For more information, see Creating playbooks in the Ansible Automation Platform Creator Guide.

  6. In the playbook, provide the following information to request code recommendations for a single task:

    1. Add a new Ansible task by starting a new line with - name: at the correct indentation.
    2. Add a detailed natural language prompt in the task description after - name: on the same line. For example, you can specify the following single task prompt: - name: Install postgresql-server
    3. Press Enter directly after the task description. Keep the cursor at the same location in your file, and wait for the code recommendation results to populate.

      The Ansible Lightspeed service is engaged, and it starts generating code recommendations for a single task.

      Important

      Ansible Lightspeed service takes around 5 seconds per task to populate the code recommendations. If you are using a multitask prompt, the Ansible Lightspeed service takes a bit longer (number of tasks times 5 seconds) to populate the results. Do not move your cursor or press any key while the code recommendation is being generated. If you change the cursor location or press any key, Ansible VS Code extension cancels the request and the Ansible Lightspeed service does not process your request.

      When the Ansible Lightspeed service is engaged, a Lightspeed processing status indicator is displayed in the lower right of the screen to denote that your code recommendation is being generated.

      Lightspeed icon

  7. View your code recommendations and ensure that the recommendations match your task intent.

    The following illustration shows the code recommendations generated by the Ansible Lightspeed service for the single task Install postgresql-server:

    Lightspeed single task in progress

  8. Accept or reject the code recommendations:

    • To accept a code recommendation, press Tab.
    • To reject a code recommendation, press Esc.

      Note

      If you reject a recommendation, you can modify the prompt and review the generated code recommendations once again to match your task intent.

  9. On the ANSIBLE: LIGHTSPEED TRAINING MATCHES tab, view the content source matching results.

    The following illustration shows the training matches found in existing Ansible Galaxy content for the task prompt Install postgresql-server:

    training matches in existing content
  10. Click Save to save the code recommendation changes in your Ansible YAML file.

6.3. Requesting code recommendations for multiple tasks

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 a comment by using a Pound key (#), and separate 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 models, and generates the code recommendations.

Prerequisites

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. Create a new YAML file or use an existing YAML file.

    • Create a YAML file:

      1. Select File New Text File.
      2. From the lower right of the screen, click Plain Text, and in the language mode, select Ansible.
      3. Save the file as a YAML file format extension (.yml or .yaml).
    • Use an existing YAML file:

      1. On the bottom right of the screen, click the existing language mode, and in the language mode settings, select Ansible.

        Note

        If you do not see the language mode section in your VS Code editor, from the Command Palette, select Configure Langauge Mode Ansible.

  3. Verify that you see an entry for Lightspeed on the status bar at the lower right of VS Code.

    If Ansible is already selected as the desired language but the Lightspeed entry is not displayed, re-select Ansible as the language mode. The following illustration shows Lightspeed entry on the VS Code status bar.

    Figure 6.2. Ansible and Lightspeed set as selected language mode

    Settings show Lightspeed as selected language mode
  4. Optional: If you see an error message about missing Ansible lint, you can install the missing module or disable it. Perform any one of the following tasks:

    • Install Ansible lint: For installation information, see the Installing section of the Ansible Lint documentation.
    • Disable Ansible lint:

      1. From the Activity bar, click the Extensions icon Extensions .
      2. From the Installed extensions list, select Ansible.
      3. From the Ansible extension page, click the Settings icon and select Extension Settings.
      4. Clear the Ansible › Validation › Lint: Enabled checkbox.
  5. Create a playbook or use an existing playbook.

    For more information, see Creating playbooks in the Ansible Automation Platform Creator Guide.

  6. In the playbook, provide the following information to request multitask code recommendations:

    1. Start a new YAML file comment by entering a Pound key (#) at the correct indentation.
    2. Add a detailed natural language prompt in a sequence, separating each task by using an Ampersand (&) symbol. For example, to automate the multitask of installing PostgreSQL server and running the PostgreSQL setup command, enter the following natural language prompt # Install postgresql-server & run postgresql-setup command.
    3. Press Enter directly after the task description. Keep the cursor at the same location in your file, and wait for the code recommendation results to populate.

      The Ansible Lightspeed service is engaged, and it starts generating code recommendations for multiple tasks.

      Important

      Ansible Lightspeed service takes around 5 seconds per task to populate the code recommendations. If you are using a multitask prompt, the Ansible Lightspeed service takes a bit longer (number of tasks times 5 seconds) to populate the results. Do not move your cursor or press any key while the code recommendation is being generated. If you change the cursor location or press any key, Ansible VS Code extension cancels the request and the Ansible Lightspeed service does not process your request.

      When the Ansible Lightspeed service is engaged, a Lightspeed processing status indicator is displayed in the lower right of the screen to denote that your code recommendation is being generated.

      Lightspeed icon

  7. Optional: If multitask code recommendations are not being generated, log out of VS Code and log in again using your Red Hat account.
  8. View your code recommendations and ensure that the recommendations match your task intent.

    The following illustration shows the code recommendations generated by the Ansible Lightspeed service for the multitask prompt Install postgresql-server & run postgresql-setup command: :

    Lightspeed single task in progress

  9. Accept or reject the code recommendations:

    • To accept a code recommendation, press Tab.
    • To reject a code recommendation, press Esc.

      Note

      If you reject a recommendation, you can modify the prompt and review the generated code recommendations once again to match your task intent.

  10. On the ANSIBLE: LIGHTSPEED TRAINING MATCHES tab, view the content source matching results.

    The following illustration shows the training matches found in existing Ansible Galaxy content for the task prompt multitask prompt Install postgresql-server & run postgresql-setup command:

    training matches in existing content
  11. Click Save to save the code recommendation changes in your Ansible YAML file.

6.4. Viewing Ansible Lightspeed training matches

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

Owing to IBM watsonx Code Assistant’s generative AI technology, as well as the types of Ansible content that were used to train the model, it is not possible to identify the specific set of training data that contributed to the generated code recommendations. However, Ansible Lightspeed provides a capability that helps you to understand the possible origins of generated code recommendations.

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:

Figure 6.3. Training matches for a multitask recommendation

Training matches for multitask recommendation

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.

Note

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.

6.5. Providing feedback on the Ansible Lightspeed service

Red Hat Ansible Lightspeed with IBM watsonx Code Assistant is designed to be improved through feedback on the quality of its suggestions. The technical details of user experiences with Red Hat Ansible Lightspeed are useful in informing further improvements.

You can submit feedback through the following channels:

  • From the Ansible VS Code extension: Use this method to provide feedback about the quality of the suggested code recommendations.

    Important

    Red Hat Support cannot assist with the suggestion quality reports. Content quality issues are routed to IBM for resolution.

  • From the Red Hat customer portal: Use this method to log bug reports and service disruption incidents, and feature requests.
Note

On the login screen of the Ansible Lightspeed Portal, there is a Chat link that redirects you to a Matrix channel. Use the Matrix channel to ask questions pertaining to your Ansible Lightspeed experience and request help to troubleshoot your issues. However, the Matrix channel is not an official Support channel, and issues raised in the Matrix chat would not be tracked through Red Hat Service Level Agreement (SLA). To raise a bug or a feature request, contact Red Hat Support and open a support ticket.

Prerequisites

  • You are part of an organization that has a trial or paid subscription to both Ansible Automation Platform and IBM watsonx Code Assistant.

Procedure

  1. Open Visual Studio Code.
  2. Click the Lightspeed entry in your status bar to see options.
  3. In the Tell us why field, provide your feedback. Here, provide feedback about what results you were expecting to receive, compared to what results were generated and the training match.
  4. Select the issue type: Bug report, Feature request, or Suggestion feedback.

    Note

    To raise a bug or feature request, contact Red Hat Support and open a support ticket. Bug features and feature requests made through Ansible Lightspeed feedback are not tracked through the Red Hat Service Level Agreement (SLA).

  5. Select the I understand that feedback is shared with Red Hat and IBM checkbox.
  6. Click Send.

    The following image shows an example of providing suggestion feedback:

    Figure 6.4. Providing feedback on Ansible Lightspeed

    Providing feedback on Ansible Lightspeed
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.