DeleteAgent mit einem AWS SDK verwenden - Amazon Bedrock

DeleteAgent mit einem AWS SDK verwenden

Die folgenden Code-Beispiele zeigen, wie verwendet wird DeleteAgent.

Beispiele für Aktionen sind Codeauszüge aus größeren Programmen und müssen im Kontext ausgeführt werden. Im folgenden Codebeispiel können Sie diese Aktion im Kontext sehen:

JavaScript
SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel- einrichten und ausführen.

Löschen eines Agenten.

import { fileURLToPath } from "node: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); }
  • Weitere API-Informationen finden Sie unter DeleteAgent in der AWS SDK für JavaScript-API-Referenz.

Python
SDK für Python (Boto3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel- einrichten und ausführen.

Löschen eines Agenten.

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 Amazon Bedrock Agents 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
  • Weitere API-Informationen finden Sie unter DeleteAgent in der API-Referenz zum AWS SDK für Python (Boto3).

Eine vollständige Liste der AWS-SDK-Entwicklerhandbücher und Code-Beispiele finden Sie unter Verwendung von Amazon Bedrock mit einem AWS SDK. Dieses Thema enthält auch Informationen zu den ersten Schritten und Details zu früheren SDK-Versionen.