You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -31,17 +31,17 @@ After you create a knowledge agent, you can update its properties at any time. I
31
31
32
32
+ Familiarity with [agentic retrieval concepts and use cases](search-agentic-retrieval-concept.md).
33
33
34
-
+ A [supported chat completion model](#supported-models) on Azure OpenAI.
35
-
36
34
+ Azure AI Search, in any [region that provides semantic ranker](search-region-support.md), on the basic pricing tier or higher. Your search service must have a [managed identity](search-how-to-managed-identities.md) for role-based access to the model.
37
35
38
-
+Permissions on Azure AI Search. **Search Service Contributor** can create and manage a knowledge agent. **Search Index Data Reader** can run queries. Instructions are provided in this article. [Quickstart: Connect to a search service](/azure/search/search-get-started-rbac?pivots=rest) explains how to configure roles and get a personal access token for REST calls.
36
+
+A [supported chat completion model](#supported-models) on Azure OpenAI.
39
37
40
-
+ A [knowledge source](search-knowledge-source-overview.md) that identifies searchable content used by the agent. It can be either a [search index knowledge source](search-knowledge-source-how-to-index.md) or a [blob knowledge source](search-knowledge-source-how-to-blob.md)
38
+
+ Permission requirements. **Search Service Contributor** can create and manage a knowledge agent. **Search Index Data Reader** can run queries. Instructions are provided in this article. [Quickstart: Connect to a search service](/azure/search/search-get-started-rbac?pivots=rest) explains how to configure roles and get a personal access token for REST calls.
39
+
40
+
+ Content requirements. A [knowledge source](search-knowledge-source-overview.md) that identifies searchable content used by the agent. It can be either a [search index knowledge source](search-knowledge-source-how-to-index.md) or a [blob knowledge source](search-knowledge-source-how-to-blob.md)
41
41
42
42
+ API requirements. To create or use a knowledge agent, use the [2025-08-01-preview](/rest/api/searchservice/operation-groups?view=rest-searchservice-2025-08-01-preview&preserve-view=true) data plane REST API. Or, use a preview package of an Azure SDK that provides knowledge agent APIs: [Azure SDK for Python](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/search/azure-search-documents/CHANGELOG.md), [Azure SDK for .NET](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/CHANGELOG.md#1170-beta3-2025-03-25), [Azure SDK for Java](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/search/azure-search-documents/CHANGELOG.md). **There's no Azure portal support knowledge agents at this time**.
43
43
44
-
To follow the steps in this guide, we recommend [Visual Studio Code](https://code.visualstudio.com/download) with a [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) for sending preview REST API calls to Azure AI Search. T
44
+
To follow the steps in this guide, we recommend [Visual Studio Code](https://code.visualstudio.com/download) with a [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) for sending preview REST API calls to Azure AI Search or the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) and [Jupyter package](https://pypi.org/project/jupyter/).
45
45
46
46
## Deploy a model for agentic retrieval
47
47
@@ -72,7 +72,7 @@ Use Azure OpenAI or an equivalent open source model:
72
72
73
73
Azure AI Search needs access to the chat completion model. You can use key-based or role-based authentication (recommended).
74
74
75
-
### Use role-based authentication
75
+
### [**Use roles**](#tab/rbac)
76
76
77
77
If you're using role-based authentication, on your Azure OpenAI resource, assign the **Cognitive Services User** role to a search service managed identity.
78
78
@@ -96,7 +96,7 @@ In Azure, you must have **Owner** or **User Access Administrator** permissions o
96
96
> [!IMPORTANT]
97
97
> If you use role-based authentication, be sure to remove all references to the API key in your requests. In a request that specifies both approaches, the API key is used instead of roles.
98
98
99
-
### Use key-based authentication
99
+
### [**Use keys**](#tab/keys)
100
100
101
101
You can use API keys if you don't have permission to create role assignments.
102
102
@@ -114,10 +114,94 @@ You can use API keys if you don't have permission to create role assignments.
114
114
@api-key: {{search-api-key}}
115
115
```
116
116
117
+
---
118
+
117
119
## Check for existing knowledge agents
118
120
119
121
The following request lists knowledge agents by name. Within the knowledge agents collection, all knowledge agents must be uniquely named. It's helpful to know about existing knowledge agents for reuse or for naming new agents.
120
122
123
+
### [**Python**](#tab/python-get-agents)
124
+
125
+
```python
126
+
# List existing knowledge agents on the search service
127
+
from azure.search.documents.indexes import SearchIndexClient
print(f"Knowledge agent '{knowledge_agent_name}' created or updated successfully.")
265
+
```
266
+
267
+
### [**REST**](#tab/rest-create-agent)
268
+
145
269
```http
146
270
@search-url=<YOUR SEARCH SERVICE URL>
147
271
@agent-name=<YOUR AGENT NAME>
@@ -242,14 +366,68 @@ PUT {{search-url}}/agents/{{agent-name}}?api-version=2025-08-01-preview
242
366
243
367
+`encryptionKey` is optional. Include an encryption key definition if you're supplementing with [customer-managed keys](search-security-manage-encryption-keys.md).
244
368
245
-
<!-- --- -->
369
+
---
246
370
247
371
## Query the knowledge agent
248
372
249
-
Call the **retrieve** action on the knowledge agent object to confirm the model connection and return a response. Use the [2025-08-01-preview](/rest/api/searchservice/operation-groups?view=rest-searchservice-2025-08-01-preview&preserve-view=true) data plane REST API or an Azure SDK preview package that provides equivalent functionality for this task.
373
+
Call the **retrieve** action on the knowledge agent object to confirm the model connection and return a response. Use the [2025-08-01-preview](/rest/api/searchservice/operation-groups?view=rest-searchservice-2025-08-01-preview&preserve-view=true) data plane REST API or an Azure SDK preview package that provides equivalent functionality for this task. For more information about the **retrieve** API and the shape of the response, see [Retrieve data using a knowledge agent in Azure AI Search](search-agentic-retrieval-how-to-retrieve.md).
250
374
251
375
Replace "where does the ocean look green?" with a query string that's valid for your search index.
252
376
377
+
### [**Python**](#tab/python-query-agent)
378
+
379
+
Start with instructions.
380
+
381
+
```python
382
+
instructions ="""
383
+
A Q&A agent that can answer questions about the Earth at night.
384
+
If you don't have the answer, respond with "I don't know".
385
+
"""
386
+
387
+
messages = [
388
+
{
389
+
"role": "system",
390
+
"content": instructions
391
+
}
392
+
]
393
+
```
394
+
395
+
Then send the query.
396
+
397
+
```python
398
+
from azure.search.documents.agent import KnowledgeAgentRetrievalClient
399
+
from azure.search.documents.agent.models import KnowledgeAgentRetrievalRequest, KnowledgeAgentMessage, KnowledgeAgentMessageTextContent, SearchIndexKnowledgeSourceParams
result = agent_client.retrieve(retrieval_request=req, api_version=search_api_version)
426
+
print(f"Retrieved content from '{knowledge_source_name}' successfully.")
427
+
```
428
+
429
+
### [**REST**](#tab/rest-query-agent)
430
+
253
431
```http
254
432
# Send grounding request
255
433
POST {{search-url}}/agents/{{agent-name}}/retrieve?api-version=2025-08-01-preview
@@ -301,55 +479,34 @@ The response to the previous query might look like this:
301
479
}
302
480
]
303
481
}
304
-
],
482
+
]
305
483
```
306
484
485
+
---
307
486
308
-
<!-- ```http
309
-
# Send grounding request
310
-
POST {{search-url}}/agents/{{agent-name}}/retrieve?api-version=2025-08-01-preview
311
-
Content-Type: application/json
312
-
Authorization: Bearer {{accessToken}}
487
+
## Delete an agent
313
488
314
-
{
315
-
"messages" : [
316
-
{
317
-
"role" : "assistant",
318
-
"content" : [
319
-
{ "type" : "text", "text" : "You are a helpful assistant for Contoso Human Resources. You have access to a search index containing guidelines about health care coverage for Washington state. If you can't find the answer in the search, say you don't know." }
320
-
]
321
-
},
322
-
{
323
-
"role" : "user",
324
-
"content" : [
325
-
{ "type" : "text", "text" : "What are my vision benefits?" }
326
-
]
327
-
}
328
-
],
329
-
"targetIndexParams" : [
330
-
{
331
-
"indexName" : "{{index-name}}",
332
-
"filterAddOn" : "State eq 'WA'",
333
-
"IncludeReferenceSourceData": true,
334
-
"rerankerThreshold" : 2.5
335
-
"maxDocsForReranker": 250
336
-
}
337
-
]
338
-
}
339
-
``` -->
489
+
If you no longer need the agent, or if you need to rebuild it on the search service, use this request to delete the current object.
340
490
341
-
For more information about the **retrieve** API and the shape of the response, see [Retrieve data using a knowledge agent in Azure AI Search](search-agentic-retrieval-how-to-retrieve.md).
491
+
### [**Python**](#tab/python-delete-agent)
342
492
343
-
## Delete an agent
493
+
```python
494
+
from azure.search.documents.indexes import SearchIndexClient
344
495
345
-
If you no longer need the agent, or if you need to rebuild it on the search service, use this request to delete the current object.
0 commit comments