AWS SDK 또는 GetAgent CLI와 함께 사용 - Amazon Bedrock

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS SDK 또는 GetAgent CLI와 함께 사용

다음 코드 예제는 GetAgent의 사용 방법을 보여줍니다.

작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.

JavaScript
JavaScript (v3) 용 SDK
참고

더 많은 내용이 있습니다. GitHub AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

에이전트를 가져옵니다.

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import { fileURLToPath } from "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); }
  • API 세부 정보는 AWS SDK for JavaScript API GetAgent참조를 참조하십시오.

Python
SDK for Python(Boto3)
참고

자세한 내용은 에서 확인할 수 GitHub 있습니다. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

에이전트를 가져옵니다.

def get_agent(self, agent_id, log_error=True): """ Gets information about an agent. :param agent_id: The unique identifier of the agent. :param log_error: Whether to log any errors that occur when getting the agent. If True, errors will be logged to the logger. If False, errors will still be raised, but not logged. :return: The information about the requested agent. """ try: response = self.client.get_agent(agentId=agent_id) agent = response["agent"] except ClientError as e: if log_error: logger.error(f"Couldn't get agent {agent_id}. {e}") raise else: return agent
  • API에 대한 자세한 내용은 파이썬용AWS SDK (Boto3) API 레퍼런스를 참조하십시오 GetAgent.

AWS SDK 개발자 가이드 및 코드 예제의 전체 목록은 을 참조하십시오. AWS SDK와 함께 이 서비스 사용 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.