-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,676 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# APIM ❤️ OpenAI | ||
|
||
## [Token Metrics Emitting lab](token-metrics-emitting.ipynb) | ||
|
||
[![flow](../../images/token-metrics-emitting.gif)](token-metrics-emitting.ipynb) | ||
|
||
Playground to try the [emit token metric policy](https://learn.microsoft.com/azure/api-management/azure-openai-emit-token-metric-policy). The policy sends metrics to Application Insights about consumption of large language model tokens through Azure OpenAI Service APIs. | ||
|
||
Notes: | ||
|
||
- Token count metrics include: Total Tokens, Prompt Tokens, and Completion Tokens. | ||
- This policy supports OpenAI response streaming! Use the [streaming tool](../../tools/streaming.ipynb) to test and troubleshoot response streaming. | ||
- Use the [tracing tool](../../tools/tracing.ipynb) to track the behavior and troubleshoot the [policy](policy.xml). | ||
|
||
[View policy configuration](policy.xml) | ||
|
||
### Result | ||
|
||
![result](result.png) | ||
|
||
### Prerequisites | ||
|
||
- [Python 3.12 or later version](https://www.python.org/) installed | ||
- [Pandas Library](https://pandas.pydata.org) installed | ||
- [VS Code](https://code.visualstudio.com/) installed with the [Jupyter notebook extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) enabled | ||
- [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed | ||
- [An Azure Subscription](https://azure.microsoft.com/free/) with Contributor permissions | ||
- [Access granted to Azure OpenAI](https://aka.ms/oai/access) | ||
- [Sign in to Azure with Azure CLI](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively) | ||
|
||
### 🚀 Get started | ||
|
||
Proceed by opening the [Jupyter notebook](token-metrics-emitting.ipynb), and follow the steps provided. | ||
|
||
### 🗑️ Clean up resources | ||
|
||
When you're finished with the lab, you should remove all your deployed resources from Azure to avoid extra charges and keep your Azure subscription uncluttered. | ||
Use the [clean-up-resources notebook](clean-up-resources.ipynb) for that. |
Oops, something went wrong.