Skip to content

Commit e862b63

Browse files
committed
updating File Search code
1 parent b15745c commit e862b63

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

articles/ai-services/agents/how-to/tools/file-search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ File search augments agents with knowledge from outside its model, such as propr
3535
## Dependency on agent setup
3636

3737
### Basic agent setup
38-
The file search tool has the same functionality as AOAI Assistants. Microsoft managed search and storage resources are used.
38+
The file search tool has the same functionality as Azure OpenAI Assistants. Microsoft managed search and storage resources are used.
3939
- Uploaded files get stored in Microsoft managed storage
4040
- A vector store is created using a Microsoft managed search resource
4141

articles/ai-services/agents/includes/file-search/upload-files-code-examples.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Create a client object, which will contain the connection string for connecting
1414
```python
1515
import os
1616
from azure.ai.projects import AIProjectClient
17-
from azure.ai.projects.models import FileSearchTool, VectorStoreDataSource, VectorStoreDataSourceAssetType
17+
from azure.ai.projects.models import FileSearchTool
1818
from azure.identity import DefaultAzureCredential
1919

2020

@@ -42,7 +42,7 @@ using NUnit.Framework;
4242
// At the moment, it should be in the format "<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<ProjectName>"
4343
// Customer needs to login to Azure subscription via Azure CLI and set the environment variables
4444
var connectionString = TestEnvironment.AzureAICONNECTIONSTRING;
45-
AgentsClient client = new AgentsClient(connectionString, new DefaultAzureCredential());
45+
AgentsClient client = new AgentsClient(connectionString, new DefaultAzureCredentia());
4646
```
4747

4848
---
@@ -56,12 +56,17 @@ Vector stores are created using message attachments that have a default expirati
5656
# [Python](#tab/python)
5757

5858
```python
59-
# We will upload the local file to Azure and will use it for vector store creation.
59+
# We will upload the local file and will use it for vector store creation.
60+
61+
#upload a file
62+
file = project_client.agents.upload_file_and_poll(file_path='./data/product_info_1.md', purpose="assistants")
63+
print(f"Uploaded file, file ID: {file.id}")
64+
6065
_, asset_uri = project_client.upload_file("./data/product_info_1.md")
6166
print(f"Uploaded file, asset URI: {asset_uri}")
62-
# create a vector store with no file and wait for it to be processed
63-
ds = VectorStoreDataSource(asset_identifier=asset_uri, asset_type=VectorStoreDataSourceAssetType.URI_ASSET)
64-
vector_store = project_client.agents.create_vector_store_and_poll(data_sources=[ds], name="sample_vector_store")
67+
68+
# create a vector store with the file you uploaded
69+
vector_store = project_client.agents.create_vector_store_and_poll(file_ids=[file.id], name="my_vectorstore")
6570
print(f"Created vector store, vector store ID: {vector_store.id}")
6671
```
6772

0 commit comments

Comments
 (0)