Skip to content

Commit 9928194

Browse files
Jarno Hakulinennick863
andauthored
Jhakulin/list op update (#40871)
* update list operations * update tests * update README * update * Fix the instrumentation tests (#40877) * Fix the instrumentation tests * Better instrumentation handling * pylint --------- Co-authored-by: Nikolay Rovinskiy <[email protected]>
1 parent 1d76e38 commit 9928194

File tree

89 files changed

+1876
-1880
lines changed

Some content is hidden

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

89 files changed

+1876
-1880
lines changed

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

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ Here is an example:
293293
```python
294294
conn_id = os.environ["AZURE_BING_CONNECTION_ID"]
295295

296-
print(conn_id)
297-
298296
# Initialize agent bing tool and add the connection id
299297
bing = BingGroundingTool(connection_id=conn_id)
300298

@@ -351,7 +349,7 @@ get sensible result, the index needs to have "embedding", "token", "category" an
351349
```python
352350
# Fetch and log all messages
353351
messages = agents_client.messages.list(thread_id=thread.id, order=ListSortOrder.ASCENDING)
354-
for message in messages.data:
352+
for message in messages:
355353
if message.role == MessageRole.AGENT and message.url_citation_annotations:
356354
placeholder_annotations = {
357355
annotation.text: f" [see {annotation.url_citation.title}] ({annotation.url_citation.url})"
@@ -1044,13 +1042,10 @@ To retrieve messages from agents, use the following example:
10441042

10451043
```python
10461044
messages = agents_client.messages.list(thread_id=thread.id, order=ListSortOrder.ASCENDING)
1047-
1048-
# The messages are following in the reverse order,
1049-
# we will iterate them and output only text contents.
1050-
for data_point in messages.data:
1051-
last_message_content = data_point.content[-1]
1052-
if isinstance(last_message_content, MessageTextContent):
1053-
print(f"{data_point.role}: {last_message_content.text.value}")
1045+
for msg in messages:
1046+
if msg.text_messages:
1047+
last_text = msg.text_messages[-1]
1048+
print(f"{msg.role}: {last_text.text.value}")
10541049
```
10551050

10561051
<!-- END SNIPPET -->
@@ -1069,20 +1064,22 @@ Here is an example retrieving file ids from messages and save to the local drive
10691064
messages = agents_client.messages.list(thread_id=thread.id)
10701065
print(f"Messages: {messages}")
10711066

1072-
for image_content in messages.image_contents:
1073-
file_id = image_content.image_file.file_id
1074-
print(f"Image File ID: {file_id}")
1075-
file_name = f"{file_id}_image_file.png"
1076-
agents_client.files.save(file_id=file_id, file_name=file_name)
1077-
print(f"Saved image file to: {Path.cwd() / file_name}")
1078-
1079-
for file_path_annotation in messages.file_path_annotations:
1080-
print(f"File Paths:")
1081-
print(f"Type: {file_path_annotation.type}")
1082-
print(f"Text: {file_path_annotation.text}")
1083-
print(f"File ID: {file_path_annotation.file_path.file_id}")
1084-
print(f"Start Index: {file_path_annotation.start_index}")
1085-
print(f"End Index: {file_path_annotation.end_index}")
1067+
for msg in messages:
1068+
# Save every image file in the message
1069+
for img in msg.image_contents:
1070+
file_id = img.image_file.file_id
1071+
file_name = f"{file_id}_image_file.png"
1072+
agents_client.files.save(file_id=file_id, file_name=file_name)
1073+
print(f"Saved image file to: {Path.cwd() / file_name}")
1074+
1075+
# Print details of every file-path annotation
1076+
for ann in msg.file_path_annotations:
1077+
print("File Paths:")
1078+
print(f" Type: {ann.type}")
1079+
print(f" Text: {ann.text}")
1080+
print(f" File ID: {ann.file_path.file_id}")
1081+
print(f" Start Index: {ann.start_index}")
1082+
print(f" End Index: {ann.end_index}")
10861083
```
10871084

10881085
<!-- END SNIPPET -->

sdk/ai/azure-ai-agents/apiview-properties.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@
7272
"azure.ai.agents.models.MessageTextUrlCitationAnnotation": "Azure.AI.Agents.MessageTextUrlCitationAnnotation",
7373
"azure.ai.agents.models.MessageTextUrlCitationDetails": "Azure.AI.Agents.MessageTextUrlCitationDetails",
7474
"azure.ai.agents.models.MicrosoftFabricToolDefinition": "Azure.AI.Agents.MicrosoftFabricToolDefinition",
75-
"azure.ai.agents.models.OpenAIPageableListOfAgent": "Azure.AI.Agents.OpenAIPageableListOf",
76-
"azure.ai.agents.models.OpenAIPageableListOfAgentThread": "Azure.AI.Agents.OpenAIPageableListOf",
77-
"azure.ai.agents.models.OpenAIPageableListOfRunStep": "Azure.AI.Agents.OpenAIPageableListOf",
78-
"azure.ai.agents.models.OpenAIPageableListOfThreadMessage": "Azure.AI.Agents.OpenAIPageableListOf",
79-
"azure.ai.agents.models.OpenAIPageableListOfThreadRun": "Azure.AI.Agents.OpenAIPageableListOf",
80-
"azure.ai.agents.models.OpenAIPageableListOfVectorStore": "Azure.AI.Agents.OpenAIPageableListOf",
81-
"azure.ai.agents.models.OpenAIPageableListOfVectorStoreFile": "Azure.AI.Agents.OpenAIPageableListOf",
8275
"azure.ai.agents.models.OpenApiAuthDetails": "Azure.AI.Agents.OpenApiAuthDetails",
8376
"azure.ai.agents.models.OpenApiAnonymousAuthDetails": "Azure.AI.Agents.OpenApiAnonymousAuthDetails",
8477
"azure.ai.agents.models.OpenApiConnectionAuthDetails": "Azure.AI.Agents.OpenApiConnectionAuthDetails",

sdk/ai/azure-ai-agents/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-agents",
5-
"Tag": "python/ai/azure-ai-agents_2d7743fd82"
5+
"Tag": "python/ai/azure-ai-agents_dab4ae41b1"
66
}

sdk/ai/azure-ai-agents/azure/ai/agents/_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCr
4646
self.endpoint = endpoint
4747
self.credential = credential
4848
self.api_version = api_version
49-
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cognitiveservices.azure.com/.default"])
49+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
5050
kwargs.setdefault("sdk_moniker", "ai-agents/{}".format(VERSION))
5151
self.polling_interval = kwargs.get("polling_interval", 30)
5252
self._configure(**kwargs)

sdk/ai/azure-ai-agents/azure/ai/agents/aio/_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848
self.endpoint = endpoint
4949
self.credential = credential
5050
self.api_version = api_version
51-
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cognitiveservices.azure.com/.default"])
51+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://ai.azure.com/.default"])
5252
kwargs.setdefault("sdk_moniker", "ai-agents/{}".format(VERSION))
5353
self.polling_interval = kwargs.get("polling_interval", 30)
5454
self._configure(**kwargs)

0 commit comments

Comments
 (0)