-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathget-agent.js
More file actions
42 lines (33 loc) · 1.39 KB
/
get-agent.js
File metadata and controls
42 lines (33 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { fileURLToPath } from "node:url";
import { checkForPlaceholders } from "../lib/utils.js";
import {
BedrockAgentClient,
GetAgentCommand,
} from "@aws-sdk/client-bedrock-agent";
/**
* Retrieves the details of an Amazon Bedrock Agent.
*
* @param {string} agentId - The unique identifier of the agent.
* @param {string} [region='us-east-1'] - The AWS region in use.
* @returns {Promise<import("@aws-sdk/client-bedrock-agent").Agent>} An object containing the agent details.
*/
export const getAgent = async (agentId, region = "us-east-1") => {
const client = new BedrockAgentClient({ region });
const command = new GetAgentCommand({ agentId });
const response = await client.send(command);
return response.agent;
};
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
// Replace the placeholders for agentId with an existing agent's id.
// Ensure to remove the brackets '[]' before adding your data.
// The agentId must be an alphanumeric string with exactly 10 characters.
const agentId = "[ABC123DE45]";
// Check for unresolved placeholders in agentId.
checkForPlaceholders([agentId]);
console.log(`Retrieving agent with ID ${agentId}...`);
const agent = await getAgent(agentId);
console.log(agent);
}