Skip to content

Commit f899362

Browse files
author
iscai-msft
committed
switch to agentserver only
1 parent ddea677 commit f899362

23 files changed

Lines changed: 20234 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"apiVersion": "virtual-public-preview",
3+
"apiVersions": {
4+
"Azure.AI.Projects": "virtual-public-preview"
5+
}
6+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"CrossLanguagePackageId": "Azure.AI.Projects",
3+
"CrossLanguageDefinitionId": {
4+
"azure.ai.agentserver.responses.models.models.TextResponseFormatConfigurationType": "OpenAI.TextResponseFormatConfigurationType",
5+
"azure.ai.agentserver.responses.models.models.ToolType": "OpenAI.ToolType",
6+
"azure.ai.agentserver.responses.models.models.AzureAISearchQueryType": "Azure.AI.Projects.AzureAISearchQueryType",
7+
"azure.ai.agentserver.responses.models.models.ContainerMemoryLimit": "OpenAI.ContainerMemoryLimit",
8+
"azure.ai.agentserver.responses.models.models.ContainerNetworkPolicyParamType": "OpenAI.ContainerNetworkPolicyParamType",
9+
"azure.ai.agentserver.responses.models.models.ComputerEnvironment": "OpenAI.ComputerEnvironment",
10+
"azure.ai.agentserver.responses.models.models.CustomToolParamFormatType": "OpenAI.CustomToolParamFormatType",
11+
"azure.ai.agentserver.responses.models.models.GrammarSyntax1": "OpenAI.GrammarSyntax1",
12+
"azure.ai.agentserver.responses.models.models.RankerVersionType": "OpenAI.RankerVersionType",
13+
"azure.ai.agentserver.responses.models.models.InputFidelity": "OpenAI.InputFidelity",
14+
"azure.ai.agentserver.responses.models.models.ImageGenActionEnum": "OpenAI.ImageGenActionEnum",
15+
"azure.ai.agentserver.responses.models.models.OpenApiAuthType": "Azure.AI.Projects.OpenApiAuthType",
16+
"azure.ai.agentserver.responses.models.models.FunctionShellToolParamEnvironmentType": "OpenAI.FunctionShellToolParamEnvironmentType",
17+
"azure.ai.agentserver.responses.models.models.ContainerSkillType": "OpenAI.ContainerSkillType",
18+
"azure.ai.agentserver.responses.models.models.SearchContextSize": "OpenAI.SearchContextSize",
19+
"azure.ai.agentserver.responses.models.models.ToolChoiceOptions": "OpenAI.ToolChoiceOptions",
20+
"azure.ai.agentserver.responses.models.models.ToolChoiceParamType": "OpenAI.ToolChoiceParamType",
21+
"azure.ai.agentserver.responses.models.models.ResponseErrorCode": "OpenAI.ResponseErrorCode",
22+
"azure.ai.agentserver.responses.models.models.OutputItemType": "OpenAI.OutputItemType",
23+
"azure.ai.agentserver.responses.models.models.ToolCallStatus": "Azure.AI.Projects.ToolCallStatus",
24+
"azure.ai.agentserver.responses.models.models.ApplyPatchCallStatus": "OpenAI.ApplyPatchCallStatus",
25+
"azure.ai.agentserver.responses.models.models.ApplyPatchFileOperationType": "OpenAI.ApplyPatchFileOperationType",
26+
"azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatus": "OpenAI.ApplyPatchCallOutputStatus",
27+
"azure.ai.agentserver.responses.models.models.ComputerActionType": "OpenAI.ComputerActionType",
28+
"azure.ai.agentserver.responses.models.models.ClickButtonType": "OpenAI.ClickButtonType",
29+
"azure.ai.agentserver.responses.models.models.FunctionAndCustomToolCallOutputType": "OpenAI.FunctionAndCustomToolCallOutputType",
30+
"azure.ai.agentserver.responses.models.models.ImageDetail": "OpenAI.ImageDetail",
31+
"azure.ai.agentserver.responses.models.models.MCPToolCallStatus": "OpenAI.MCPToolCallStatus",
32+
"azure.ai.agentserver.responses.models.models.MemoryItemKind": "Azure.AI.Projects.MemoryItemKind",
33+
"azure.ai.agentserver.responses.models.models.MessageStatus": "OpenAI.MessageStatus",
34+
"azure.ai.agentserver.responses.models.models.MessageRole": "OpenAI.MessageRole",
35+
"azure.ai.agentserver.responses.models.models.MessageContentType": "OpenAI.MessageContentType",
36+
"azure.ai.agentserver.responses.models.models.AnnotationType": "OpenAI.AnnotationType",
37+
"azure.ai.agentserver.responses.models.models.OutputMessageContentType": "OpenAI.OutputMessageContentType",
38+
"azure.ai.agentserver.responses.models.models.LocalShellCallStatus": "OpenAI.LocalShellCallStatus",
39+
"azure.ai.agentserver.responses.models.models.FunctionShellCallEnvironmentType": "OpenAI.FunctionShellCallEnvironmentType",
40+
"azure.ai.agentserver.responses.models.models.LocalShellCallOutputStatusEnum": "OpenAI.LocalShellCallOutputStatusEnum",
41+
"azure.ai.agentserver.responses.models.models.FunctionShellCallOutputOutcomeType": "OpenAI.FunctionShellCallOutputOutcomeType",
42+
"azure.ai.agentserver.responses.models.models.ItemType": "OpenAI.ItemType",
43+
"azure.ai.agentserver.responses.models.models.ApplyPatchCallStatusParam": "OpenAI.ApplyPatchCallStatusParam",
44+
"azure.ai.agentserver.responses.models.models.ApplyPatchOperationParamType": "OpenAI.ApplyPatchOperationParamType",
45+
"azure.ai.agentserver.responses.models.models.ApplyPatchCallOutputStatusParam": "OpenAI.ApplyPatchCallOutputStatusParam",
46+
"azure.ai.agentserver.responses.models.models.FunctionCallItemStatus": "OpenAI.FunctionCallItemStatus",
47+
"azure.ai.agentserver.responses.models.models.DetailEnum": "OpenAI.DetailEnum",
48+
"azure.ai.agentserver.responses.models.models.FunctionShellCallItemStatus": "OpenAI.FunctionShellCallItemStatus",
49+
"azure.ai.agentserver.responses.models.models.FunctionShellCallItemParamEnvironmentType": "OpenAI.FunctionShellCallItemParamEnvironmentType",
50+
"azure.ai.agentserver.responses.models.models.FunctionShellCallOutputOutcomeParamType": "OpenAI.FunctionShellCallOutputOutcomeParamType",
51+
"azure.ai.agentserver.responses.models.models.IncludeEnum": "OpenAI.IncludeEnum",
52+
"azure.ai.agentserver.responses.models.models.ResponseStreamEventType": "OpenAI.ResponseStreamEventType",
53+
"azure.ai.agentserver.responses.models.models.OutputContentType": "OpenAI.OutputContentType",
54+
"azure.ai.agentserver.responses.models.models.PageOrder": "Azure.AI.Projects.PageOrder",
55+
"azure.ai.agentserver.responses.models.models.ItemFieldType": "OpenAI.ItemFieldType",
56+
"azure.ai.agentserver.responses.models.models.ModelIdsCompaction": "OpenAI.ModelIdsCompaction",
57+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.create_response": "Azure.AI.Projects.Responses.createResponse",
58+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.create_response": "Azure.AI.Projects.Responses.createResponse",
59+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.create_response_stream": "Azure.AI.Projects.Responses.createResponseStream",
60+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.create_response_stream": "Azure.AI.Projects.Responses.createResponseStream",
61+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.get_response": "Azure.AI.Projects.Responses.getResponse",
62+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.get_response": "Azure.AI.Projects.Responses.getResponse",
63+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.get_response_stream": "Azure.AI.Projects.Responses.getResponseStream",
64+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.get_response_stream": "Azure.AI.Projects.Responses.getResponseStream",
65+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.delete_response": "Azure.AI.Projects.Responses.deleteResponse",
66+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.delete_response": "Azure.AI.Projects.Responses.deleteResponse",
67+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.cancel_response": "Azure.AI.Projects.Responses.cancelResponse",
68+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.cancel_response": "Azure.AI.Projects.Responses.cancelResponse",
69+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.list_input_items": "Azure.AI.Projects.Responses.listInputItems",
70+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.list_input_items": "Azure.AI.Projects.Responses.listInputItems",
71+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.list_responses": "Azure.AI.Projects.Responses.listResponses",
72+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.list_responses": "Azure.AI.Projects.Responses.listResponses",
73+
"azure.ai.agentserver.responses.models.operations.ResponsesOperations.compact_response_conversation": "Azure.AI.Projects.Responses.compactResponseConversation",
74+
"azure.ai.agentserver.responses.models.aio.operations.ResponsesOperations.compact_response_conversation": "Azure.AI.Projects.Responses.compactResponseConversation"
75+
},
76+
"CrossLanguageVersion": "8daa8c9e22b2"
77+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
import sys
11+
from typing import Any, TYPE_CHECKING, Union
12+
13+
from azure.core import PipelineClient
14+
from azure.core.credentials import AzureKeyCredential
15+
from azure.core.pipeline import policies
16+
from azure.core.rest import HttpRequest, HttpResponse
17+
18+
from ._configuration import ProjectsClientConfiguration
19+
from ._utils.serialization import Deserializer, Serializer
20+
from .operations import ResponsesOperations
21+
22+
if sys.version_info >= (3, 11):
23+
from typing import Self
24+
else:
25+
from typing_extensions import Self # type: ignore
26+
27+
if TYPE_CHECKING:
28+
from azure.core.credentials import TokenCredential
29+
30+
31+
class ProjectsClient: # pylint: disable=client-accepts-api-version-keyword
32+
"""ProjectsClient.
33+
34+
:ivar responses: ResponsesOperations operations
35+
:vartype responses: azure.ai.agentserver.responses.models.operations.ResponsesOperations
36+
:param endpoint: Foundry Project endpoint in the form
37+
"https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you
38+
only have one Project in your Foundry Hub, or to target the default Project in your Hub, use
39+
the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project".
40+
Required.
41+
:type endpoint: str
42+
:param credential: Credential used to authenticate requests to the service. Is either a key
43+
credential type or a token credential type. Required.
44+
:type credential: ~azure.core.credentials.AzureKeyCredential or
45+
~azure.core.credentials.TokenCredential
46+
"""
47+
48+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
49+
_endpoint = "{endpoint}"
50+
self._config = ProjectsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
51+
52+
_policies = kwargs.pop("policies", None)
53+
if _policies is None:
54+
_policies = [
55+
policies.RequestIdPolicy(**kwargs),
56+
self._config.headers_policy,
57+
self._config.user_agent_policy,
58+
self._config.proxy_policy,
59+
policies.ContentDecodePolicy(**kwargs),
60+
self._config.redirect_policy,
61+
self._config.retry_policy,
62+
self._config.authentication_policy,
63+
self._config.custom_hook_policy,
64+
self._config.logging_policy,
65+
policies.DistributedTracingPolicy(**kwargs),
66+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
67+
self._config.http_logging_policy,
68+
]
69+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
70+
71+
self._serialize = Serializer()
72+
self._deserialize = Deserializer()
73+
self._serialize.client_side_validation = False
74+
self.responses = ResponsesOperations(self._client, self._config, self._serialize, self._deserialize)
75+
76+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
77+
"""Runs the network request through the client's chained policies.
78+
79+
>>> from azure.core.rest import HttpRequest
80+
>>> request = HttpRequest("GET", "https://www.example.org/")
81+
<HttpRequest [GET], url: 'https://www.example.org/'>
82+
>>> response = client.send_request(request)
83+
<HttpResponse: 200 OK>
84+
85+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
86+
87+
:param request: The network request you want to make. Required.
88+
:type request: ~azure.core.rest.HttpRequest
89+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
90+
:return: The response of your network call. Does not do error handling on your response.
91+
:rtype: ~azure.core.rest.HttpResponse
92+
"""
93+
94+
request_copy = deepcopy(request)
95+
path_format_arguments = {
96+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
97+
}
98+
99+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
100+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
101+
102+
def close(self) -> None:
103+
self._client.close()
104+
105+
def __enter__(self) -> Self:
106+
self._client.__enter__()
107+
return self
108+
109+
def __exit__(self, *exc_details: Any) -> None:
110+
self._client.__exit__(*exc_details)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any, TYPE_CHECKING, Union
10+
11+
from azure.core.credentials import AzureKeyCredential
12+
from azure.core.pipeline import policies
13+
14+
from ._version import VERSION
15+
16+
if TYPE_CHECKING:
17+
from azure.core.credentials import TokenCredential
18+
19+
20+
class ProjectsClientConfiguration: # pylint: disable=too-many-instance-attributes
21+
"""Configuration for ProjectsClient.
22+
23+
Note that all parameters used to create this instance are saved as instance
24+
attributes.
25+
26+
:param endpoint: Foundry Project endpoint in the form
27+
"https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you
28+
only have one Project in your Foundry Hub, or to target the default Project in your Hub, use
29+
the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project".
30+
Required.
31+
:type endpoint: str
32+
:param credential: Credential used to authenticate requests to the service. Is either a key
33+
credential type or a token credential type. Required.
34+
:type credential: ~azure.core.credentials.AzureKeyCredential or
35+
~azure.core.credentials.TokenCredential
36+
"""
37+
38+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
39+
if endpoint is None:
40+
raise ValueError("Parameter 'endpoint' must not be None.")
41+
if credential is None:
42+
raise ValueError("Parameter 'credential' must not be None.")
43+
44+
self.endpoint = endpoint
45+
self.credential = credential
46+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
47+
kwargs.setdefault("sdk_moniker", "ai-agentserver-responses/{}".format(VERSION))
48+
self.polling_interval = kwargs.get("polling_interval", 30)
49+
self._configure(**kwargs)
50+
51+
def _infer_policy(self, **kwargs):
52+
if isinstance(self.credential, AzureKeyCredential):
53+
return policies.AzureKeyCredentialPolicy(self.credential, "api-key", **kwargs)
54+
if hasattr(self.credential, "get_token"):
55+
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
56+
raise TypeError(f"Unsupported credential: {self.credential}")
57+
58+
def _configure(self, **kwargs: Any) -> None:
59+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
60+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
61+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
62+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
63+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
64+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
65+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
66+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
67+
self.authentication_policy = kwargs.get("authentication_policy")
68+
if self.credential and not self.authentication_policy:
69+
self.authentication_policy = self._infer_policy(**kwargs)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------------
6+
"""Customize generated code here.
7+
8+
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
9+
"""
10+
11+
12+
__all__: list[str] = [] # Add all objects you want publicly available to users at this package level
13+
14+
15+
def patch_sdk():
16+
"""Do not remove from this file.
17+
18+
`patch_sdk` is a last resort escape hatch that allows you to do customizations
19+
you can't accomplish using the techniques described in
20+
https://aka.ms/azsdk/python/dpcodegen/python/customize
21+
"""

0 commit comments

Comments
 (0)