-
Notifications
You must be signed in to change notification settings - Fork 28
Review main-notebooks/management.ipynb
#57
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,23 +4,23 @@ | |
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Manage Analyzers in Your Resource" | ||
"# Managing Analyzers in Your Resource" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This notebook demo how to create a simple analyzer and manage its lifecycle." | ||
"This notebook demonstrates how to create a simple analyzer and manage its lifecycle." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Prerequisites\n", | ||
"1. Ensure Azure AI service is configured following [steps](../README.md#configure-azure-ai-service-resource)\n", | ||
"2. Install the required packages to run the sample." | ||
"1. Ensure your Azure AI service is configured following the [configuration steps](../README.md#configure-azure-ai-service-resource).\n", | ||
"2. Install the required packages to run this sample." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
|
@@ -36,16 +36,18 @@ | |
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Create Azure AI Content Understanding Client\n", | ||
"## Create the Azure AI Content Understanding Client\n", | ||
"\n", | ||
"> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class containing functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, it can be regarded as a lightweight SDK. Fill the constant **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, **AZURE_AI_API_KEY** with the information from your Azure AI Service.\n", | ||
"> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class that provides functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, this client serves as a lightweight SDK.\n", | ||
"\n", | ||
"> Fill the constants **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, and **AZURE_AI_API_KEY** with your Azure AI Service details.\n", | ||
"\n", | ||
"> ⚠️ Important:\n", | ||
"You must update the code below to match your Azure authentication method.\n", | ||
"Update the code below to match your Azure authentication method.\n", | ||
"Look for the `# IMPORTANT` comments and modify those sections accordingly.\n", | ||
"If you skip this step, the sample may not run correctly.\n", | ||
"If you skip this step, the sample might not run correctly.\n", | ||
"\n", | ||
"> ⚠️ Note: Using a subscription key works, but using a token provider with Azure Active Directory (AAD) is much safer and is highly recommended for production environments." | ||
"> ⚠️ Note: Using a subscription key works, but using Azure Active Directory (AAD) token-based authentication is more secure and highly recommended for production environments." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
|
@@ -65,13 +67,13 @@ | |
"load_dotenv(find_dotenv())\n", | ||
"logging.basicConfig(level=logging.INFO)\n", | ||
"\n", | ||
"# For authentication, you can use either token-based auth or subscription key, and only one of them is required\n", | ||
"# For authentication, you can use either token-based auth or subscription key. Use only one of these methods.\n", | ||
"AZURE_AI_ENDPOINT = os.getenv(\"AZURE_AI_ENDPOINT\")\n", | ||
"# IMPORTANT: Replace with your actual subscription key or set up in \".env\" file if not using token auth\n", | ||
"# IMPORTANT: Replace with your actual subscription key or set it in your \".env\" file if not using token auth\n", | ||
"AZURE_AI_API_KEY = os.getenv(\"AZURE_AI_API_KEY\")\n", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"AZURE_AI_API_VERSION = os.getenv(\"AZURE_AI_API_VERSION\", \"2025-05-01-preview\")\n", | ||
"\n", | ||
"# Add the parent directory to the path to use shared modules \n", | ||
"# Add the parent directory to the system path to use shared modules\n", | ||
"parent_dir = Path(Path.cwd()).parent\n", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"sys.path.append(str(parent_dir))\n", | ||
"from python.content_understanding_client import AzureContentUnderstandingClient\n", | ||
|
@@ -84,18 +86,18 @@ | |
" api_version=AZURE_AI_API_VERSION,\n", | ||
" # IMPORTANT: Comment out token_provider if using subscription key\n", | ||
" token_provider=token_provider,\n", | ||
" # IMPORTANT: Uncomment this if using subscription key\n", | ||
" # IMPORTANT: Uncomment this line if using subscription key\n", | ||
" # subscription_key=AZURE_AI_API_KEY,\n", | ||
" x_ms_useragent=\"azure-ai-content-understanding-python/analyzer_management\", # This header is used for sample usage telemetry, please comment out this line if you want to opt out.\n", | ||
" x_ms_useragent=\"azure-ai-content-understanding-python/analyzer_management\", # This header is used for sample usage telemetry. Comment out this line if you want to opt out.\n", | ||
")" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Create a simple analyzer\n", | ||
"We first create an analyzer from a template to extract invoice fields." | ||
"## Create a Simple Analyzer\n", | ||
"First, we create an analyzer from a template to extract invoice fields." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
|
@@ -119,14 +121,14 @@ | |
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## List all analyzers created in your resource" | ||
"## List All Analyzers in Your Resource" | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"After the analyzer is successfully created, we can use it to analyze our input files." | ||
"After successfully creating an analyzer, you can list all analyzers available in your resource." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
|
@@ -137,17 +139,17 @@ | |
"source": [ | ||
"response = client.get_all_analyzers()\n", | ||
"print(f\"Number of analyzers in your resource: {len(response['value'])}\")\n", | ||
"print(f\"The first 3 analyzer details: {json.dumps(response['value'][:3], indent=2)}\")\n", | ||
"print(f\"The last analyzer details: {json.dumps(response['value'][:-1], indent=2)}\")" | ||
"print(f\"Details of the first 3 analyzers: {json.dumps(response['value'][:3], indent=2)}\")\n", | ||
"print(f\"Details of all analyzers except the last one: {json.dumps(response['value'][:-1], indent=2)}\")" | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Get analyzer details with id\n", | ||
"## Get Analyzer Details by ID\n", | ||
"\n", | ||
"Remember the analyzer id when you create it. You can use the id to look up detail analyzer definitions afterwards." | ||
"Keep track of the analyzer ID when you create it. Use the ID to retrieve detailed analyzer definitions later." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
|
@@ -164,8 +166,8 @@ | |
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Delete Analyzer\n", | ||
"If you don't need an analyzer anymore, delete it with its id." | ||
"## Delete an Analyzer\n", | ||
"If you no longer need an analyzer, delete it using its ID." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
{ | ||
|
@@ -199,4 +201,4 @@ | |
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.