diff --git a/src/ai-examples/HISTORY.rst b/src/ai-examples/HISTORY.rst index 38acb6f6677..36ae4114d46 100644 --- a/src/ai-examples/HISTORY.rst +++ b/src/ai-examples/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +0.2.0 +++++++ +* Add AI generated examples to all group and command "--help" + 0.1.0 ++++++ * Initial release. diff --git a/src/ai-examples/README.rst b/src/ai-examples/README.rst index cf3eb509bea..c321db81c46 100644 --- a/src/ai-examples/README.rst +++ b/src/ai-examples/README.rst @@ -1,6 +1,6 @@ Microsoft Azure CLI 'AI Examples' Extension ========================================== -Improve user experince by adding AI powered examples to command help content. +Improve user experience by adding AI powered examples to command help content. This extension changes the default examples provided when calling `-h` or `--help` on a command, such as `az vm create -h`, with ones selected by an AI powered service. The service provides examples based on Azure usage, internet sources, and other factors. \ No newline at end of file diff --git a/src/ai-examples/azext_ai_examples/__init__.py b/src/ai-examples/azext_ai_examples/__init__.py index 4c678e05fdc..817323b7e79 100644 --- a/src/ai-examples/azext_ai_examples/__init__.py +++ b/src/ai-examples/azext_ai_examples/__init__.py @@ -12,8 +12,8 @@ def inject_functions_into_core(): # Replace the default examples from help calls from azure.cli.core._help import AzCliHelp - from azext_ai_examples.custom import provide_examples - AzCliHelp.example_provider = provide_examples + from azext_ai_examples.custom import new_examples + AzCliHelp.update_examples = new_examples class AiExamplesCommandsLoader(AzCommandsLoader): diff --git a/src/ai-examples/azext_ai_examples/azext_metadata.json b/src/ai-examples/azext_ai_examples/azext_metadata.json index bb2003f649f..2892e1607d2 100644 --- a/src/ai-examples/azext_ai_examples/azext_metadata.json +++ b/src/ai-examples/azext_ai_examples/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isPreview": true, - "azext.minCliCoreVersion": "2.0.81" + "azext.minCliCoreVersion": "2.2.0" } \ No newline at end of file diff --git a/src/ai-examples/azext_ai_examples/custom.py b/src/ai-examples/azext_ai_examples/custom.py index a7a82cbefd4..56d5f8680f4 100644 --- a/src/ai-examples/azext_ai_examples/custom.py +++ b/src/ai-examples/azext_ai_examples/custom.py @@ -23,28 +23,17 @@ def check_connection_aladdin(): print('Connection failed') -# Replacements for core functions -def provide_examples(help_file): - return replace_examples(help_file) +def new_examples(help_file): + help_file.examples = replace_examples(help_file.command) -# Provide two options for changing the examples - -# Replace built in examples wirh Aladdin ones -def replace_examples(help_file): +# Replace built in examples with Aladdin ones +def replace_examples(command): # Specify az to coerce the examples to be for the exact command - lookup_term = "az " + help_file.command + lookup_term = "az " + command return get_generated_examples(lookup_term) -# Append Aladdin examples to the built in ones -def append_examples(help_file): - # Specify az to coerce the examples to be for the exact command - lookup_term = "az " + help_file.command - aladdin_examples = get_generated_examples(lookup_term) - return concat_unique_examples(help_file.examples, aladdin_examples) - - # Support functions def get_generated_examples(cli_term): examples = [] @@ -57,23 +46,6 @@ def get_generated_examples(cli_term): return examples -def concat_unique_examples(first_list, second_list): - for first_item in first_list: - for second_item in second_list: - if are_examples_equal(first_item, second_item): - second_list.remove(second_item) - return first_list + second_list - - -def are_examples_equal(first, second): - return clean_string(first.short_summary) == clean_string(second.short_summary) \ - or clean_string(first.command) == clean_string(second.command) - - -def clean_string(text): - return text.strip() - - def clean_from_http_answer(http_answer): example = HelpExample() example.short_summary = http_answer['title'].strip() diff --git a/src/ai-examples/setup.py b/src/ai-examples/setup.py index 26bbd6139a1..ae84343ae63 100644 --- a/src/ai-examples/setup.py +++ b/src/ai-examples/setup.py @@ -15,7 +15,7 @@ logger.warn("Wheel is not available, disabling bdist_wheel hook") # HISTORY.rst entry. -VERSION = '0.1.0' +VERSION = '0.2.0' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -48,7 +48,7 @@ author='Matthew Booe', author_email='mabooe@microsoft.com', url='https://github.com/Azure/azure-cli-extensions/tree/master/src/ai-examples', - long_description='Improve user experince by adding AI powered examples to command help content.', + long_description='Improve user experience by adding AI powered examples to command help content.', license='MIT', classifiers=CLASSIFIERS, packages=find_packages(),