@@ -6,7 +6,7 @@ services: cognitive-services
6
6
manager : nitinme
7
7
ms.service : azure-ai-agent-service
8
8
ms.topic : how-to
9
- ms.date : 05/28 /2025
9
+ ms.date : 07/02 /2025
10
10
author : aahill
11
11
ms.author : aahi
12
12
zone_pivot_groups : selection-bing-grounding-code
@@ -78,7 +78,7 @@ file = project_client.agents.files.upload_and_poll(file_path=file_path, purpose=
78
78
print (f " Uploaded file, file ID: { file .id} " )
79
79
80
80
# Create a vector store with the uploaded file
81
- vector_store = project_client.agents.create_vector_store_and_poll (file_ids = [file .id], name = " my_vectorstore" )
81
+ vector_store = project_client.agents.vector_stores.create_and_poll (file_ids = [file .id], name = " my_vectorstore" )
82
82
print (f " Created vector store, vector store ID: { vector_store.id} " )
83
83
```
84
84
@@ -134,7 +134,7 @@ if run.status == "failed":
134
134
print (f " Run failed: { run.last_error} " )
135
135
136
136
# Cleanup resources
137
- project_client.agents.delete_vector_store (vector_store.id)
137
+ project_client.agents.vector_stores.delete (vector_store.id)
138
138
print (" Deleted vector store" )
139
139
140
140
project_client.agents.delete_file(file_id = file .id)
@@ -145,8 +145,16 @@ print("Deleted agent")
145
145
146
146
# Fetch and log all messages from the thread
147
147
messages = project_client.agents.messages.list(thread_id = thread.id)
148
- for message in messages.data:
149
- print (f " Role: { message.role} , Content: { message.content} " )
148
+ file_name = os.path.split(file_path)[- 1 ]
149
+ for msg in messages:
150
+ if msg.text_messages:
151
+ last_text = msg.text_messages[- 1 ].text.value
152
+ for annotation in msg.text_messages[- 1 ].text.annotations:
153
+ citation = (
154
+ file_name if annotation.file_citation.file_id == file .id else annotation.file_citation.file_id
155
+ )
156
+ last_text = last_text.replace(annotation.text, f " [ { citation} ] " )
157
+ print (f " { msg.role} : { last_text} " )
150
158
```
151
159
::: zone-end
152
160
0 commit comments