admin管理员组

文章数量:1188225

How do you use prompts stored in prompt management with a single invocation of the model? I setup a prompt with a variable called myInput but the docs don't specify how I can use this other than this example which implies I need to setup a flow just to use the prompt? Am I unable to use the prompt I created in prompt management directly with the InvokeModelCommand?

Nothing in the docs I'm seeing explicitly calls tells you how to specify prompt variables even though the modelId field states this in this doc:

If you use a prompt created through Prompt management, specify the ARN of the prompt.

import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime";
...
const bedrockClient = new BedrockRuntimeClient({});
...
const command = new InvokeModelCommand({
    modelId: "arn:aws:bedrock:us-east-1:12345678:prompt/ABCDEFG:2",
    body: JSON.stringify({
        promptVariables: {
            myInput: myInputValue
        }
    })
});

const response = await bedrockClient.send(command);

Specifying the modelId is ok but gives an error because the prompt variables can't be passed.

ValidationException: Malformed request for promptVariablesreceived

How do you use prompts stored in prompt management with a single invocation of the model? I setup a prompt with a variable called myInput but the docs don't specify how I can use this other than this example which implies I need to setup a flow just to use the prompt? Am I unable to use the prompt I created in prompt management directly with the InvokeModelCommand?

Nothing in the docs I'm seeing explicitly calls tells you how to specify prompt variables even though the modelId field states this in this doc:

If you use a prompt created through Prompt management, specify the ARN of the prompt.

import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime";
...
const bedrockClient = new BedrockRuntimeClient({});
...
const command = new InvokeModelCommand({
    modelId: "arn:aws:bedrock:us-east-1:12345678:prompt/ABCDEFG:2",
    body: JSON.stringify({
        promptVariables: {
            myInput: myInputValue
        }
    })
});

const response = await bedrockClient.send(command);

Specifying the modelId is ok but gives an error because the prompt variables can't be passed.

ValidationException: Malformed request for promptVariablesreceived
Share Improve this question asked Jan 24 at 20:27 AdamAdam 4,78011 gold badges57 silver badges90 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Although the InvokeModelCommand explicitly states you can specify the ARN of the prompt managed template, there appears to be no way to pass prompt variables as part of the request. The ConverseCommand supports it but not the InvokeModelCommand and the examples only show managed prompt templates being used in flows so for now I'm assuming those are the only two scenarios where they can be used unfortunately.

本文标签: amazon web servicesUsing AWS Bedrock Prompt Management with InvokeCommandStack Overflow