Skip to content

Commit

Permalink
Merge branch 'main' into fts-query
Browse files Browse the repository at this point in the history
  • Loading branch information
simorenoh committed Nov 15, 2024
2 parents c2242eb + 4c67ca7 commit efce422
Show file tree
Hide file tree
Showing 1,410 changed files with 27,461 additions and 1,325,564 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# ServiceLabel: %AI

# PRLabel: %AI
/sdk/ai/ @luigiw @needuv @achauhan-scc @kingernupur @paulshealy1 @singankit
/sdk/ai/ @luigiw @needuv @achauhan-scc @kingernupur @paulshealy1 @singankit @dargilco @jhakulin

# ServiceOwners: @luigiw @needuv @singankit
# ServiceLabel: %Evaluation
Expand Down
3 changes: 2 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,8 @@
"aiservices",
"OTEL",
"GENAI",
"fspath"
"fspath",
"azureopenai"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion common/smoketest/test-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,4 @@
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value, ';EndpointSuffix=', parameters('storageEndpointSuffix'))]"
}
}
}
}
4 changes: 3 additions & 1 deletion eng/pipelines/templates/steps/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ steps:
condition: and(succeeded(), eq(variables['TestSamples'], 'true'))
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
# Enable samples tests that use DefaultAzureCredential to load the federated pipeline credential
AZURE_POD_IDENTITY_AUTHORITY_HOST: 'https://FakeAuthorityHost'
${{ insert }}: ${{ parameters.EnvVars }}
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
azureSubscription: azure-sdk-tests-public
azurePowerShellVersion: LatestVersion
pwsh: true
ScriptType: InlineScript
Expand Down
6 changes: 6 additions & 0 deletions sdk/ai/azure-ai-inference/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 1.0.0b7 (Unreleased)

### Bugs Fixed

* Fix a bug that would cause an error when tracing was enabled and azure-core-tracing-opentelemetry was not installed and asynchronous chat completion was used.

## 1.0.0b6 (2024-11-11)

### Features Added
Expand Down
2 changes: 1 addition & 1 deletion sdk/ai/azure-ai-inference/azure/ai/inference/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "1.0.0b6"
VERSION = "1.0.0b7"
457 changes: 361 additions & 96 deletions sdk/ai/azure-ai-projects/README.md

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from os import PathLike
from pathlib import Path
from typing import Any, Dict, List, Tuple, Union

from typing_extensions import Self

from azure.core import PipelineClient
Expand Down Expand Up @@ -69,7 +68,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2020-02-02",
credential_scopes=["https://management.azure.com"],
credential_scopes=["https://management.azure.com/.default"],
**kwargs0,
)

Expand Down Expand Up @@ -107,7 +106,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2024-07-01-preview",
credential_scopes=["https://management.azure.com"],
credential_scopes=["https://management.azure.com/.default"],
**kwargs1,
)
_policies1 = kwargs1.pop("policies", None)
Expand Down Expand Up @@ -138,7 +137,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2024-07-01-preview", # TODO: Update me
credential_scopes=["https://ml.azure.com"],
credential_scopes=["https://ml.azure.com/.default"],
**kwargs2,
)
_policies2 = kwargs2.pop("policies", None)
Expand Down Expand Up @@ -170,7 +169,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2024-07-01-preview", # TODO: Update me
credential_scopes=["https://ml.azure.com"], # TODO: Update once service changes are ready
credential_scopes=["https://ml.azure.com/.default"], # TODO: Update once service changes are ready
**kwargs3,
)
_policies3 = kwargs3.pop("policies", None)
Expand Down Expand Up @@ -224,7 +223,7 @@ def __exit__(self, *exc_details: Any) -> None:
self._client3.__exit__(*exc_details)

@classmethod
def from_connection_string(cls, conn_str: str, credential: "TokenCredential", **kwargs) -> "AIProjectClient":
def from_connection_string(cls, conn_str: str, credential: "TokenCredential", **kwargs) -> Self:
"""
Create an AIProjectClient from a connection string.
Expand Down
11 changes: 5 additions & 6 deletions sdk/ai/azure-ai-projects/azure/ai/projects/aio/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from os import PathLike
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union

from typing_extensions import Self

from azure.core import AsyncPipelineClient
Expand Down Expand Up @@ -75,7 +74,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2020-02-02",
credential_scopes=["https://management.azure.com"],
credential_scopes=["https://management.azure.com/.default"],
**kwargs0,
)

Expand Down Expand Up @@ -107,7 +106,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2024-07-01-preview",
credential_scopes=["https://management.azure.com"],
credential_scopes=["https://management.azure.com/.default"],
**kwargs1,
)
_policies1 = kwargs1.pop("policies", None)
Expand Down Expand Up @@ -138,7 +137,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2024-07-01-preview", # TODO: Update me
credential_scopes=["https://ml.azure.com"],
credential_scopes=["https://ml.azure.com/.default"],
**kwargs2,
)
_policies2 = kwargs2.pop("policies", None)
Expand Down Expand Up @@ -170,7 +169,7 @@ def __init__( # pylint: disable=super-init-not-called,too-many-statements
project_name=project_name,
credential=credential,
api_version="2024-07-01-preview", # TODO: Update me
credential_scopes=["https://ml.azure.com"], # TODO: Update once service changes are ready
credential_scopes=["https://ml.azure.com/.default"], # TODO: Update once service changes are ready
**kwargs3,
)
_policies3 = kwargs3.pop("policies", None)
Expand Down Expand Up @@ -224,7 +223,7 @@ async def __aexit__(self, *exc_details: Any) -> None:
await self._client3.__aexit__(*exc_details)

@classmethod
def from_connection_string(cls, conn_str: str, credential: "AsyncTokenCredential", **kwargs) -> "AIProjectClient":
def from_connection_string(cls, conn_str: str, credential: "AsyncTokenCredential", **kwargs) -> Self:
"""
Create an asynchronous AIProjectClient from a connection string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async def get_azure_openai_client(self, *, api_version: Optional[str] = None, **
:keyword api_version: The Azure OpenAI api-version to use when creating the client. Optional.
See "Data plane - Inference" row in the table at
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs. If this keyword
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs. If this keyword
is not specified, you must set the environment variable `OPENAI_API_VERSION` instead.
:paramtype api_version: str
:return: An authenticated AsyncAzureOpenAI client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def get_azure_openai_client(self, *, api_version: Optional[str] = None, **kwargs
:keyword api_version: The Azure OpenAI api-version to use when creating the client. Optional.
See "Data plane - Inference" row in the table at
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs. If this keyword
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs. If this keyword
is not specified, you must set the environment variable `OPENAI_API_VERSION` instead.
:paramtype api_version: str
:return: An authenticated AzureOpenAI client
Expand Down Expand Up @@ -253,7 +253,7 @@ def get_azure_openai_client(self, *, api_version: Optional[str] = None, **kwargs
auth = "Creating AzureOpenAI using SAS authentication"
logger.debug("[InferenceOperations.get_azure_openai_client] %s", auth)
client = AzureOpenAI(
# See https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider # pylint: disable=line-too-long
# See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider # pylint: disable=line-too-long
azure_ad_token_provider=get_bearer_token_provider(
connection.token_credential, "https://cognitiveservices.azure.com/.default"
),
Expand Down
7 changes: 1 addition & 6 deletions sdk/ai/azure-ai-projects/azure_ai_projects_tests.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
# but do not commit these changes to the repository.
#

# The default here should be to run tests from recordings:
AZURE_TEST_RUN_LIVE=false
AZURE_SKIP_LIVE_RECORDING=true
PROXY_URL=http://localhost:5000

########################################################################################################################
# Connection tests
#
Expand All @@ -35,7 +30,7 @@ AZURE_AI_PROJECTS_CONNECTIONS_TESTS_AISERVICES_CONNECTION_NAME=
# - A default AIServices resource with at least one chat-completions model deployed (from OpenAI or non-OpenAI)
# - A default Azure OpenAI resource connected with at least one chat-completions OpenAI model deployed
# Populate the Azure OpenAI api-version and model deployment names below.
# Note: See Azure OpenAI api-versions here: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
# Note: See Azure OpenAI api-versions here: https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
#
AZURE_AI_PROJECTS_INFERENCE_TESTS_PROJECT_CONNECTION_STRING=
AZURE_AI_PROJECTS_INFERENCE_TESTS_AOAI_API_VERSION=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ async def sample_connections_async() -> None:
aoai_client = AsyncAzureOpenAI(
api_key=connection.key,
azure_endpoint=connection.endpoint_url,
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
)
elif connection.authentication_type == AuthenticationType.ENTRA_ID:
print("====> Creating AzureOpenAI client using Entra ID authentication")
from azure.identity.aio import get_bearer_token_provider

aoai_client = AsyncAzureOpenAI(
# See https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider
# See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider
azure_ad_token_provider=get_bearer_token_provider(
cast(AsyncTokenCredential, connection.token_credential),
"https://cognitiveservices.azure.com/.default",
),
azure_endpoint=connection.endpoint_url,
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
)
else:
raise ValueError(f"Authentication type {connection.authentication_type} not supported.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,20 @@
aoai_client = AzureOpenAI(
api_key=connection.key,
azure_endpoint=connection.endpoint_url,
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
)
elif connection.authentication_type == AuthenticationType.ENTRA_ID:
print("====> Creating AzureOpenAI client using Entra ID authentication")
from azure.core.credentials import TokenCredential
from azure.identity import get_bearer_token_provider

aoai_client = AzureOpenAI(
# See https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider
# See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider
azure_ad_token_provider=get_bearer_token_provider(
cast(TokenCredential, connection.token_credential), "https://cognitiveservices.azure.com/.default"
),
azure_endpoint=connection.endpoint_url,
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
)
else:
raise ValueError(f"Authentication type {connection.authentication_type} not supported.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
Before running the sample:
pip install azure-identity
pip install "git+https://github.com/Azure/azure-sdk-for-python.git@users/singankit/ai_project_utils#egg=azure-ai-client&subdirectory=sdk/ai/azure-ai-client"
pip install "git+https://github.com/Azure/azure-sdk-for-python.git@users/singankit/demo_evaluators_id#egg=azure-ai-evaluation&subdirectory=sdk/evaluation/azure-ai-evaluation"
pip install azure-ai-projects
pip install azure-ai-evaluation
Set this environment variables with your own values:
PROJECT_CONNECTION_STRING - the Azure AI Project connection string, as found in your AI Studio Project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* MODEL_DEPLOYMENT_NAME - The model deployment name, as found in your AI Studio Project.
Update the Azure OpenAI api-version as needed (see `api_version=` below). Values can be found here:
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
"""
import os
import asyncio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* MODEL_DEPLOYMENT_NAME - The model deployment name, as found in your AI Studio Project.
Update the Azure OpenAI api-version as needed (see `api_version=` below). Values can be found here:
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
"""
import os
from azure.ai.projects import AIProjectClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
messages, which may contain personal data. False by default.
Update the Azure OpenAI api-version as needed (see `api_version=` below). Values can be found here:
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
"""
import os
from azure.ai.projects import AIProjectClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
messages, which may contain personal data. False by default.
Update the Azure OpenAI api-version as needed (see `api_version=` below). Values can be found here:
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
"""
import os
import sys
Expand Down
2 changes: 1 addition & 1 deletion sdk/ai/azure-ai-projects/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
license="MIT License",
author="Microsoft Corporation",
author_email="[email protected]",
url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk",
url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/ai/azure-ai-projects",
keywords="azure, azure sdk",
classifiers=[
"Development Status :: 4 - Beta",
Expand Down
43 changes: 16 additions & 27 deletions sdk/ai/azure-ai-projects/tests/README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,34 @@
# Azure AI Project client library tests for Python

The instructions below are for running tests locally, on a Windows machine, against the live service.
The instructions below are for running tests locally, on a Windows machine, against the live service using a local build of the client library.

## Build and install the client library

- Clone or download this sample repository.
- Open a command prompt window in the folder `sdk\ai\azure-ai-projects`
- If you want to run tests against the latest published client library, install it by running:
```bash
pip install azure-ai-projects
```
- If you want to run tests against a locally built client library:
- First build the wheel:
```bash
pip install wheel
pip install -r dev_requirements.txt
python setup.py bdist_wheel
```
- Then install the resulting local wheel (update version `1.0.0b1` to the current one):
```bash
pip install dist\azure_ai_projects-1.0.0b1-py3-none-any.whl --user --force-reinstall
```
- Install development dependencies:
```bash
pip install -r dev_requirements.txt
```
- Build the package:
```bash
pip install wheel
python setup.py bdist_wheel
```
- Install the resulting wheel (update version `1.0.0b1` to the current one):
```bash
pip install dist\azure_ai_projects-1.0.0b1-py3-none-any.whl --user --force-reinstall
```

## Log in to Azure

```bash
az login
```

## Setup for running tests in the `agents` folder
## Setup up environment variables

**Note:** The environment variables required by the test are defined in `agentClientPreparer`. **It is important project name to be the part of environment variable!** For example, the project is `azure_ai_projects` and the variable may be called `azure_ai_projects_connection_string`. The variables without `azure_ai_projects` substrings will be ignored according to logic of `EnvironmentVariableLoader`. The values of these variables will be supplied to kwargs of the unit tests, decorated by `EnvironmentVariableLoader` function.

```bash
set AZURE_AI_PROJECTS_CONNECTION_STRING=<your_connection_string>
set AZURE_AI_PROJECTS_DATA_PATH=<your_blob_containing_product_info_1.md_from_samples>
```

## Setup for running tests in the `evaluations` folder

## Setup for running tests in the `connections` and `inference` folders
Edit the file `azure_ai_projects_tests.env` located in the folder above. Follow the instructions there on how to set up Azure AI Studio projects to be used for testing, and enter appropriate values for the environment variables used for the tests you want to run.

## Configure test proxy

Expand Down
2 changes: 1 addition & 1 deletion sdk/ai/azure-ai-projects/tests/inference/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_inference_get_azure_openai_client(self, **kwargs):
api_version = kwargs.pop("azure_ai_projects_inference_tests_aoai_api_version")
model = kwargs.pop("azure_ai_projects_inference_tests_aoai_model_deployment_name")
with self.get_sync_client(**kwargs) as project_client:
# See API versions in https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
# See API versions in https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
with project_client.inference.get_azure_openai_client(api_version=api_version) as azure_openai_client:
if is_live_and_not_recording():
response = azure_openai_client.chat.completions.create(
Expand Down
Loading

0 comments on commit efce422

Please sign in to comment.