I've tested my prompt out in the AWS Bedrock Chat interface and I'm happy with it, so I'm now trying to convert it into code.
The issue is that I cannot understand how to attach a txt
document to my request.
I've clicked on the paperclip icon to add a file to my prompt. The file was then added to my textbox.
How does this look when using the @aws-sdk/client-bedrock-runtime
package?
So far I have:
const client = new BedrockRuntimeClient({
region: "us-east-1",
});
const data = await client.send(
new InvokeModelCommand({
modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0",
contentType: "application/json",
accept: "application/json",
body: JSON.stringify({
anthropic_version: "bedrock-2023-05-31",
max_tokens: 10000,
temperature: 1.0,
messages: [
{
role: "user",
content: "My prompt",
},
],
}),
})
);
I've tried adding my file contents as a message, but the output was completely different from what I get in the Bedrock interface.
I've looked at docs, I've asked various LLMs... Nothing.
Help?
I've tested my prompt out in the AWS Bedrock Chat interface and I'm happy with it, so I'm now trying to convert it into code.
The issue is that I cannot understand how to attach a txt
document to my request.
I've clicked on the paperclip icon to add a file to my prompt. The file was then added to my textbox.
How does this look when using the @aws-sdk/client-bedrock-runtime
package?
So far I have:
const client = new BedrockRuntimeClient({
region: "us-east-1",
});
const data = await client.send(
new InvokeModelCommand({
modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0",
contentType: "application/json",
accept: "application/json",
body: JSON.stringify({
anthropic_version: "bedrock-2023-05-31",
max_tokens: 10000,
temperature: 1.0,
messages: [
{
role: "user",
content: "My prompt",
},
],
}),
})
);
I've tried adding my file contents as a message, but the output was completely different from what I get in the Bedrock interface.
I've looked at docs, I've asked various LLMs... Nothing.
Help?
Share Improve this question asked Feb 7 at 21:20 lpetruccilpetrucci 1,6796 gold badges29 silver badges49 bronze badges1 Answer
Reset to default 1Based on Anthropic API reference, it seems that the body.messages[].content[].type
supports only
image
ortext
For example, for images, load the image as base64 string. For .txt
, I can only assume then you need to load the file content and just pass it as a text
type.
Reference: https://docs.anthropic.com/en/api/messages#body-messages-content