From 7390eb2929ab81e8d79989b9beda763c21306a8d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 22:59:27 +0000 Subject: [PATCH 1/3] Initial plan From 22b32541cd1beef0285f55b4567d9549757f2457 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 23:05:06 +0000 Subject: [PATCH 2/3] Update multimodal input sample to document required environment variables Co-authored-by: dmytrostruk <13853051+dmytrostruk@users.noreply.github.com> --- .../multimodal_input/README.md | 37 +++++++++++++------ .../multimodal_input/azure_chat_multimodal.py | 3 ++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/python/samples/getting_started/multimodal_input/README.md b/python/samples/getting_started/multimodal_input/README.md index e4690724d2f..df3cf77667e 100644 --- a/python/samples/getting_started/multimodal_input/README.md +++ b/python/samples/getting_started/multimodal_input/README.md @@ -16,21 +16,34 @@ This folder contains examples demonstrating how to send multimodal content (imag - **Description**: Shows how to send multimodal content to Azure OpenAI service - **Supported formats**: PNG/JPEG images, WAV/MP3 audio, PDF documents -## Running the Examples +## Environment Variables + +Set the following environment variables before running the examples: + +**For OpenAI:** +- `OPENAI_API_KEY`: Your OpenAI API key + +**For Azure OpenAI:** +- `AZURE_OPENAI_ENDPOINT`: Your Azure OpenAI endpoint +- `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`: The name of your Azure OpenAI chat model deployment + +Optionally for Azure OpenAI: +- `AZURE_OPENAI_API_VERSION`: The API version to use (default is `2024-10-21`) +- `AZURE_OPENAI_API_KEY`: Your Azure OpenAI API key (if not using `AzureCliCredential`) -1. Set your API keys: +## Authentication - ```bash - export OPENAI_API_KEY="your-openai-key" - export AZURE_OPENAI_API_KEY="your-azure-key" - export AZURE_OPENAI_ENDPOINT="your-azure-endpoint" - ``` +The Azure example uses `AzureCliCredential` for authentication. Run `az login` in your terminal before running the example, or replace `AzureCliCredential` with your preferred authentication method (e.g., provide `api_key` parameter). -2. Run an example: - ```bash - python openai_chat_client_multimodal.py - python azure_chat_client_multimodal.py - ``` +## Running the Examples + +```bash +# Run OpenAI example +python openai_chat_multimodal.py + +# Run Azure example (requires az login or API key) +python azure_chat_multimodal.py +``` ## Using Your Own Files diff --git a/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py b/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py index ec31d8176db..81c26c88bf9 100644 --- a/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py +++ b/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py @@ -11,6 +11,9 @@ async def test_image() -> None: """Test image analysis with Azure.""" + # For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred + # authentication option. Requires AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_CHAT_DEPLOYMENT_NAME + # environment variables to be set. client = AzureOpenAIChatClient(credential=AzureCliCredential()) # Fetch image from httpbin From 3c86c313586f7b93e6af1eab7693fc2147a3787d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 23:06:42 +0000 Subject: [PATCH 3/3] Add examples showing how to pass deployment_name as parameter Co-authored-by: dmytrostruk <13853051+dmytrostruk@users.noreply.github.com> --- .../samples/getting_started/multimodal_input/README.md | 10 ++++++++++ .../multimodal_input/azure_chat_multimodal.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/python/samples/getting_started/multimodal_input/README.md b/python/samples/getting_started/multimodal_input/README.md index df3cf77667e..b4b99a58f79 100644 --- a/python/samples/getting_started/multimodal_input/README.md +++ b/python/samples/getting_started/multimodal_input/README.md @@ -31,6 +31,16 @@ Optionally for Azure OpenAI: - `AZURE_OPENAI_API_VERSION`: The API version to use (default is `2024-10-21`) - `AZURE_OPENAI_API_KEY`: Your Azure OpenAI API key (if not using `AzureCliCredential`) +**Note:** You can also provide configuration directly in code instead of using environment variables: +```python +# Example: Pass deployment_name directly +client = AzureOpenAIChatClient( + credential=AzureCliCredential(), + deployment_name="your-deployment-name", + endpoint="https://your-resource.openai.azure.com" +) +``` + ## Authentication The Azure example uses `AzureCliCredential` for authentication. Run `az login` in your terminal before running the example, or replace `AzureCliCredential` with your preferred authentication method (e.g., provide `api_key` parameter). diff --git a/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py b/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py index 81c26c88bf9..031ae09da2c 100644 --- a/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py +++ b/python/samples/getting_started/multimodal_input/azure_chat_multimodal.py @@ -14,6 +14,8 @@ async def test_image() -> None: # For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred # authentication option. Requires AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_CHAT_DEPLOYMENT_NAME # environment variables to be set. + # Alternatively, you can pass deployment_name explicitly: + # client = AzureOpenAIChatClient(credential=AzureCliCredential(), deployment_name="your-deployment-name") client = AzureOpenAIChatClient(credential=AzureCliCredential()) # Fetch image from httpbin