Sono disponibili altri esempi per SDK AWS nel repository GitHub della documentazione degli esempi per SDK AWS
Utilizzo di GetPrompt con un SDK AWS
L’esempio di codice seguente mostra come utilizzare GetPrompt.
- Python
-
- SDK per Python (Boto3)
-
Nota
Ulteriori informazioni su GitHub. Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel Repository di esempi di codice AWS
. Ottiene 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 informazioni dettagliate sull’API, consulta GetPrompt nella documentazione di riferimento dell’API AWS SDK per Python (Boto3).
-
GetKnowledgeBase
ListAgentActionGroups