Skip to content

Commit e51bc80

Browse files
committed
code
1 parent 3143fe4 commit e51bc80

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,23 @@ AgentsClient agentClient = projectClient.GetAgentsClient();
6363
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/).
6464

6565
```csharp
66-
ConnectionResponse bingConnection = projectClient.GetConnectionsClient().GetConnection(bingConnectionName);
66+
AgentsClient agentClient = projectClient.GetAgentsClient();
67+
ConnectionResponse bingConnection = await projectClient.GetConnectionsClient().GetConnectionAsync(bingConnectionName);
6768
var connectionId = bingConnection.Id;
69+
var instanceName = "<your_config_instance_name>";
6870

69-
ToolConnectionList connectionList = new()
70-
{
71-
ConnectionList = { new ToolConnection(connectionId) }
72-
};
73-
BingGroundingToolDefinition bingGroundingTool = new(connectionList);
74-
75-
Agent agent = agentClient.CreateAgent(
76-
model: modelDeploymentName,
77-
name: "my-assistant",
78-
instructions: "You are a helpful assistant.",
79-
tools: [bingGroundingTool]);
71+
SearchConfigurationList searchConfigurationList = new SearchConfigurationList(
72+
new List<SearchConfiguration>
73+
{
74+
new SearchConfiguration(connectionId, instanceName)
75+
});
76+
77+
BingCustomSearchToolDefinition bingGroundingTool = new(searchConfigurationList);
78+
Agent agent = await agentClient.CreateAgentAsync(
79+
model: modelDeploymentName,
80+
name: "my-assistant",
81+
instructions: "You are a helpful assistant.",
82+
tools: [ bingGroundingTool ]);
8083
```
8184

8285
## Step 3: Create a thread

0 commit comments

Comments
 (0)