Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Interactive] Integrate Recommendation capability into interactive #5950

Merged
merged 158 commits into from
May 30, 2023

Conversation

wu5bocheng
Copy link
Contributor

@wu5bocheng wu5bocheng commented Mar 7, 2023


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az interactive

Description

Outline

[Revolutionary Change] Integrate the cli recommendation to make the completion ability more intelligent and provide the scenario completion.
[Add] Support command recommendations that predicts the next commands users might need.
[Add] Support scenario recommendations to help users complete the complex scenarios more smoothly and simply.
[Add] Support new config az config set interactive.enable_recommender=False to disable these new recommenders.
[Add] Add loading bar to avoid command execution errors caused by uncompleted command loading and param update. User can use CTRL+C to cancel the loading bar or az config set interactive.enable_preloading=False to disable it.
[Add] Add value completion mechanism for param value in scenarios
[Add] Support searching ability for scenarios
[Optimize] Update telemetry feedback function and add 'CLIRecommendation' property. (Details: https://github.com/hackathon-cli-recommendation/cli-recommendation/blob/master/Docs/feedback_design.md)
[Optimize] Optimize param completion mechanism to recommend one parameter at a time.
[Optimize] Support using 'CTRL+C' to refresh the panel interface
[Fix] Fix display offset in toolbar
[Fix] Command execution errors caused by uncompleted command loading and param update
[Others] Remove README.rst and modified setup file
[Others] Import styled text print from azure-cli-core.style

File Structure

azext_interactive

  • azext_metadata.json
    • Contains extension configuration information
  • init.py
    • Initializes the extension
  • azclishell
    • app.py
      • Core file that includes initialization, preloading, tool startup, command execution, and handling command return results
      • [Function] redraw_scenario_recommendation_info
        • Processes and parses the results returned by the scenario recommendation service
      • [Function] _space_examples
        • Displays examples related to the input command, updating formatting issues
      • [Function] create_application
        • Creates the interactive interface, updating to add scenario mode support
      • [Function] handle_scenario
        • Parses and handles the user's scenario request to obtain the user's selected scenario
      • [Function] scenario_repl
        • Sets the return, processing, and display logic for scenario mode
      • [Function] handle_search
        • Parses and handles the user's search request to obtain the user's input keywords and selected search results, finally processes the results and calls the scenario_repl's scenario mode
      • [Function] load_command_table
        • Adds command preloading functionality to fix errors caused by incomplete command loading
    • az_completer.py
      • Configuration file for autocomplete functionality
      • [Function] gen_recommend_completion
        • Calls the recommendation service when the user enters a space/az, recommending commands based on historical input
      • [Function] gen_recommended_scenario
        • Calls the recommendation service when the user enters a space/az, recommending a set of commands forming a scenario based on historical input
    • layout.py
      • Layout file for the interactive interface, updated to set and support scenario mode
    • recommendation.py
      • Core file for the recommendation service frontend, implementing command and scenario recommendation functionality for the user
      • [Class] RecommendThread
        • Recommendation service thread that uses the get_recommend_from_api function, allowing asynchronous requests
      • [Class] Recommender
        • [Function] feedback_command/feedback_scenario/feedback_search
          • Collects data through telemetry based on the user's acceptance of the recommended results, preparing data support for subsequent fine-tuning
        • [Function] update_exec_result
          • Updates the execution result of the previous command, preparing for error handling
        • [Function] _get_result/get_commands/get_scenarios
          • Parses and retrieves the recommended results from RecommendThread based on the set recommendation result type
      • [Function] get_recommend_from_api
        • Calls the API to retrieve command and scenario recommendation results
      • [Function] send_feedback
        • Collects user feedback data on the recommended results through telemetry, preparing data support for subsequent fine-tuning, called by feedback_command/scenario/search
      • [Function] _show_details_for_e2e_scenario
        • Parses the returned scenario information from the request and outputs detailed information and recommendation reasons for each command
      • [Function] gen_command_in_scenario
        • Parses and outputs each command separately in scenario mode
      • [Function] _get_command_sample/_format_command_sample
        • Parses the returned scenario script and adds emphasis and example information
    • scenario_search.py
      • Core file that supports scenario search functionality, similar to azext_scenario_guide.requests.search_online project
      • [Function] search_result_to_scenario_list
        • Parses the results returned by scenario_search to adapt them to scenario mode
    • scenario_suggest.py
      • Implements parameter completion and recommendation functionality in scenarios
      • [Function] update_customized_cached_param_map
        • Maintains a dictionary with param sample value and partial special param name as keys, and user-entered custom value as the value
      • [Function] get_suggestion
        • Recommends param and param value to the user in scenario mode. Auto-completion of custom parameter values entered by the user historically
    • telemetry.py
    • threads.py
    • util.py
      • Contains some reusable functions, mainly used for scenario search functionality
    • _azclierror.py
      • Contains custom error information
    • _dump_commands.py
    • init.py
      • Contains extension version information
  • tests
    • Testing folder for automated test scripts

Intelligent AZ Interactive (Revolutionary Change)

Recommendation

We have integrated the cli recommendation to make the completion ability more intelligent and provide the scenario completion. This is a revolutionary change. Users can enable or disable the recommendation feature by running the following commands:

$ az config set interactive.enable_recommender=True # Default, try the new recommendation feature
$ az config set interactive.enable_recommender=False # Disable the recommendation feature

Command Recommendation

Command recommendation uses an intelligent algorithm to suggest the most relevant and frequently used command for the user based on their historical command inputs. By analyzing the user's input history and matching it with the highest relevant commands, Intelligent Az Interactive can assist Azure CLI beginners in making quick and informed decisions, saving them time and effort.

The command recommendation feature can also be a good way to broaden users' knowledge boundaries and help them recognize and learn commands that are related to their common commands but never used before.

Scenario Identification

Scenario identification is another powerful feature that automatically recognizes the user's current scenario and recommends a set of commands that are most relevant to the user's needs. This feature is based on our extensive database of over 600+ business scenarios, which cover a wide range of use cases across various scenes. By analyzing the user's input history, Intelligent Az Interactive can identify the relevant scenario and suggest the most appropriate command set, helping new CLI users to quickly accomplish their tasks with confidence and ease.

Search for Scenarios

We have added the ability to help users search for scenarios based on keywords. When the user enters some keywords or descriptions, we will recommend the scenarios that are most likely to be used based on the keywords and descriptions of the functions the user wants to implement.

$ az interactive // initialize the az interactive
$ /connect a mongodb to web app // Search for scenario by starting with / and entering keywords
>>  output
[1] Connect an app to MongoDB (Cosmos DB). (5 Commands)
Connect an app to MongoDB (Cosmos DB).

[2] Tutorial to create and connect Web App to Azure Database for MySQL Flexible Server in a virtual network (6 Commands)
Tutorial to create and connect Web App to Azure Database for MySQL Flexible Server in a virtual network

[3] Connect an app to SQL Database. (7 Commands)
Connect an app to SQL Database.

[4] Connect an app to a storage account. (5 Commands)
Connect an app to a storage account.

[5] Deploy an ASP.NET Core web app to Azure App Service and connect to an Azure SQL Database. (8 Commands)
Deploy an ASP.NET Core web app to Azure App Service and connect to an Azure SQL Database.

 ? Please select your option (if none, enter 0):
 $ 1 // Select the scenario you want to use

Loading Bar

The loading bar is a feature that we have implemented to provide users with a more stable and predictable experience while using our platform. Its primary function is to prevent command parameter detection errors that may occur due to incomplete loading. By displaying the progress of initialization through the loading bar, users can be assured that the initialization process is ongoing and they can expect to see a fully loaded interface once the bar reaches 100%.

Additionally, the loading bar helps prevent user interface lagging or freezing due to insufficient memory. By preloading the necessary resources and data, users can avoid encountering these issues when inputting commands.

The loading bar is an essential tool that improves the user experience by ensuring that all necessary components are loaded before usage, thereby reducing the risk of encountering errors and providing a smoother, more stable platform.

Please refer to the following gif to see the loading bar in action:

loading_bar

Value Completion in Scenarios

We added a completion mechanism for param value in scenarios to improve the completion ability of param value in
scenarios. In multiple commands of the same scenario, once the user enters a param value, we store the value entered by
the user based on the scenario sample value and some special global params, and automatically recommend the completion
of these param values in subsequent commands.

Telemetry Feedback Optimization

To collect data and facilitate the optimization and tuning of the cli recommendation model, we have optimized the
telemetry feedback function. We have added CLIRecommendation to the properties of telemetry feedback. For details,
please refer
to cli-recommendation.

@jsntcy
Copy link
Member

jsntcy commented May 29, 2023

How can we guarantee there is no regression with this change?

@wu5bocheng
Copy link
Contributor Author

How can we guarantee there is no regression with this change?

Our recommendations are based on the correlation between commands, suggesting more frequent command combinations to users, and have achieved better results in tests. If the user wants to disable the recommendation feature, it can be disabled by az config set interactive.enable_recommender=False

wu5bocheng and others added 6 commits May 30, 2023 14:44
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
wu5bocheng and others added 2 commits May 30, 2023 15:03
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
@zhoxing-ms zhoxing-ms merged commit 1a82058 into Azure:main May 30, 2023
@azclibot
Copy link
Collaborator

[Release] Update index.json for extension [ interactive ] : https://dev.azure.com/azclitools/internal/_build/results?buildId=59035&view=results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants