Use DeleteAgent com um AWS SDK ou CLI - Amazon Bedrock

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Use DeleteAgent com um AWS SDK ou CLI

Os exemplos de códigos a seguir mostram como usar DeleteAgent.

Exemplos de ações são trechos de código de programas maiores e devem ser executados em contexto. É possível ver essa ação no contexto no seguinte exemplo de código:

JavaScript
SDK para JavaScript (v3)
nota

Tem mais sobre GitHub. Encontre o exemplo completo e veja como configurar e executar no AWS Code Examples Repository.

Exclua um agente.

// 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, DeleteAgentCommand, } from "@aws-sdk/client-bedrock-agent"; /** * Deletes an Amazon Bedrock Agent. * * @param {string} agentId - The unique identifier of the agent to delete. * @param {string} [region='us-east-1'] - The AWS region in use. * @returns {Promise<import("@aws-sdk/client-bedrock-agent").DeleteAgentCommandOutput>} An object containing the agent id, the status, and some additional metadata. */ export const deleteAgent = (agentId, region = "us-east-1") => { const client = new BedrockAgentClient({ region }); const command = new DeleteAgentCommand({ agentId }); return client.send(command); }; // 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(`Deleting agent with ID ${agentId}...`); const response = await deleteAgent(agentId); console.log(response); }
  • Para obter detalhes da API, consulte DeleteAgenta Referência AWS SDK for JavaScript da API.

Python
SDK para Python (Boto3).
nota

Tem mais sobre GitHub. Encontre o exemplo completo e veja como configurar e executar no AWS Code Examples Repository.

Exclua um agente.

def delete_agent(self, agent_id): """ Deletes an Amazon Bedrock agent. :param agent_id: The unique identifier of the agent to delete. :return: The response from Agents for Bedrock if successful, otherwise raises an exception. """ try: response = self.client.delete_agent( agentId=agent_id, skipResourceInUseCheck=False ) except ClientError as e: logger.error(f"Couldn't delete agent. {e}") raise else: return response
  • Para obter detalhes da API, consulte a DeleteAgentReferência da API AWS SDK for Python (Boto3).

Para obter uma lista completa dos guias do desenvolvedor do AWS SDK e exemplos de código, consulteUsando esse serviço com um AWS SDK. Este tópico também inclui informações sobre como começar e detalhes sobre versões anteriores do SDK.