Skip to content

Commit 3419dd9

Browse files
Merge pull request #5846 from aahill/june-fixes
updating python code
2 parents 9e19e81 + 84dbd1e commit 3419dd9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

articles/ai-foundry/agents/how-to/tools/file-search-upload-files.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services: cognitive-services
66
manager: nitinme
77
ms.service: azure-ai-agent-service
88
ms.topic: how-to
9-
ms.date: 05/28/2025
9+
ms.date: 07/02/2025
1010
author: aahill
1111
ms.author: aahi
1212
zone_pivot_groups: selection-bing-grounding-code
@@ -78,7 +78,7 @@ file = project_client.agents.files.upload_and_poll(file_path=file_path, purpose=
7878
print(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")
8282
print(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)
138138
print("Deleted vector store")
139139

140140
project_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
147147
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}")
150158
```
151159
:::zone-end
152160

0 commit comments

Comments
 (0)