@@ -6,7 +6,7 @@ services: cognitive-services
66manager : nitinme
77ms.service : azure-ai-agent-service
88ms.topic : how-to
9- ms.date : 05/28 /2025
9+ ms.date : 07/02 /2025
1010author : aahill
1111ms.author : aahi
1212zone_pivot_groups : selection-bing-grounding-code
@@ -78,7 +78,7 @@ file = project_client.agents.files.upload_and_poll(file_path=file_path, purpose=
7878print (f " Uploaded file, file ID: { file .id} " )
7979
8080# 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" )
8282print (f " Created vector store, vector store ID: { vector_store.id} " )
8383```
8484
@@ -134,7 +134,7 @@ if run.status == "failed":
134134 print (f " Run failed: { run.last_error} " )
135135
136136# Cleanup resources
137- project_client.agents.delete_vector_store (vector_store.id)
137+ project_client.agents.vector_stores.delete (vector_store.id)
138138print (" Deleted vector store" )
139139
140140project_client.agents.delete_file(file_id = file .id)
@@ -145,8 +145,16 @@ print("Deleted agent")
145145
146146# Fetch and log all messages from the thread
147147messages = 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} " )
150158```
151159::: zone-end
152160
0 commit comments