Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Utilizzo GetPrompt
con un AWS SDK
Il seguente esempio di codice mostra come utilizzareGetPrompt
.
- Python
-
- SDK per Python (Boto3)
-
Richiedi un prompt gestito da Amazon Bedrock.
def get_prompt(client, prompt_id):
"""
Gets an Amazon Bedrock managed prompt.
Args:
client: Amazon Bedrock Agent boto3 client.
prompt_id (str): The identifier of the prompt that you want to get.
Returns:
dict: The response from the GetPrompt operation.
"""
try:
logger.info("Getting prompt ID: %s.", prompt_id)
response = client.get_prompt(
promptIdentifier=prompt_id
)
logger.info("Retrieved prompt ID: %s. Name: %s",
prompt_id,
response['name'])
return response
except ClientError as e:
logger.exception("Client error getting prompt: %s", str(e))
raise
except Exception as e:
logger.exception("Unexpected error getting prompt: %s", str(e))
raise
Per un elenco completo delle guide per sviluppatori AWS SDK e degli esempi di codice, consulta. Utilizzo di Amazon Bedrock con un AWS SDK Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell'SDK.