A programming framework for agentic AI
Add doc about how to use aad for model client (#38)
Jack Gerrits7bfd182a0f25
diff --git a/docs/src/conf.py b/docs/src/conf.pyindex 0560ff78f..aca8349b4 100644--- a/docs/src/conf.py+++ b/docs/src/conf.py@@ -17,7 +17,8 @@ extensions = ["sphinx.ext.autodoc","sphinx.ext.autosummary","sphinx.ext.napoleon",- "sphinxcontrib.apidoc"+ "sphinxcontrib.apidoc",+ "myst_parser"]apidoc_module_dir = '../../src/agnext'diff --git a/docs/src/guides/azure_openai_with_aad_auth.md b/docs/src/guides/azure_openai_with_aad_auth.mdnew file mode 100644index 000000000..689158bdb--- /dev/null+++ b/docs/src/guides/azure_openai_with_aad_auth.md@@ -0,0 +1,41 @@+# Azure OpenAI with AAD Auth++This guide will show you how to use the Azure OpenAI client with Azure Active Directory (AAD) authentication.++The identity used must be assigned the [**Cognitive Services OpenAI User**](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/role-based-access-control#cognitive-services-openai-user) role.++## Install Azure Identity client++The Azure identity client is used to authenticate with Azure Active Directory.++```sh+pip install azure-identity+```++## Using the Model Client++```python+from agnext.agent_components.model_client import AzureOpenAI+from azure.identity import DefaultAzureCredential, get_bearer_token_provider++# Create the token provider+token_provider = get_bearer_token_provider(+ DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"+)++client = AzureOpenAI(+ model="{your-azure-deployment}",+ api_version="2024-02-01",+ azure_endpoint="https://{your-custom-endpoint}.openai.azure.com/",+ azure_ad_token_provider=token_provider,+ model_capabilities={+ "vision":True,+ "function_calling":True,+ "json_output":True,+ }+)+```++```{note}+See [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/managed-identity#chat-completions) for how to use the Azure client directly or for more info.+```diff --git a/docs/src/index.rst b/docs/src/index.rstindex 8aedc84e3..d0700142e 100644--- a/docs/src/index.rst+++ b/docs/src/index.rst@@ -1,6 +1,13 @@agnext------+.. toctree::+ :caption: Guides+ :hidden:++ guides/azure_openai_with_aad_auth++.. toctree:::caption: Reference:hidden:diff --git a/pyproject.toml b/pyproject.tomlindex 7545797c5..765a7af1f 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -32,7 +32,7 @@ dev = ["types-Pillow","polars",]-docs = ["sphinx", "furo", "sphinxcontrib-apidoc"]+docs = ["sphinx", "furo", "sphinxcontrib-apidoc", "myst-parser"][tool.setuptools.package-data]agnext = ["py.typed"]