Skip to content

Commit 84d180a

Browse files
authored
Changes for beta 8 release of Python Azure AI Projects SDK (#39990)
1 parent 54ee3ae commit 84d180a

23 files changed

+2560
-439
lines changed

Diff for: .vscode/cspell.json

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"sdk/ai/azure-ai-inference/samples/hello_how_are_you.mp3",
3737
"sdk/ai/azure-ai-inference/tests/hello_how_are_you.mp3",
3838
"sdk/ai/azure-ai-projects/samples/agents/nifty_500_quarterly_results.csv",
39+
"sdk/ai/azure-ai-projects/samples/agents/tripadvisor_openapi.json",
3940
"/sdk/ai/azure-ai-projects/samples/evaluations/async_samples/data/**",
4041
"/sdk/ai/azure-ai-projects/samples/evaluations/data/**",
4142
"sdk/ai/azure-ai-resources/azure/ai/resources/_index/_langchain/vendor/**",
@@ -1344,6 +1345,10 @@
13441345
{
13451346
"filename": "sdk/ai/azure-ai-projects/**",
13461347
"words": [
1348+
"coso",
1349+
"longtitude",
1350+
"abbrev",
1351+
"accommodations",
13471352
"ENTRAID",
13481353
"entraid",
13491354
"aiservices",

Diff for: sdk/ai/azure-ai-projects/CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Release History
22

3+
## 1.0.0b8 (2025-03-28)
4+
5+
### Features added
6+
7+
* New parameters added for Azure AI Search tool, with corresponding sample update.
8+
* Fabric tool REST name updated, along with convenience code.
9+
10+
### Sample updates
11+
12+
* Sample update demonstrating new parameters added for Azure AI Search tool.
13+
* Sample added using OpenAPI tool against authenticated TripAdvisor API spec.
14+
15+
### Bugs Fixed
16+
17+
* Fix for a bug in Agent tracing causing event handler return values to not be returned when tracing is enabled.
18+
* Fix for a bug in Agent tracing causing tool calls not to be recorded in traces.
19+
* Fix for a bug in Agent tracing causing function tool calls to not work properly when tracing is enabled.
20+
* Fix for a bug in Agent streaming, where `agent_id` was not included in the response. This caused the SDK not to make function calls when the thread run status is `requires_action`.
21+
322
## 1.0.0b7 (2025-03-06)
423

524
### Features added

Diff for: sdk/ai/azure-ai-projects/README.md

+69-7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ To report an issue with the client library, or request additional features, plea
4646
- [Function call](#create-agent-with-function-call)
4747
- [Azure Function Call](#create-agent-with-azure-function-call)
4848
- [OpenAPI](#create-agent-with-openapi)
49+
- [Fabric data](#create-an-agent-with-fabric)
4950
- [Create thread](#create-thread) with
5051
- [Tool resource](#create-thread-with-tool-resource)
5152
- [Create message](#create-message) with:
@@ -455,17 +456,19 @@ Here is an example to integrate Azure AI Search:
455456
<!-- SNIPPET:sample_agents_azure_ai_search.create_agent_with_azure_ai_search_tool -->
456457

457458
```python
458-
conn_list = project_client.connections.list()
459-
conn_id = ""
460-
for conn in conn_list:
461-
if conn.connection_type == ConnectionType.AZURE_AI_SEARCH:
462-
conn_id = conn.id
463-
break
459+
connection = project_client.connections.get(connection_name=os.environ["AI_SEARCH_CONNECTION_NAME"])
460+
conn_id = connection.id
464461

465462
print(conn_id)
466463

467464
# Initialize agent AI search tool and add the search index connection id
468-
ai_search = AzureAISearchTool(index_connection_id=conn_id, index_name="myindexname")
465+
ai_search = AzureAISearchTool(
466+
index_connection_id=conn_id,
467+
index_name="sample_index",
468+
query_type=AzureAISearchQueryType.SIMPLE,
469+
top_k=3,
470+
filter=""
471+
)
469472

470473
# Create agent with AI search tool and process assistant run
471474
with project_client:
@@ -480,6 +483,34 @@ with project_client:
480483

481484
<!-- END SNIPPET -->
482485

486+
If the agent has found the relevant information in the index, the reference
487+
and annotation will be provided in the message response. In the example above, we replace
488+
the reference placeholder by the actual reference and url. Please note, that to
489+
get sensible result, the index needs to have fields "title" and "url".
490+
491+
<!-- SNIPPET:sample_agents_azure_ai_search.populate_references_agent_with_azure_ai_search_tool -->
492+
493+
```python
494+
# Fetch and log all messages
495+
messages = project_client.agents.list_messages(thread_id=thread.id, order=ListSortOrder.ASCENDING)
496+
for message in messages.data:
497+
if message.role == MessageRole.AGENT and message.url_citation_annotations:
498+
placeholder_annotations = {
499+
annotation.text: f" [see {annotation.url_citation.title}] ({annotation.url_citation.url})"
500+
for annotation in message.url_citation_annotations
501+
}
502+
for message_text in message.text_messages:
503+
message_str = message_text.text.value
504+
for k, v in placeholder_annotations.items():
505+
message_str = message_str.replace(k, v)
506+
print(f"{message.role}: {message_str}")
507+
else:
508+
for message_text in message.text_messages:
509+
print(f"{message.role}: {message_text.text.value}")
510+
```
511+
512+
<!-- END SNIPPET -->
513+
483514
#### Create Agent with Function Call
484515

485516
You can enhance your Agents by defining callback functions as function tools. These can be provided to `create_agent` via either the `toolset` parameter or the combination of `tools` and `tool_resources`. Here are the distinctions:
@@ -780,6 +811,37 @@ with project_client:
780811

781812
<!-- END SNIPPET -->
782813

814+
#### Create an Agent with Fabric
815+
816+
To enable your Agent to answer queries using Fabric data, use `FabricTool` along with a connection to the Fabric resource.
817+
818+
Here is an example:
819+
820+
<!-- SNIPPET:sample_agents_fabric.create_agent_with_fabric_tool -->
821+
822+
```python
823+
fabric_connection = project_client.connections.get(connection_name=os.environ["FABRIC_CONNECTION_NAME"])
824+
conn_id = fabric_connection.id
825+
826+
print(conn_id)
827+
828+
# Initialize an Agent Fabric tool and add the connection id
829+
fabric = FabricTool(connection_id=conn_id)
830+
831+
# Create an Agent with the Fabric tool and process an Agent run
832+
with project_client:
833+
agent = project_client.agents.create_agent(
834+
model=os.environ["MODEL_DEPLOYMENT_NAME"],
835+
name="my-agent",
836+
instructions="You are a helpful agent",
837+
tools=fabric.definitions,
838+
headers={"x-ms-enable-preview": "true"},
839+
)
840+
```
841+
842+
<!-- END SNIPPET -->
843+
844+
783845
#### Create Thread
784846

785847
For each session or conversation, a thread is required. Here is an example:

Diff for: sdk/ai/azure-ai-projects/assets.json

+1-1
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_e7dc31a23f"
5+
"Tag": "python/ai/azure-ai-projects_819c7192e3"
66
}

Diff for: sdk/ai/azure-ai-projects/azure/ai/projects/_serialization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def from_dict(
411411
:param function key_extractors: A key extractor function.
412412
:param str content_type: JSON by default, set application/xml if XML.
413413
:returns: An instance of this model
414-
:raises: DeserializationError if something went wrong
414+
:raises DeserializationError: if something went wrong
415415
:rtype: Self
416416
"""
417417
deserializer = Deserializer(cls._infer_class_models())

Diff for: sdk/ai/azure-ai-projects/azure/ai/projects/_version.py

+1-1
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.0b7"
9+
VERSION = "1.0.0b8"

Diff for: sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5144,8 +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", "CognitiveSearch", and "API Key". Default value is
5148-
None.
5147+
"Serverless", "AzureBlob", "AIServices", "CognitiveSearch", "ApiKey", "CustomKeys", and
5148+
"CognitiveService". Default value is None.
51495149
:paramtype category: str or ~azure.ai.projects.models.ConnectionType
51505150
:keyword include_all: Indicates whether to list datastores. Service default: do not list
51515151
datastores. Default value is None.

Diff for: sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515

1616
from ._models import ( # type: ignore
17+
AISearchIndexResource,
18+
AOAIModelConfig,
1719
Agent,
1820
AgentDeletionStatus,
1921
AgentThread,
@@ -34,6 +36,7 @@
3436
Dataset,
3537
Evaluation,
3638
EvaluationSchedule,
39+
EvaluationTarget,
3740
EvaluatorConfiguration,
3841
FileDeletionStatus,
3942
FileListResponse,
@@ -46,8 +49,8 @@
4649
FunctionName,
4750
FunctionToolDefinition,
4851
IncompleteRunDetails,
49-
IndexResource,
5052
InputData,
53+
MAASModelConfig,
5154
MessageAttachment,
5255
MessageContent,
5356
MessageDelta,
@@ -145,6 +148,7 @@
145148
SubmitToolOutputsAction,
146149
SubmitToolOutputsDetails,
147150
SystemData,
151+
TargetModelConfig,
148152
ThreadDeletionStatus,
149153
ThreadMessage,
150154
ThreadMessageOptions,
@@ -185,6 +189,7 @@
185189
AgentsApiToolChoiceOptionMode,
186190
AgentsNamedToolChoiceType,
187191
AuthenticationType,
192+
AzureAISearchQueryType,
188193
ConnectionType,
189194
DoneEvent,
190195
ErrorEvent,
@@ -224,6 +229,8 @@
224229
from ._patch import patch_sdk as _patch_sdk
225230

226231
__all__ = [
232+
"AISearchIndexResource",
233+
"AOAIModelConfig",
227234
"Agent",
228235
"AgentDeletionStatus",
229236
"AgentThread",
@@ -244,6 +251,7 @@
244251
"Dataset",
245252
"Evaluation",
246253
"EvaluationSchedule",
254+
"EvaluationTarget",
247255
"EvaluatorConfiguration",
248256
"FileDeletionStatus",
249257
"FileListResponse",
@@ -256,8 +264,8 @@
256264
"FunctionName",
257265
"FunctionToolDefinition",
258266
"IncompleteRunDetails",
259-
"IndexResource",
260267
"InputData",
268+
"MAASModelConfig",
261269
"MessageAttachment",
262270
"MessageContent",
263271
"MessageDelta",
@@ -355,6 +363,7 @@
355363
"SubmitToolOutputsAction",
356364
"SubmitToolOutputsDetails",
357365
"SystemData",
366+
"TargetModelConfig",
358367
"ThreadDeletionStatus",
359368
"ThreadMessage",
360369
"ThreadMessageOptions",
@@ -392,6 +401,7 @@
392401
"AgentsApiToolChoiceOptionMode",
393402
"AgentsNamedToolChoiceType",
394403
"AuthenticationType",
404+
"AzureAISearchQueryType",
395405
"ConnectionType",
396406
"DoneEvent",
397407
"ErrorEvent",

Diff for: sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py

+26-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class AgentsNamedToolChoiceType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
3939
"""Tool type ``file_search``"""
4040
BING_GROUNDING = "bing_grounding"
4141
"""Tool type ``bing_grounding``"""
42-
MICROSOFT_FABRIC = "fabric_aiskill"
43-
"""Tool type ``fabric_aiskill``"""
42+
MICROSOFT_FABRIC = "fabric_dataagent"
43+
"""Tool type ``fabric_dataagent``"""
4444
SHAREPOINT = "sharepoint_grounding"
4545
"""Tool type ``sharepoint_grounding``"""
4646
AZURE_AI_SEARCH = "azure_ai_search"
@@ -50,6 +50,8 @@ class AgentsNamedToolChoiceType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
5050
class AgentStreamEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta):
5151
"""Each event in a server-sent events stream has an ``event`` and ``data`` property:
5252
53+
54+
5355
.. code-block::
5456
5557
event: thread.created
@@ -58,7 +60,7 @@ class AgentStreamEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta):
5860
We emit events whenever a new object is created, transitions to a new state, or is being
5961
streamed in parts (deltas). For example, we emit ``thread.run.created`` when a new run
6062
is created, ``thread.run.completed`` when a run completes, and so on. When an Agent chooses
61-
to create a message during a run, we emit a ``thread.message.created event``\\ , a
63+
to create a message during a run, we emit a ``thread.message.created event``, a
6264
``thread.message.in_progress`` event, many ``thread.message.delta`` events, and finally a
6365
``thread.message.completed`` event.
6466
@@ -134,10 +136,27 @@ class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
134136
"""Entra ID authentication (formerly known as AAD)"""
135137
SAS = "SAS"
136138
"""Shared Access Signature (SAS) authentication"""
139+
CUSTOM = "CustomKeys"
140+
"""Custom authentication"""
137141
NONE = "None"
138142
"""No authentication"""
139143

140144

145+
class AzureAISearchQueryType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
146+
"""Available query types for Azure AI Search tool."""
147+
148+
SIMPLE = "simple"
149+
"""Query type ``simple``"""
150+
SEMANTIC = "semantic"
151+
"""Query type ``semantic``"""
152+
VECTOR = "vector"
153+
"""Query type ``vector``"""
154+
VECTOR_SIMPLE_HYBRID = "vector_simple_hybrid"
155+
"""Query type ``vector_simple_hybrid``"""
156+
VECTOR_SEMANTIC_HYBRID = "vector_semantic_hybrid"
157+
"""Query type ``vector_semantic_hybrid``"""
158+
159+
141160
class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
142161
"""The Type (or category) of the connection."""
143162

@@ -153,6 +172,10 @@ class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
153172
"""Azure AI Search"""
154173
API_KEY = "ApiKey"
155174
"""Generic connection that uses API Key authentication"""
175+
CUSTOM = "CustomKeys"
176+
"""Generic connection that uses Custom authentication"""
177+
COGNITIVE_SERVICE = "CognitiveService"
178+
"""Cognitive Service"""
156179

157180

158181
class DoneEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta):
@@ -301,7 +324,6 @@ class MessageStreamEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta):
301324
class OpenApiAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
302325
"""Authentication type for OpenApi endpoint. Allowed types are:
303326
304-
305327
* Anonymous (no authentication required)
306328
* Connection (requires connection_id to endpoint, as setup in AI Foundry)
307329
* Managed_Identity (requires audience for identity based auth).

0 commit comments

Comments
 (0)