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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"apiVersion": "virtual-public-preview",
"apiVersions": {
"Azure.AI.Projects": "virtual-public-preview"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"CrossLanguagePackageId": "Azure.AI.Projects",
"CrossLanguageDefinitionId": {
"azure.ai.agentserver.responses.models.models.TextResponseFormatConfigurationType": "OpenAI.TextResponseFormatConfigurationType",
"azure.ai.agentserver.responses.models.models.ToolType": "OpenAI.ToolType",
"azure.ai.agentserver.responses.models.models.AzureAISearchQueryType": "Azure.AI.Projects.AzureAISearchQueryType",
"azure.ai.agentserver.responses.models.models.ContainerMemoryLimit": "OpenAI.ContainerMemoryLimit",
"azure.ai.agentserver.responses.models.models.ContainerNetworkPolicyParamType": "OpenAI.ContainerNetworkPolicyParamType",
"azure.ai.agentserver.responses.models.models.ComputerEnvironment": "OpenAI.ComputerEnvironment",
"azure.ai.agentserver.responses.models.models.CustomToolParamFormatType": "OpenAI.CustomToolParamFormatType",
"azure.ai.agentserver.responses.models.models.GrammarSyntax1": "OpenAI.GrammarSyntax1",
"azure.ai.agentserver.responses.models.models.RankerVersionType": "OpenAI.RankerVersionType",
"azure.ai.agentserver.responses.models.models.InputFidelity": "OpenAI.InputFidelity",
"azure.ai.agentserver.responses.models.models.ImageGenActionEnum": "OpenAI.ImageGenActionEnum",
"azure.ai.agentserver.responses.models.models.OpenApiAuthType": "Azure.AI.Projects.OpenApiAuthType",
"azure.ai.agentserver.responses.models.models.FunctionShellToolParamEnvironmentType": "OpenAI.FunctionShellToolParamEnvironmentType",
"azure.ai.agentserver.responses.models.models.ContainerSkillType": "OpenAI.ContainerSkillType",
"azure.ai.agentserver.responses.models.models.SearchContextSize": "OpenAI.SearchContextSize",
"azure.ai.agentserver.responses.models.models.ToolChoiceOptions": "OpenAI.ToolChoiceOptions",
"azure.ai.agentserver.responses.models.models.ToolChoiceParamType": "OpenAI.ToolChoiceParamType",
"azure.ai.agentserver.responses.models.models.ResponseErrorCode": "OpenAI.ResponseErrorCode",
"azure.ai.agentserver.responses.models.models.OutputItemType": "OpenAI.OutputItemType",
"azure.ai.agentserver.responses.models.models.ToolCallStatus": "Azure.AI.Projects.ToolCallStatus",
"azure.ai.agentserver.responses.models.models.ApplyPatchCallStatus": "OpenAI.ApplyPatchCallStatus",
"azure.ai.agentserver.responses.models.models.ApplyPatchFileOperationType": "OpenAI.ApplyPatchFileOperationType",
"azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatus": "OpenAI.ApplyPatchCallOutputStatus",
"azure.ai.agentserver.responses.models.models.ComputerActionType": "OpenAI.ComputerActionType",
"azure.ai.agentserver.responses.models.models.ClickButtonType": "OpenAI.ClickButtonType",
"azure.ai.agentserver.responses.models.models.FunctionAndCustomToolCallOutputType": "OpenAI.FunctionAndCustomToolCallOutputType",
"azure.ai.agentserver.responses.models.models.ImageDetail": "OpenAI.ImageDetail",
"azure.ai.agentserver.responses.models.models.MCPToolCallStatus": "OpenAI.MCPToolCallStatus",
"azure.ai.agentserver.responses.models.models.MemoryItemKind": "Azure.AI.Projects.MemoryItemKind",
"azure.ai.agentserver.responses.models.models.MessageStatus": "OpenAI.MessageStatus",
"azure.ai.agentserver.responses.models.models.MessageRole": "OpenAI.MessageRole",
"azure.ai.agentserver.responses.models.models.MessageContentType": "OpenAI.MessageContentType",
"azure.ai.agentserver.responses.models.models.AnnotationType": "OpenAI.AnnotationType",
"azure.ai.agentserver.responses.models.models.OutputMessageContentType": "OpenAI.OutputMessageContentType",
"azure.ai.agentserver.responses.models.models.LocalShellCallStatus": "OpenAI.LocalShellCallStatus",
"azure.ai.agentserver.responses.models.models.FunctionShellCallEnvironmentType": "OpenAI.FunctionShellCallEnvironmentType",
"azure.ai.agentserver.responses.models.models.LocalShellCallOutputStatusEnum": "OpenAI.LocalShellCallOutputStatusEnum",
"azure.ai.agentserver.responses.models.models.FunctionShellCallOutputOutcomeType": "OpenAI.FunctionShellCallOutputOutcomeType",
"azure.ai.agentserver.responses.models.models.ItemType": "OpenAI.ItemType",
"azure.ai.agentserver.responses.models.models.ApplyPatchCallStatusParam": "OpenAI.ApplyPatchCallStatusParam",
"azure.ai.agentserver.responses.models.models.ApplyPatchOperationParamType": "OpenAI.ApplyPatchOperationParamType",
"azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatusParam": "OpenAI.ApplyPatchCallOutputStatusParam",
"azure.ai.agentserver.responses.models.models.FunctionCallItemStatus": "OpenAI.FunctionCallItemStatus",
"azure.ai.agentserver.responses.models.models.DetailEnum": "OpenAI.DetailEnum",
"azure.ai.agentserver.responses.models.models.FunctionShellCallItemStatus": "OpenAI.FunctionShellCallItemStatus",
"azure.ai.agentserver.responses.models.models.FunctionShellCallItemParamEnvironmentType": "OpenAI.FunctionShellCallItemParamEnvironmentType",
"azure.ai.agentserver.responses.models.models.FunctionShellCallOutputOutcomeParamType": "OpenAI.FunctionShellCallOutputOutcomeParamType",
"azure.ai.agentserver.responses.models.models.IncludeEnum": "OpenAI.IncludeEnum",
"azure.ai.agentserver.responses.models.models.ResponseStreamEventType": "OpenAI.ResponseStreamEventType",
"azure.ai.agentserver.responses.models.models.OutputContentType": "OpenAI.OutputContentType",
"azure.ai.agentserver.responses.models.models.PageOrder": "Azure.AI.Projects.PageOrder",
"azure.ai.agentserver.responses.models.models.ItemFieldType": "OpenAI.ItemFieldType",
"azure.ai.agentserver.responses.models.models.ModelIdsCompaction": "OpenAI.ModelIdsCompaction",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.create_response": "Azure.AI.Projects.Responses.createResponse",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.create_response": "Azure.AI.Projects.Responses.createResponse",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.create_response_stream": "Azure.AI.Projects.Responses.createResponseStream",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.create_response_stream": "Azure.AI.Projects.Responses.createResponseStream",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.get_response": "Azure.AI.Projects.Responses.getResponse",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.get_response": "Azure.AI.Projects.Responses.getResponse",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.get_response_stream": "Azure.AI.Projects.Responses.getResponseStream",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.get_response_stream": "Azure.AI.Projects.Responses.getResponseStream",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.delete_response": "Azure.AI.Projects.Responses.deleteResponse",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.delete_response": "Azure.AI.Projects.Responses.deleteResponse",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.cancel_response": "Azure.AI.Projects.Responses.cancelResponse",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.cancel_response": "Azure.AI.Projects.Responses.cancelResponse",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.list_input_items": "Azure.AI.Projects.Responses.listInputItems",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.list_input_items": "Azure.AI.Projects.Responses.listInputItems",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.list_responses": "Azure.AI.Projects.Responses.listResponses",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.list_responses": "Azure.AI.Projects.Responses.listResponses",
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.compact_response_conversation": "Azure.AI.Projects.Responses.compactResponseConversation",
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.compact_response_conversation": "Azure.AI.Projects.Responses.compactResponseConversation"
},
"CrossLanguageVersion": "8daa8c9e22b2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
import sys
from typing import Any, TYPE_CHECKING, Union

from azure.core import PipelineClient
from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse

from ._configuration import ProjectsClientConfiguration
from ._utils.serialization import Deserializer, Serializer
from .operations import ResponsesOperations

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self # type: ignore

if TYPE_CHECKING:
from azure.core.credentials import TokenCredential


class ProjectsClient: # pylint: disable=client-accepts-api-version-keyword
"""ProjectsClient.

:ivar responses: ResponsesOperations operations
:vartype responses: azure.ai.agentserver.responses.models.operations.ResponsesOperations
:param endpoint: Foundry Project endpoint in the form
"https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you
only have one Project in your Foundry Hub, or to target the default Project in your Hub, use
the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project".
Required.
:type endpoint: str
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
_endpoint = "{endpoint}"
self._config = ProjectsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)

_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)

self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False
self.responses = ResponsesOperations(self._client, self._config, self._serialize, self._deserialize)

def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""

request_copy = deepcopy(request)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self) -> None:
self._client.close()

def __enter__(self) -> Self:
self._client.__enter__()
return self

def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING, Union

from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
from azure.core.credentials import TokenCredential


class ProjectsClientConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for ProjectsClient.

Note that all parameters used to create this instance are saved as instance
attributes.

:param endpoint: Foundry Project endpoint in the form
"https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you
only have one Project in your Foundry Hub, or to target the default Project in your Hub, use
the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project".
Required.
:type endpoint: str
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.endpoint = endpoint
self.credential = credential
self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "ai-agentserver-responses/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _infer_policy(self, **kwargs):
if isinstance(self.credential, AzureKeyCredential):
return policies.AzureKeyCredentialPolicy(self.credential, "api-key", **kwargs)
if hasattr(self.credential, "get_token"):
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
raise TypeError(f"Unsupported credential: {self.credential}")

def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = self._infer_policy(**kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------
"""Customize generated code here.

Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
"""


__all__: list[str] = [] # Add all objects you want publicly available to users at this package level


def patch_sdk():
"""Do not remove from this file.

`patch_sdk` is a last resort escape hatch that allows you to do customizations
you can't accomplish using the techniques described in
https://aka.ms/azsdk/python/dpcodegen/python/customize
"""
Loading
Loading