Skip to content

Commit 61a8ba6

Browse files
bobogogo1990Bo Gou
andauthored
update bing custom search sample (Azure#33981)
### Packages impacted by this PR The instanceName should be an predefined env variable, it is not the connectionName ### Issues associated with this PR ### Describe the problem that is addressed by this PR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: Bo Gou <[email protected]>
1 parent 471864c commit 61a8ba6

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

sdk/ai/ai-projects/samples-dev/agents/agentsBingCustomSearch.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import "dotenv/config";
1818

1919
const connectionString =
2020
process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || "<project connection string>";
21+
const bingCustomSearchInstanceName =
22+
process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || "<instance-name>";
2123

2224
export async function main(): Promise<void> {
2325
// Create an Azure AI Client from a connection string, copied from your AI Foundry project.
@@ -36,7 +38,8 @@ export async function main(): Promise<void> {
3638
const bingCustomSearchTool = ToolUtility.createBingCustomSearchTool([
3739
{
3840
connectionId: bingCustomSearchConnection.id,
39-
instanceName: bingCustomSearchConnection.name,
41+
// please do not use bingCustomSearchConnection.name here
42+
instanceName: bingCustomSearchInstanceName,
4043
},
4144
]);
4245

@@ -72,7 +75,7 @@ export async function main(): Promise<void> {
7275
run = await client.agents.getRun(thread.id, run.id);
7376
}
7477
if (run.status === "failed") {
75-
console.log(`Run failed: ${run.lastError}`);
78+
console.log(`Run failed: ${JSON.stringify(run, null, 2)}`);
7679
}
7780
console.log(`Run finished with status: ${run.status}`);
7881

sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingCustomSearch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ require("dotenv/config");
1616

1717
const connectionString =
1818
process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || "<project connection string>";
19+
const bingCustomSearchInstanceName =
20+
process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || "<instance-name>";
1921

2022
async function main() {
2123
// Create an Azure AI Client from a connection string, copied from your AI Foundry project.
@@ -34,7 +36,8 @@ async function main() {
3436
const bingCustomSearchTool = ToolUtility.createBingCustomSearchTool([
3537
{
3638
connectionId: bingCustomSearchConnection.id,
37-
instanceName: bingCustomSearchConnection.name,
39+
// please do not use bingCustomSearchConnection.name here
40+
instanceName: bingCustomSearchInstanceName,
3841
},
3942
]);
4043

@@ -70,7 +73,7 @@ async function main() {
7073
run = await client.agents.getRun(thread.id, run.id);
7174
}
7275
if (run.status === "failed") {
73-
console.log(`Run failed: ${run.lastError}`);
76+
console.log(`Run failed: ${JSON.stringify(run, null, 2)}`);
7477
}
7578
console.log(`Run finished with status: ${run.status}`);
7679

sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingCustomSearch.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import "dotenv/config";
1717

1818
const connectionString =
1919
process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || "<project connection string>";
20+
const bingCustomSearchInstanceName =
21+
process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || "<instance-name>";
2022

2123
export async function main(): Promise<void> {
2224
// Create an Azure AI Client from a connection string, copied from your AI Foundry project.
@@ -35,7 +37,8 @@ export async function main(): Promise<void> {
3537
const bingCustomSearchTool = ToolUtility.createBingCustomSearchTool([
3638
{
3739
connectionId: bingCustomSearchConnection.id,
38-
instanceName: bingCustomSearchConnection.name,
40+
// please do not use bingCustomSearchConnection.name here
41+
instanceName: bingCustomSearchInstanceName,
3942
},
4043
]);
4144

@@ -71,7 +74,7 @@ export async function main(): Promise<void> {
7174
run = await client.agents.getRun(thread.id, run.id);
7275
}
7376
if (run.status === "failed") {
74-
console.log(`Run failed: ${run.lastError}`);
77+
console.log(`Run failed: ${JSON.stringify(run, null, 2)}`);
7578
}
7679
console.log(`Run finished with status: ${run.status}`);
7780

0 commit comments

Comments
 (0)