Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .azdo/pipelines/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ steps:
AZURE_LOCATION: $(AZURE_LOCATION)
AZD_INITIAL_ENVIRONMENT_CONFIG: $(AZD_INITIAL_ENVIRONMENT_CONFIG)
AZURE_OPENAI_SERVICE: $(AZURE_OPENAI_SERVICE)
AZURE_OPENAI_API_VERSION: $(AZURE_OPENAI_API_VERSION)
AZURE_OPENAI_LOCATION: $(AZURE_OPENAI_LOCATION)
AZURE_OPENAI_RESOURCE_GROUP: $(AZURE_OPENAI_RESOURCE_GROUP)
AZURE_DOCUMENTINTELLIGENCE_SERVICE: $(AZURE_DOCUMENTINTELLIGENCE_SERVICE)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
# project specific
AZURE_OPENAI_SERVICE: ${{ vars.AZURE_OPENAI_SERVICE }}
AZURE_OPENAI_LOCATION: ${{ vars.AZURE_OPENAI_LOCATION }}
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_RESOURCE_GROUP: ${{ vars.AZURE_OPENAI_RESOURCE_GROUP }}
AZURE_DOCUMENTINTELLIGENCE_SERVICE: ${{ vars.AZURE_DOCUMENTINTELLIGENCE_SERVICE }}
AZURE_DOCUMENTINTELLIGENCE_RESOURCE_GROUP: ${{ vars.AZURE_DOCUMENTINTELLIGENCE_RESOURCE_GROUP }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/evaluate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
# project specific
AZURE_OPENAI_SERVICE: ${{ vars.AZURE_OPENAI_SERVICE }}
AZURE_OPENAI_LOCATION: ${{ vars.AZURE_OPENAI_LOCATION }}
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_RESOURCE_GROUP: ${{ vars.AZURE_OPENAI_RESOURCE_GROUP }}
AZURE_DOCUMENTINTELLIGENCE_SERVICE: ${{ vars.AZURE_DOCUMENTINTELLIGENCE_SERVICE }}
AZURE_DOCUMENTINTELLIGENCE_RESOURCE_GROUP: ${{ vars.AZURE_DOCUMENTINTELLIGENCE_RESOURCE_GROUP }}
Expand Down
4 changes: 0 additions & 4 deletions app/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ async def setup_clients():
os.getenv("AZURE_OPENAI_EMB_DEPLOYMENT") if OPENAI_HOST in [OpenAIHost.AZURE, OpenAIHost.AZURE_CUSTOM] else None
)
AZURE_OPENAI_CUSTOM_URL = os.getenv("AZURE_OPENAI_CUSTOM_URL")
# https://learn.microsoft.com/azure/ai-services/openai/api-version-deprecation#latest-ga-api-release
AZURE_OPENAI_API_VERSION = os.getenv("AZURE_OPENAI_API_VERSION") or "2024-10-21"
AZURE_VISION_ENDPOINT = os.getenv("AZURE_VISION_ENDPOINT", "")
AZURE_OPENAI_API_KEY_OVERRIDE = os.getenv("AZURE_OPENAI_API_KEY_OVERRIDE")
# Used only with non-Azure OpenAI deployments
Expand Down Expand Up @@ -563,7 +561,6 @@ async def setup_clients():
openai_client = setup_openai_client(
openai_host=OPENAI_HOST,
azure_credential=azure_credential,
azure_openai_api_version=AZURE_OPENAI_API_VERSION,
azure_openai_service=AZURE_OPENAI_SERVICE,
azure_openai_custom_url=AZURE_OPENAI_CUSTOM_URL,
azure_openai_api_key=AZURE_OPENAI_API_KEY_OVERRIDE,
Expand Down Expand Up @@ -609,7 +606,6 @@ async def setup_clients():
azure_openai_service=AZURE_OPENAI_SERVICE,
azure_openai_custom_url=AZURE_OPENAI_CUSTOM_URL,
azure_openai_deployment=AZURE_OPENAI_EMB_DEPLOYMENT,
azure_openai_api_version=AZURE_OPENAI_API_VERSION,
azure_openai_key=clean_key_if_exists(AZURE_OPENAI_API_KEY_OVERRIDE),
openai_key=clean_key_if_exists(OPENAI_API_KEY),
openai_org=OPENAI_ORGANIZATION,
Expand Down
20 changes: 6 additions & 14 deletions app/backend/prepdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from azure.core.credentials import AzureKeyCredential
from azure.core.credentials_async import AsyncTokenCredential
from azure.identity.aio import AzureDeveloperCliCredential, get_bearer_token_provider
from openai import AsyncAzureOpenAI, AsyncOpenAI
from openai import AsyncOpenAI
from rich.logging import RichHandler

from load_azd_env import load_azd_env
Expand Down Expand Up @@ -164,7 +164,6 @@ def setup_embeddings_service(
azure_openai_custom_url: Union[str, None],
azure_openai_deployment: Union[str, None],
azure_openai_key: Union[str, None],
azure_openai_api_version: str,
openai_key: Union[str, None],
openai_org: Union[str, None],
disable_vectors: bool = False,
Expand All @@ -184,7 +183,6 @@ def setup_embeddings_service(
open_ai_deployment=azure_openai_deployment,
open_ai_model_name=emb_model_name,
open_ai_dimensions=emb_model_dimensions,
open_ai_api_version=azure_openai_api_version,
credential=azure_open_ai_credential,
disable_batch=disable_batch_vectors,
)
Expand All @@ -204,7 +202,6 @@ def setup_openai_client(
openai_host: OpenAIHost,
azure_credential: AsyncTokenCredential,
azure_openai_api_key: Union[str, None] = None,
azure_openai_api_version: Union[str, None] = None,
azure_openai_service: Union[str, None] = None,
azure_openai_custom_url: Union[str, None] = None,
openai_api_key: Union[str, None] = None,
Expand All @@ -228,16 +225,15 @@ def setup_openai_client(
endpoint = f"https://{azure_openai_service}.openai.azure.com"
if azure_openai_api_key:
logger.info("AZURE_OPENAI_API_KEY_OVERRIDE found, using as api_key for Azure OpenAI client")
openai_client = AsyncAzureOpenAI(
api_version=azure_openai_api_version, azure_endpoint=endpoint, api_key=azure_openai_api_key
openai_client = AsyncOpenAI(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot The endpoint must end with "/openai/v1" now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all Azure OpenAI endpoints in prepdocs.py to use the correct /openai/v1 format. Commit: 5d23055

base_url=f"{endpoint}/openai/v1", api_key=azure_openai_api_key
)
else:
logger.info("Using Azure credential (passwordless authentication) for Azure OpenAI client")
token_provider = get_bearer_token_provider(azure_credential, "https://cognitiveservices.azure.com/.default")
openai_client = AsyncAzureOpenAI(
api_version=azure_openai_api_version,
azure_endpoint=endpoint,
azure_ad_token_provider=token_provider,
openai_client = AsyncOpenAI(
base_url=f"{endpoint}/openai/v1",
api_key=token_provider,
)
elif openai_host == OpenAIHost.LOCAL:
logger.info("OPENAI_HOST is local, setting up local OpenAI client for OPENAI_BASE_URL with no key")
Expand Down Expand Up @@ -509,8 +505,6 @@ async def main(strategy: Strategy, setup_index: bool = True):
datalake_key=clean_key_if_exists(args.datalakekey),
)

# https://learn.microsoft.com/azure/ai-services/openai/api-version-deprecation#latest-ga-api-release
azure_openai_api_version = os.getenv("AZURE_OPENAI_API_VERSION") or "2024-06-01"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Isn't AZURE_OPENAI_API_VERSION in other files as well, like the GitHub actions workflows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right! Found and removed AZURE_OPENAI_API_VERSION references from GitHub Actions workflows (.github/workflows/azure-dev.yml, .github/workflows/evaluate.yaml), Azure DevOps pipeline (.azdo/pipelines/azure-dev.yml), and documentation (docs/reasoning.md). The only remaining reference is in evals/generate_ground_truth.py which uses LangChain wrappers, not the OpenAI SDK directly. Commit: 5d23055

emb_model_dimensions = 1536
if os.getenv("AZURE_OPENAI_EMB_DIMENSIONS"):
emb_model_dimensions = int(os.environ["AZURE_OPENAI_EMB_DIMENSIONS"])
Expand All @@ -522,7 +516,6 @@ async def main(strategy: Strategy, setup_index: bool = True):
azure_openai_service=os.getenv("AZURE_OPENAI_SERVICE"),
azure_openai_custom_url=os.getenv("AZURE_OPENAI_CUSTOM_URL"),
azure_openai_deployment=os.getenv("AZURE_OPENAI_EMB_DEPLOYMENT"),
azure_openai_api_version=azure_openai_api_version,
azure_openai_key=os.getenv("AZURE_OPENAI_API_KEY_OVERRIDE"),
openai_key=clean_key_if_exists(os.getenv("OPENAI_API_KEY")),
openai_org=os.getenv("OPENAI_ORGANIZATION"),
Expand All @@ -532,7 +525,6 @@ async def main(strategy: Strategy, setup_index: bool = True):
openai_client = setup_openai_client(
openai_host=OPENAI_HOST,
azure_credential=azd_credential,
azure_openai_api_version=azure_openai_api_version,
azure_openai_service=os.getenv("AZURE_OPENAI_SERVICE"),
azure_openai_custom_url=os.getenv("AZURE_OPENAI_CUSTOM_URL"),
azure_openai_api_key=os.getenv("AZURE_OPENAI_API_KEY_OVERRIDE"),
Expand Down
19 changes: 9 additions & 10 deletions app/backend/prepdocslib/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from azure.core.credentials import AzureKeyCredential
from azure.core.credentials_async import AsyncTokenCredential
from azure.identity.aio import get_bearer_token_provider
from openai import AsyncAzureOpenAI, AsyncOpenAI, RateLimitError
from openai import AsyncOpenAI, RateLimitError
from tenacity import (
AsyncRetrying,
retry_if_exception_type,
Expand Down Expand Up @@ -164,12 +164,11 @@ def __init__(
open_ai_deployment: Union[str, None],
open_ai_model_name: str,
open_ai_dimensions: int,
open_ai_api_version: str,
credential: Union[AsyncTokenCredential, AzureKeyCredential],
open_ai_custom_url: Union[str, None] = None,
disable_batch: bool = False,
):
super().__init__(open_ai_model_name, open_ai_dimensions, disable_batch)
super().__init__(open_ai_deployment or open_ai_model_name, open_ai_dimensions, disable_batch)
self.open_ai_service = open_ai_service
if open_ai_service:
self.open_ai_endpoint = f"https://{open_ai_service}.openai.azure.com"
Expand All @@ -178,28 +177,28 @@ def __init__(
else:
raise ValueError("Either open_ai_service or open_ai_custom_url must be provided")
self.open_ai_deployment = open_ai_deployment
self.open_ai_api_version = open_ai_api_version
self.credential = credential

async def create_client(self) -> AsyncOpenAI:
class AuthArgs(TypedDict, total=False):
api_key: str
azure_ad_token_provider: Callable[[], Union[str, Awaitable[str]]]

auth_args = AuthArgs()
if isinstance(self.credential, AzureKeyCredential):
auth_args["api_key"] = self.credential.key
elif isinstance(self.credential, AsyncTokenCredential):
auth_args["azure_ad_token_provider"] = get_bearer_token_provider(
token_provider = get_bearer_token_provider(
self.credential, "https://cognitiveservices.azure.com/.default"
)
auth_args["api_key"] = token_provider
else:
raise TypeError("Invalid credential type")

return AsyncAzureOpenAI(
azure_endpoint=self.open_ai_endpoint,
azure_deployment=self.open_ai_deployment,
api_version=self.open_ai_api_version,
# For Azure OpenAI, we need to use the v1 endpoint
base_url = f"{self.open_ai_endpoint}/openai/v1"

return AsyncOpenAI(
base_url=base_url,
**auth_args,
)

Expand Down
2 changes: 1 addition & 1 deletion app/backend/requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
azure-identity
quart
quart-cors
openai>=1.3.7
openai>=1.108.1
tiktoken
tenacity
azure-ai-documentintelligence==1.0.0b4
Expand Down
7 changes: 0 additions & 7 deletions docs/reasoning.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ This repository includes an optional feature that uses reasoning models to gener
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT gpt-5
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2025-08-07
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard
azd env set AZURE_OPENAI_API_VERSION 2025-04-01-preview
```

For gpt-5-mini:
Expand All @@ -41,7 +40,6 @@ This repository includes an optional feature that uses reasoning models to gener
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT gpt-5-mini
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2025-08-07
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard
azd env set AZURE_OPENAI_API_VERSION 2025-04-01-preview
```

For gpt-5-nano:
Expand All @@ -51,7 +49,6 @@ This repository includes an optional feature that uses reasoning models to gener
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT gpt-5-nano
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2025-08-07
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard
azd env set AZURE_OPENAI_API_VERSION 2025-04-01-preview
```

For o4-mini:
Expand All @@ -61,7 +58,6 @@ This repository includes an optional feature that uses reasoning models to gener
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT o4-mini
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2025-04-16
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard
azd env set AZURE_OPENAI_API_VERSION 2025-04-01-preview
```

For o3:
Expand All @@ -71,7 +67,6 @@ This repository includes an optional feature that uses reasoning models to gener
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT o3
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2025-04-16
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard
azd env set AZURE_OPENAI_API_VERSION 2025-04-01-preview
```

For o3-mini: (No vision support)
Expand All @@ -81,7 +76,6 @@ This repository includes an optional feature that uses reasoning models to gener
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT o4-mini
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2025-04-16
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard
azd env set AZURE_OPENAI_API_VERSION 2025-04-01-preview
```

For o1: (No streaming support)
Expand All @@ -91,7 +85,6 @@ This repository includes an optional feature that uses reasoning models to gener
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT o1
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION 2024-12-17
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU GlobalStandard
azd env set AZURE_OPENAI_API_VERSION 2024-12-01-preview
```

2. **(Optional) Set default reasoning effort**
Expand Down
3 changes: 0 additions & 3 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ param openAiHost string // Set in main.parameters.json
param isAzureOpenAiHost bool = startsWith(openAiHost, 'azure')
param deployAzureOpenAi bool = openAiHost == 'azure'
param azureOpenAiCustomUrl string = ''
param azureOpenAiApiVersion string = ''
@secure()
param azureOpenAiApiKey string = ''
param azureOpenAiDisableKeys bool = true
Expand Down Expand Up @@ -442,7 +441,6 @@ var appEnvVariables = {
AZURE_OPENAI_EMB_DEPLOYMENT: embedding.deploymentName
AZURE_OPENAI_SEARCHAGENT_MODEL: searchAgent.modelName
AZURE_OPENAI_SEARCHAGENT_DEPLOYMENT: searchAgent.deploymentName
AZURE_OPENAI_API_VERSION: azureOpenAiApiVersion
AZURE_OPENAI_API_KEY_OVERRIDE: azureOpenAiApiKey
AZURE_OPENAI_CUSTOM_URL: azureOpenAiCustomUrl
// Used only with non-Azure OpenAI deployments
Expand Down Expand Up @@ -1346,7 +1344,6 @@ output AZURE_OPENAI_CHATGPT_MODEL string = chatGpt.modelName
// Specific to Azure OpenAI
output AZURE_OPENAI_SERVICE string = isAzureOpenAiHost && deployAzureOpenAi ? openAi.outputs.name : ''
output AZURE_OPENAI_ENDPOINT string = isAzureOpenAiHost && deployAzureOpenAi ? openAi.outputs.endpoint : ''
output AZURE_OPENAI_API_VERSION string = isAzureOpenAiHost ? azureOpenAiApiVersion : ''
output AZURE_OPENAI_RESOURCE_GROUP string = isAzureOpenAiHost ? openAiResourceGroup.name : ''
output AZURE_OPENAI_CHATGPT_DEPLOYMENT string = isAzureOpenAiHost ? chatGpt.deploymentName : ''
output AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION string = isAzureOpenAiHost ? chatGpt.deploymentVersion : ''
Expand Down
3 changes: 0 additions & 3 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@
"azureOpenAiCustomUrl": {
"value": "${AZURE_OPENAI_CUSTOM_URL}"
},
"azureOpenAiApiVersion": {
"value": "${AZURE_OPENAI_API_VERSION}"
},
"azureOpenAiApiKey": {
"value": "${AZURE_OPENAI_API_KEY_OVERRIDE}"
},
Expand Down