Skip to content

Commit b950db6

Browse files
committed
Azure OpenAI change
1 parent 9d8da38 commit b950db6

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

infra/main.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module aca 'aca.bicep' = {
123123
containerAppsEnvironmentName: containerApps.outputs.environmentName
124124
containerRegistryName: containerApps.outputs.registryName
125125
aiServicesDeploymentName: aiServicesDeploymentName
126-
aiServicesEndpoint: 'https://${aiServices.outputs.name}.services.ai.azure.com/openai/v1'
126+
aiServicesEndpoint: 'https://${aiServices.outputs.name}.services.ai.azure.com'
127127
exists: acaExists
128128
}
129129
}
@@ -167,7 +167,7 @@ output AZURE_LOCATION string = location
167167
output AZURE_TENANT_ID string = tenant().tenantId
168168

169169
output AZURE_DEEPSEEK_DEPLOYMENT string = aiServicesDeploymentName
170-
output AZURE_INFERENCE_ENDPOINT string = 'https://${aiServices.outputs.name}.services.ai.azure.com/openai/v1'
170+
output AZURE_INFERENCE_ENDPOINT string = 'https://${aiServices.outputs.name}.services.ai.azure.com'
171171

172172
output SERVICE_ACA_IDENTITY_PRINCIPAL_ID string = aca.outputs.identityPrincipalId
173173
output SERVICE_ACA_NAME string = aca.outputs.name

src/quartapp/chat.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import json
22
import os
33

4-
import httpx
54
from azure.core.credentials import AzureKeyCredential
65
from azure.identity.aio import AzureDeveloperCliCredential, ManagedIdentityCredential, get_bearer_token_provider
7-
from openai import AsyncOpenAI, DefaultAsyncHttpxClient
6+
from openai import AsyncAzureOpenAI
87
from quart import (
98
Blueprint,
109
Response,
@@ -37,21 +36,11 @@ async def configure_openai():
3736
bp.azure_credential, "https://cognitiveservices.azure.com/.default"
3837
)
3938

40-
class TokenBasedAuth(httpx.Auth):
41-
async def async_auth_flow(self, request):
42-
token = await openai_token_provider()
43-
request.headers["Authorization"] = f"Bearer {token}"
44-
yield request
45-
46-
def sync_auth_flow(self, request):
47-
raise RuntimeError("Cannot use a sync authentication class with httpx.AsyncClient")
48-
4939
# Create the Asynchronous Azure OpenAI client
50-
bp.openai_client = AsyncOpenAI(
51-
base_url=os.environ["AZURE_INFERENCE_ENDPOINT"],
52-
api_key="placeholder",
53-
default_query={"api-version": "preview"},
54-
http_client=DefaultAsyncHttpxClient(auth=TokenBasedAuth()),
40+
bp.openai_client = AsyncAzureOpenAI(
41+
azure_endpoint=os.environ["AZURE_INFERENCE_ENDPOINT"],
42+
azure_ad_token_provider=openai_token_provider,
43+
api_version="2025-04-01-preview", # temporary
5544
)
5645

5746
# Set the model name to the Azure OpenAI model deployment name

0 commit comments

Comments
 (0)