Skip to content

Feature/move agent samples and doc #41514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
12 changes: 12 additions & 0 deletions sdk/ai/azure-ai-projects/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Release History

## 1.0.0b12 (Unreleased)

### Features added

### Breaking changes

### Bugs Fixed

* Fix for enable_telemetry to correctly instrument azure-ai-agents

### Sample updates

## 1.0.0b11 (2025-05-15)

There have been significant updates with the release of version 1.0.0b11, including breaking changes.
Expand Down
521 changes: 1 addition & 520 deletions sdk/ai/azure-ai-projects/README.md

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions sdk/ai/azure-ai-projects/apiview-properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,30 @@
"azure.ai.projects.aio.operations.EvaluationsOperations.create": "Azure.AI.Projects.Evaluations.create",
"azure.ai.projects.operations.EvaluationsOperations.create_agent_evaluation": "Azure.AI.Projects.Evaluations.createAgentEvaluation",
"azure.ai.projects.aio.operations.EvaluationsOperations.create_agent_evaluation": "Azure.AI.Projects.Evaluations.createAgentEvaluation",
"azure.ai.projects.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.ServicePatterns.Datasets.listVersions",
"azure.ai.projects.aio.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.ServicePatterns.Datasets.listVersions",
"azure.ai.projects.operations.DatasetsOperations.list": "Azure.AI.Projects.ServicePatterns.Datasets.listLatest",
"azure.ai.projects.aio.operations.DatasetsOperations.list": "Azure.AI.Projects.ServicePatterns.Datasets.listLatest",
"azure.ai.projects.operations.DatasetsOperations.get": "Azure.AI.Projects.ServicePatterns.Datasets.getVersion",
"azure.ai.projects.aio.operations.DatasetsOperations.get": "Azure.AI.Projects.ServicePatterns.Datasets.getVersion",
"azure.ai.projects.operations.DatasetsOperations.delete": "Azure.AI.Projects.ServicePatterns.Datasets.deleteVersion",
"azure.ai.projects.aio.operations.DatasetsOperations.delete": "Azure.AI.Projects.ServicePatterns.Datasets.deleteVersion",
"azure.ai.projects.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.ServicePatterns.Datasets.createOrUpdateVersion",
"azure.ai.projects.aio.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.ServicePatterns.Datasets.createOrUpdateVersion",
"azure.ai.projects.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.Datasets.listVersions",
"azure.ai.projects.aio.operations.DatasetsOperations.list_versions": "Azure.AI.Projects.Datasets.listVersions",
"azure.ai.projects.operations.DatasetsOperations.list": "Azure.AI.Projects.Datasets.listLatest",
"azure.ai.projects.aio.operations.DatasetsOperations.list": "Azure.AI.Projects.Datasets.listLatest",
"azure.ai.projects.operations.DatasetsOperations.get": "Azure.AI.Projects.Datasets.getVersion",
"azure.ai.projects.aio.operations.DatasetsOperations.get": "Azure.AI.Projects.Datasets.getVersion",
"azure.ai.projects.operations.DatasetsOperations.delete": "Azure.AI.Projects.Datasets.deleteVersion",
"azure.ai.projects.aio.operations.DatasetsOperations.delete": "Azure.AI.Projects.Datasets.deleteVersion",
"azure.ai.projects.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.Datasets.createOrUpdateVersion",
"azure.ai.projects.aio.operations.DatasetsOperations.create_or_update": "Azure.AI.Projects.Datasets.createOrUpdateVersion",
"azure.ai.projects.operations.DatasetsOperations.pending_upload": "Azure.AI.Projects.Datasets.startPendingUploadVersion",
"azure.ai.projects.aio.operations.DatasetsOperations.pending_upload": "Azure.AI.Projects.Datasets.startPendingUploadVersion",
"azure.ai.projects.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials",
"azure.ai.projects.aio.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials",
"azure.ai.projects.operations.IndexesOperations.list_versions": "Azure.AI.Projects.ServicePatterns.Indexes.listVersions",
"azure.ai.projects.aio.operations.IndexesOperations.list_versions": "Azure.AI.Projects.ServicePatterns.Indexes.listVersions",
"azure.ai.projects.operations.IndexesOperations.list": "Azure.AI.Projects.ServicePatterns.Indexes.listLatest",
"azure.ai.projects.aio.operations.IndexesOperations.list": "Azure.AI.Projects.ServicePatterns.Indexes.listLatest",
"azure.ai.projects.operations.IndexesOperations.get": "Azure.AI.Projects.ServicePatterns.Indexes.getVersion",
"azure.ai.projects.aio.operations.IndexesOperations.get": "Azure.AI.Projects.ServicePatterns.Indexes.getVersion",
"azure.ai.projects.operations.IndexesOperations.delete": "Azure.AI.Projects.ServicePatterns.Indexes.deleteVersion",
"azure.ai.projects.aio.operations.IndexesOperations.delete": "Azure.AI.Projects.ServicePatterns.Indexes.deleteVersion",
"azure.ai.projects.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.ServicePatterns.Indexes.createOrUpdateVersion",
"azure.ai.projects.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.ServicePatterns.Indexes.createOrUpdateVersion",
"azure.ai.projects.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions",
"azure.ai.projects.aio.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions",
"azure.ai.projects.operations.IndexesOperations.list": "Azure.AI.Projects.Indexes.listLatest",
"azure.ai.projects.aio.operations.IndexesOperations.list": "Azure.AI.Projects.Indexes.listLatest",
"azure.ai.projects.operations.IndexesOperations.get": "Azure.AI.Projects.Indexes.getVersion",
"azure.ai.projects.aio.operations.IndexesOperations.get": "Azure.AI.Projects.Indexes.getVersion",
"azure.ai.projects.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion",
"azure.ai.projects.aio.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion",
"azure.ai.projects.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion",
"azure.ai.projects.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion",
"azure.ai.projects.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get",
"azure.ai.projects.aio.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get",
"azure.ai.projects.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list",
Expand Down
6 changes: 6 additions & 0 deletions sdk/ai/azure-ai-projects/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/ai/azure-ai-projects",
"Tag": "python/ai/azure-ai-projects_25a915bc4c"
}
2 changes: 1 addition & 1 deletion sdk/ai/azure-ai-projects/azure/ai/projects/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from azure.core.credentials import TokenCredential


class AIProjectClient: # pylint: disable=too-many-instance-attributes
class AIProjectClient:
"""AIProjectClient.

:ivar connections: ConnectionsOperations operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def enable_telemetry(
)

try:
from azure.ai.agents.tracing import AIAgentsInstrumentor # pylint: disable=import-error,no-name-in-module
from azure.ai.agents.telemetry import AIAgentsInstrumentor # pylint: disable=import-error,no-name-in-module

agents_instrumentor = AIAgentsInstrumentor()
if not agents_instrumentor.is_instrumented():
Expand Down
2 changes: 1 addition & 1 deletion sdk/ai/azure-ai-projects/azure/ai/projects/_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.0b11"
VERSION = "1.0.0b12"
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from azure.core.credentials_async import AsyncTokenCredential


class AIProjectClient: # pylint: disable=too-many-instance-attributes
class AIProjectClient:
"""AIProjectClient.

:ivar connections: ConnectionsOperations operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None:

response = pipeline_response.http_response

if response.status_code not in [204]:
if response.status_code not in [204, 200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""
import logging
from typing import Optional, TYPE_CHECKING, Any
from urllib.parse import urlparse
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.tracing.decorator import distributed_trace

Expand All @@ -18,6 +17,8 @@
EntraIDCredentials,
)
from ...models._enums import ConnectionType
from ...operations._patch_inference import _get_aoai_inference_url
from ...operations._patch_inference import _get_inference_url

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
Expand All @@ -40,48 +41,6 @@ class InferenceOperations:
def __init__(self, outer_instance: "azure.ai.projects.aio.AIProjectClient") -> None: # type: ignore[name-defined]
self._outer_instance = outer_instance

# TODO: Use a common method for both the sync and async operations
@classmethod
def _get_inference_url(cls, input_url: str) -> str:
"""
Converts an input URL in the format:
https://<host-name>/<some-path>
to:
https://<host-name>/models

:param input_url: The input endpoint URL used to construct AIProjectClient.
:type input_url: str

:return: The endpoint URL required to construct inference clients from the azure-ai-inference package.
:rtype: str
"""
parsed = urlparse(input_url)
if parsed.scheme != "https" or not parsed.netloc:
raise ValueError("Invalid endpoint URL format. Must be an https URL with a host.")
new_url = f"https://{parsed.netloc}/models"
return new_url

# TODO: Use a common method for both the sync and async operations
@classmethod
def _get_aoai_inference_url(cls, input_url: str) -> str:
"""
Converts an input URL in the format:
https://<host-name>/<some-path>
to:
https://<host-name>

:param input_url: The input endpoint URL used to construct AIProjectClient.
:type input_url: str

:return: The endpoint URL required to construct an AzureOpenAI client from the `openai` package.
:rtype: str
"""
parsed = urlparse(input_url)
if parsed.scheme != "https" or not parsed.netloc:
raise ValueError("Invalid endpoint URL format. Must be an https URL with a host.")
new_url = f"https://{parsed.netloc}"
return new_url

@distributed_trace
def get_chat_completions_client(self, **kwargs: Any) -> "ChatCompletionsClient": # type: ignore[name-defined]
"""Get an authenticated asynchronous ChatCompletionsClient (from the package azure-ai-inference) to use with
Expand All @@ -107,7 +66,7 @@ def get_chat_completions_client(self, **kwargs: Any) -> "ChatCompletionsClient":
"Azure AI Inference SDK is not installed. Please install it using 'pip install azure-ai-inference'"
) from e

endpoint = self._get_inference_url(self._outer_instance._config.endpoint) # pylint: disable=protected-access
endpoint = _get_inference_url(self._outer_instance._config.endpoint) # pylint: disable=protected-access

client = ChatCompletionsClient(
endpoint=endpoint,
Expand Down Expand Up @@ -146,7 +105,7 @@ def get_embeddings_client(self, **kwargs: Any) -> "EmbeddingsClient": # type: i
"Azure AI Inference SDK is not installed. Please install it using 'pip install azure-ai-inference'"
) from e

endpoint = self._get_inference_url(self._outer_instance._config.endpoint) # pylint: disable=protected-access
endpoint = _get_inference_url(self._outer_instance._config.endpoint) # pylint: disable=protected-access

client = EmbeddingsClient(
endpoint=endpoint,
Expand Down Expand Up @@ -185,7 +144,7 @@ def get_image_embeddings_client(self, **kwargs: Any) -> "ImageEmbeddingsClient":
"Azure AI Inference SDK is not installed. Please install it using 'pip install azure-ai-inference'"
) from e

endpoint = self._get_inference_url(self._outer_instance._config.endpoint) # pylint: disable=protected-access
endpoint = _get_inference_url(self._outer_instance._config.endpoint) # pylint: disable=protected-access

client = ImageEmbeddingsClient(
endpoint=endpoint,
Expand Down Expand Up @@ -300,7 +259,7 @@ async def get_azure_openai_client(
"azure.identity package not installed. Please install it using 'pip install azure.identity'"
) from e

azure_endpoint = self._get_aoai_inference_url(
azure_endpoint = _get_aoai_inference_url(
self._outer_instance._config.endpoint # pylint: disable=protected-access
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ class ConnectionsOperations:
:attr:`connections` attribute.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
Expand Down Expand Up @@ -878,7 +878,7 @@ class EvaluationsOperations:
:attr:`evaluations` attribute.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
Expand Down Expand Up @@ -1295,7 +1295,7 @@ class DatasetsOperations:
:attr:`datasets` attribute.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
Expand Down Expand Up @@ -1576,7 +1576,7 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis

response = pipeline_response.http_response

if response.status_code not in [204]:
if response.status_code not in [204, 200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -1951,7 +1951,7 @@ class IndexesOperations:
:attr:`indexes` attribute.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
Expand Down Expand Up @@ -2400,7 +2400,7 @@ class DeploymentsOperations:
:attr:`deployments` attribute.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
Expand Down Expand Up @@ -2583,7 +2583,7 @@ class RedTeamsOperations:
:attr:`red_teams` attribute.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
Expand Down
Loading
Loading