Skip to content

Commit d72961e

Browse files
howieleungdargilconick863jhakulinM-Hietala
authored
Changes for Beta 7 release of Python Azure AI Projects SDK (#39877)
* Set version to beta 7 * Fix deserialization of RunStepDeltaFileSearchToolCall. (#39798) * Regeerate code and update tests * Revert some changes * Fix sanitizer to run the tests on vector store * Fix * Fix spelling * run black and fix split chinese characters in streaming (#39826) * Add support for URL citation, and use "agent_id" instead of "assistant_id" in public SDK APIs (wire protocol still uses "assistant_id") (#39822) * Add convenience method to access URL citations on the ThreadMessage class * Overload test and rebase (#39237) * Set release date in CHANGELOG.md * Update README for Azure Function (#39976) * Update README for Azure Function * Update comment on Role assignment in package README.md (#39984) * Fix toc links on https://pypi.org/project/azure-ai-projects/. Add link to page talking about role assignments * Revert TOC changes * More * tracing update to samples (#39986) * tracing update to samples * fixing async sample * updating snippet --------- Co-authored-by: Marko Hietala <[email protected]> --------- Co-authored-by: Darren Cohen <[email protected]> Co-authored-by: Nikolay Rovinskiy <[email protected]> Co-authored-by: Jarno Hakulinen <[email protected]> Co-authored-by: M-Hietala <[email protected]> Co-authored-by: Marko Hietala <[email protected]>
1 parent 538180c commit d72961e

File tree

109 files changed

+2419
-1095
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2419
-1095
lines changed

sdk/ai/azure-ai-projects/CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Release History
22

3+
## 1.0.0b7 (2025-03-06)
4+
5+
### Features added
6+
7+
* Add support for parsing URL citations in Agent text messages. See new classes `MessageTextUrlCitationAnnotation` and `MessageDeltaTextUrlCitationAnnotation`.
8+
* Add enum value `ConnectionType.API_KEY` to support enumeration of generic connections that uses API Key authentication.
9+
10+
### Sample updates
11+
12+
* Update sample `sample_agents_bing_grounding.py` with printout of URL citation.
13+
* Add new samples `sample_agents_stream_eventhandler_with_bing_grounding.py` and `sample_agents_stream_iteration_with_bing_grounding.py` with printout of URL citation.
14+
15+
### Bugs Fixed
16+
17+
* Fix a bug in deserialization of `RunStepDeltaFileSearchToolCall` returned during Agent streaming (see [GitHub issue 48333](https://github.com/Azure/azure-sdk-for-net/issues/48333)).
18+
* Fix for Exception raised while parsing Agent streaming response, in some rare cases, for multibyte UTF-8 languages like Chinese.
19+
20+
### Breaking Changes
21+
22+
* Rename input argument `assistant_id` to `agent_id` in all Agent methods to align with the "Agent" terminology. Similarly, rename all `assistant_id` properties on classes.
23+
324
## 1.0.0b6 (2025-02-14)
425

526
### Features added

sdk/ai/azure-ai-projects/README.md

Lines changed: 117 additions & 92 deletions
Large diffs are not rendered by default.

sdk/ai/azure-ai-projects/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ai/azure-ai-projects",
5-
"Tag": "python/ai/azure-ai-projects_85b26dc606"
5+
"Tag": "python/ai/azure-ai-projects_04dc35e78c"
66
}

sdk/ai/azure-ai-projects/azure/ai/projects/_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=line-too-long,useless-suppression
12
# coding=utf-8
23
# --------------------------------------------------------------------------
34
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -62,7 +63,7 @@ def __init__(
6263
credential: "TokenCredential",
6364
**kwargs: Any
6465
) -> None:
65-
_endpoint = "{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}" # pylint: disable=line-too-long
66+
_endpoint = "{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}"
6667
self._config = AIProjectClientConfiguration(
6768
endpoint=endpoint,
6869
subscription_id=subscription_id,

sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=line-too-long,useless-suppression
12
# ------------------------------------
23
# Copyright (c) Microsoft Corporation.
34
# Licensed under the MIT License.

sdk/ai/azure-ai-projects/azure/ai/projects/_serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=too-many-lines
1+
# pylint: disable=line-too-long,useless-suppression,too-many-lines
22
# --------------------------------------------------------------------------
33
#
44
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
13611361
# Iter and wrapped, should have found one node only (the wrap one)
13621362
if len(children) != 1:
13631363
raise DeserializationError(
1364-
"Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long
1364+
"Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format(
13651365
xml_name
13661366
)
13671367
)

sdk/ai/azure-ai-projects/azure/ai/projects/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "1.0.0b6"
9+
VERSION = "1.0.0b7"

sdk/ai/azure-ai-projects/azure/ai/projects/aio/_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=line-too-long,useless-suppression
12
# coding=utf-8
23
# --------------------------------------------------------------------------
34
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -62,7 +63,7 @@ def __init__(
6263
credential: "AsyncTokenCredential",
6364
**kwargs: Any
6465
) -> None:
65-
_endpoint = "{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}" # pylint: disable=line-too-long
66+
_endpoint = "{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}"
6667
self._config = AIProjectClientConfiguration(
6768
endpoint=endpoint,
6869
subscription_id=subscription_id,

sdk/ai/azure-ai-projects/azure/ai/projects/aio/_patch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=line-too-long,useless-suppression
12
# ------------------------------------
23
# Copyright (c) Microsoft Corporation.
34
# Licensed under the MIT License.

sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=too-many-lines
1+
# pylint: disable=line-too-long,useless-suppression,too-many-lines
22
# coding=utf-8
33
# --------------------------------------------------------------------------
44
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -449,11 +449,11 @@ async def list_agents(
449449
return deserialized # type: ignore
450450

451451
@distributed_trace_async
452-
async def get_agent(self, assistant_id: str, **kwargs: Any) -> _models.Agent:
452+
async def get_agent(self, agent_id: str, **kwargs: Any) -> _models.Agent:
453453
"""Retrieves an existing agent.
454454
455-
:param assistant_id: Identifier of the agent. Required.
456-
:type assistant_id: str
455+
:param agent_id: Identifier of the agent. Required.
456+
:type agent_id: str
457457
:return: Agent. The Agent is compatible with MutableMapping
458458
:rtype: ~azure.ai.projects.models.Agent
459459
:raises ~azure.core.exceptions.HttpResponseError:
@@ -472,7 +472,7 @@ async def get_agent(self, assistant_id: str, **kwargs: Any) -> _models.Agent:
472472
cls: ClsType[_models.Agent] = kwargs.pop("cls", None)
473473

474474
_request = build_agents_get_agent_request(
475-
assistant_id=assistant_id,
475+
agent_id=agent_id,
476476
api_version=self._config.api_version,
477477
headers=_headers,
478478
params=_params,
@@ -516,7 +516,7 @@ async def get_agent(self, assistant_id: str, **kwargs: Any) -> _models.Agent:
516516
@overload
517517
async def update_agent(
518518
self,
519-
assistant_id: str,
519+
agent_id: str,
520520
*,
521521
content_type: str = "application/json",
522522
model: Optional[str] = None,
@@ -533,8 +533,8 @@ async def update_agent(
533533
) -> _models.Agent:
534534
"""Modifies an existing agent.
535535
536-
:param assistant_id: The ID of the agent to modify. Required.
537-
:type assistant_id: str
536+
:param agent_id: The ID of the agent to modify. Required.
537+
:type agent_id: str
538538
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
539539
Default value is "application/json".
540540
:paramtype content_type: str
@@ -584,12 +584,12 @@ async def update_agent(
584584

585585
@overload
586586
async def update_agent(
587-
self, assistant_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
587+
self, agent_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
588588
) -> _models.Agent:
589589
"""Modifies an existing agent.
590590
591-
:param assistant_id: The ID of the agent to modify. Required.
592-
:type assistant_id: str
591+
:param agent_id: The ID of the agent to modify. Required.
592+
:type agent_id: str
593593
:param body: Required.
594594
:type body: JSON
595595
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
@@ -602,12 +602,12 @@ async def update_agent(
602602

603603
@overload
604604
async def update_agent(
605-
self, assistant_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
605+
self, agent_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
606606
) -> _models.Agent:
607607
"""Modifies an existing agent.
608608
609-
:param assistant_id: The ID of the agent to modify. Required.
610-
:type assistant_id: str
609+
:param agent_id: The ID of the agent to modify. Required.
610+
:type agent_id: str
611611
:param body: Required.
612612
:type body: IO[bytes]
613613
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
@@ -621,7 +621,7 @@ async def update_agent(
621621
@distributed_trace_async
622622
async def update_agent(
623623
self,
624-
assistant_id: str,
624+
agent_id: str,
625625
body: Union[JSON, IO[bytes]] = _Unset,
626626
*,
627627
model: Optional[str] = None,
@@ -638,8 +638,8 @@ async def update_agent(
638638
) -> _models.Agent:
639639
"""Modifies an existing agent.
640640
641-
:param assistant_id: The ID of the agent to modify. Required.
642-
:type assistant_id: str
641+
:param agent_id: The ID of the agent to modify. Required.
642+
:type agent_id: str
643643
:param body: Is either a JSON type or a IO[bytes] type. Required.
644644
:type body: JSON or IO[bytes]
645645
:keyword model: The ID of the model to use. Default value is None.
@@ -721,7 +721,7 @@ async def update_agent(
721721
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
722722

723723
_request = build_agents_update_agent_request(
724-
assistant_id=assistant_id,
724+
agent_id=agent_id,
725725
content_type=content_type,
726726
api_version=self._config.api_version,
727727
content=_content,
@@ -765,11 +765,11 @@ async def update_agent(
765765
return deserialized # type: ignore
766766

767767
@distributed_trace_async
768-
async def delete_agent(self, assistant_id: str, **kwargs: Any) -> _models.AgentDeletionStatus:
768+
async def delete_agent(self, agent_id: str, **kwargs: Any) -> _models.AgentDeletionStatus:
769769
"""Deletes an agent.
770770
771-
:param assistant_id: Identifier of the agent. Required.
772-
:type assistant_id: str
771+
:param agent_id: Identifier of the agent. Required.
772+
:type agent_id: str
773773
:return: AgentDeletionStatus. The AgentDeletionStatus is compatible with MutableMapping
774774
:rtype: ~azure.ai.projects.models.AgentDeletionStatus
775775
:raises ~azure.core.exceptions.HttpResponseError:
@@ -788,7 +788,7 @@ async def delete_agent(self, assistant_id: str, **kwargs: Any) -> _models.AgentD
788788
cls: ClsType[_models.AgentDeletionStatus] = kwargs.pop("cls", None)
789789

790790
_request = build_agents_delete_agent_request(
791-
assistant_id=assistant_id,
791+
agent_id=agent_id,
792792
api_version=self._config.api_version,
793793
headers=_headers,
794794
params=_params,
@@ -1825,7 +1825,7 @@ async def create_run(
18251825
self,
18261826
thread_id: str,
18271827
*,
1828-
assistant_id: str,
1828+
agent_id: str,
18291829
include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None,
18301830
content_type: str = "application/json",
18311831
model: Optional[str] = None,
@@ -1849,8 +1849,8 @@ async def create_run(
18491849
18501850
:param thread_id: Identifier of the thread. Required.
18511851
:type thread_id: str
1852-
:keyword assistant_id: The ID of the agent that should run the thread. Required.
1853-
:paramtype assistant_id: str
1852+
:keyword agent_id: The ID of the agent that should run the thread. Required.
1853+
:paramtype agent_id: str
18541854
:keyword include: A list of additional fields to include in the response.
18551855
Currently the only supported value is
18561856
``step_details.tool_calls[*].file_search.results[*].content`` to fetch the file search result
@@ -1997,7 +1997,7 @@ async def create_run(
19971997
thread_id: str,
19981998
body: Union[JSON, IO[bytes]] = _Unset,
19991999
*,
2000-
assistant_id: str = _Unset,
2000+
agent_id: str = _Unset,
20012001
include: Optional[List[Union[str, _models.RunAdditionalFieldList]]] = None,
20022002
model: Optional[str] = None,
20032003
instructions: Optional[str] = None,
@@ -2022,8 +2022,8 @@ async def create_run(
20222022
:type thread_id: str
20232023
:param body: Is either a JSON type or a IO[bytes] type. Required.
20242024
:type body: JSON or IO[bytes]
2025-
:keyword assistant_id: The ID of the agent that should run the thread. Required.
2026-
:paramtype assistant_id: str
2025+
:keyword agent_id: The ID of the agent that should run the thread. Required.
2026+
:paramtype agent_id: str
20272027
:keyword include: A list of additional fields to include in the response.
20282028
Currently the only supported value is
20292029
``step_details.tool_calls[*].file_search.results[*].content`` to fetch the file search result
@@ -2117,12 +2117,12 @@ async def create_run(
21172117
cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None)
21182118

21192119
if body is _Unset:
2120-
if assistant_id is _Unset:
2121-
raise TypeError("missing required argument: assistant_id")
2120+
if agent_id is _Unset:
2121+
raise TypeError("missing required argument: agent_id")
21222122
body = {
21232123
"additional_instructions": additional_instructions,
21242124
"additional_messages": additional_messages,
2125-
"assistant_id": assistant_id,
2125+
"assistant_id": agent_id,
21262126
"instructions": instructions,
21272127
"max_completion_tokens": max_completion_tokens,
21282128
"max_prompt_tokens": max_prompt_tokens,
@@ -2767,7 +2767,7 @@ async def cancel_run(self, thread_id: str, run_id: str, **kwargs: Any) -> _model
27672767
async def create_thread_and_run(
27682768
self,
27692769
*,
2770-
assistant_id: str,
2770+
agent_id: str,
27712771
content_type: str = "application/json",
27722772
thread: Optional[_models.AgentThreadCreationOptions] = None,
27732773
model: Optional[str] = None,
@@ -2788,8 +2788,8 @@ async def create_thread_and_run(
27882788
) -> _models.ThreadRun:
27892789
"""Creates a new agent thread and immediately starts a run using that new thread.
27902790
2791-
:keyword assistant_id: The ID of the agent for which the thread should be created. Required.
2792-
:paramtype assistant_id: str
2791+
:keyword agent_id: The ID of the agent for which the thread should be created. Required.
2792+
:paramtype agent_id: str
27932793
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
27942794
Default value is "application/json".
27952795
:paramtype content_type: str
@@ -2903,7 +2903,7 @@ async def create_thread_and_run(
29032903
self,
29042904
body: Union[JSON, IO[bytes]] = _Unset,
29052905
*,
2906-
assistant_id: str = _Unset,
2906+
agent_id: str = _Unset,
29072907
thread: Optional[_models.AgentThreadCreationOptions] = None,
29082908
model: Optional[str] = None,
29092909
instructions: Optional[str] = None,
@@ -2925,8 +2925,8 @@ async def create_thread_and_run(
29252925
29262926
:param body: Is either a JSON type or a IO[bytes] type. Required.
29272927
:type body: JSON or IO[bytes]
2928-
:keyword assistant_id: The ID of the agent for which the thread should be created. Required.
2929-
:paramtype assistant_id: str
2928+
:keyword agent_id: The ID of the agent for which the thread should be created. Required.
2929+
:paramtype agent_id: str
29302930
:keyword thread: The details used to create the new thread. If no thread is provided, an empty
29312931
one will be created. Default value is None.
29322932
:paramtype thread: ~azure.ai.projects.models.AgentThreadCreationOptions
@@ -3014,10 +3014,10 @@ async def create_thread_and_run(
30143014
cls: ClsType[_models.ThreadRun] = kwargs.pop("cls", None)
30153015

30163016
if body is _Unset:
3017-
if assistant_id is _Unset:
3018-
raise TypeError("missing required argument: assistant_id")
3017+
if agent_id is _Unset:
3018+
raise TypeError("missing required argument: agent_id")
30193019
body = {
3020-
"assistant_id": assistant_id,
3020+
"assistant_id": agent_id,
30213021
"instructions": instructions,
30223022
"max_completion_tokens": max_completion_tokens,
30233023
"max_prompt_tokens": max_prompt_tokens,
@@ -5144,7 +5144,8 @@ async def _list_connections(
51445144
"""List the details of all the connections (not including their credentials).
51455145
51465146
:keyword category: Category of the workspace connection. Known values are: "AzureOpenAI",
5147-
"Serverless", "AzureBlob", "AIServices", and "CognitiveSearch". Default value is None.
5147+
"Serverless", "AzureBlob", "AIServices", "CognitiveSearch", and "API Key". Default value is
5148+
None.
51485149
:paramtype category: str or ~azure.ai.projects.models.ConnectionType
51495150
:keyword include_all: Indicates whether to list datastores. Service default: do not list
51505151
datastores. Default value is None.
@@ -5404,7 +5405,6 @@ def __init__(self, *args, **kwargs) -> None:
54045405
async def _get_app_insights(
54055406
self, app_insights_resource_url: str, **kwargs: Any
54065407
) -> _models._models.GetAppInsightsResponse:
5407-
# pylint: disable=line-too-long
54085408
"""Gets the properties of the specified Application Insights resource.
54095409
54105410
:param app_insights_resource_url: The AppInsights Azure resource Url. It should have the

0 commit comments

Comments
 (0)