File tree Expand file tree Collapse file tree
apigw-lambda-bedrock-js-sam/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,18 +9,25 @@ export const handler = async (event) => {
99 //console.log(prompt)
1010 //const prompt = 'Write a text to be posted on my social media channels about how Amazon Bedrock works';
1111 const body = {
12- 'prompt' : "\n\nHuman:" + prompt + "\n\nAssistant:" ,
13- "temperature" : 0.5 ,
14- "top_p" : 1 ,
15- "top_k" : 250 ,
16- "max_tokens_to_sample" : 200 ,
17- "stop_sequences" : [ "\n\nHuman:" ]
18- }
12+ anthropic_version : "bedrock-2023-05-31" ,
13+ messages : [
14+ {
15+ role : "user" ,
16+ content : [
17+ {
18+ "type" : "text" ,
19+ "text" : prompt
20+ }
21+ ] ,
22+ } ,
23+ ] ,
24+ max_tokens : 200
25+ } ;
1926 const input = {
2027 body : JSON . stringify ( body ) ,
2128 contentType : "application/json" ,
2229 accept : "application/json" ,
23- modelId : "anthropic.claude-v2 " ,
30+ modelId : "global. anthropic.claude-sonnet-4-5-20250929-v1:0 " ,
2431 } ;
2532 const command = new InvokeModelCommand ( input ) ;
2633 const res = await client . send ( command ) ;
@@ -29,7 +36,7 @@ export const handler = async (event) => {
2936 //console.log(JSON.stringify(stringifiedResponse));
3037 const response = {
3138 statusCode : 200 ,
32- body : JSON . stringify ( stringifiedResponse ) ,
39+ body : stringifiedResponse ,
3340 } ;
3441 return response ;
35- } ;
42+ } ;
You can’t perform that action at this time.
0 commit comments