Skip to content

Commit 828b31d

Browse files
authored
Merge pull request #16 from lindazqli/patch-50
Update bing-code-samples.md
2 parents c08048e + 0b37ebc commit 828b31d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

articles/ai-services/agents/how-to/tools/bing-code-samples.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Use this article to find step-by-step instructions and code samples for Groundin
2020
## Prerequisites
2121

2222
* A [connected Grounding with Bing Search resource](./bing-grounding.md#setup).
23+
* Your connection ID needs to be in this format: `/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.CognitiveServices/accounts/<ai_service_name>/projects/<project_name>/connections/<connection_name>`
2324

2425
> [!IMPORTANT]
2526
> There are requirements for displaying Grounding with Bing Search results. See the [overview article](./bing-grounding.md#how-to-display-grounding-with-bing-search-results) for details.
@@ -401,15 +402,16 @@ Create a client object, which will contain the connection string for connecting
401402
>[!IMPORTANT]
402403
> 1. This REST API allows developers to invoke the Grounding with Bing Search tool through the Azure AI Foundry Agent Service. It does not send calls to the Grounding with Bing Search API directly.
403404
404-
Follow the [REST API Quickstart](../../quickstart.md?pivots=rest-api) to set the right values for the environment variables `AZURE_AI_AGENTS_TOKEN` and `AZURE_AI_AGENTS_ENDPOINT`. The client creation is demonstrated in the next section.
405+
Follow the [REST API Quickstart](../../quickstart.md?pivots=rest-api) to set the right values for the environment variables `AZURE_AI_AGENTS_TOKEN`, `AZURE_AI_FOUNDRY_PROJECT_ENDPOINT` and `API_VERSION`. The client creation is demonstrated in the next section.
405406
406407
407408
## Create an Agent with the Grounding with Bing search tool enabled
408409
409410
To make the Grounding with Bing search tool available to your agent, use a connection to initialize the tool and attach it to the agent. You can find your connection in the **connected resources** section of your project in the [Azure AI Foundry portal](https://ai.azure.com/).
410411
411412
```console
412-
curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=2025-05-01 \
413+
curl --request POST \
414+
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=$API_VERSION \
413415
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
414416
-H "Content-Type: application/json" \
415417
-d '{
@@ -438,7 +440,8 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=2025-05-01 \
438440
## Create a thread
439441
440442
```console
441-
curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=2025-05-01 \
443+
curl --request POST \
444+
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=$API_VERSION \
442445
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
443446
-H "Content-Type: application/json" \
444447
-d ''
@@ -447,7 +450,8 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=2025-05-01 \
447450
## Add a user question to the thread
448451
449452
```console
450-
curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
453+
curl --request POST \
454+
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=$API_VERSION \
451455
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
452456
-H "Content-Type: application/json" \
453457
-d '{
@@ -461,7 +465,8 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-versi
461465
Create a run and observe that the model uses the Grounding with Bing Search tool to provide a response to the user's question.
462466
463467
```console
464-
curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=2025-05-01 \
468+
curl --request POST \
469+
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=$API_VERSION \
465470
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
466471
-H "Content-Type: application/json" \
467472
-d '{
@@ -472,19 +477,21 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=2
472477
### Retrieve the status of the run
473478
474479
```console
475-
curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=2025-05-01 \
480+
curl --request GET \
481+
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=$API_VERSION \
476482
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
477483
```
478484
479485
### Retrieve the agent response
480486
481487
```console
482-
curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
488+
curl --request GET \
489+
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=$API_VERSION \
483490
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
484491
```
485492
486493
::: zone-end
487494
488495
## Next steps
489496
490-
[See the full sample for Grounding with Bing Search.](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/sample_agents_bing_grounding.py)
497+
[See the full sample for Grounding with Bing Search.](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/sample_agents_bing_grounding.py)

0 commit comments

Comments
 (0)