Skip to content

Commit 26e805c

Browse files
committed
chore: wip
1 parent 2fade3a commit 26e805c

File tree

1 file changed

+26
-0
lines changed
  • storage/framework/.stacks/core/cloud/src/cloud/lambda

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// TODO: get eslint on save formatting to work
2+
const AWS = require("aws-sdk")
3+
4+
const handler = async (event) => {
5+
const requestBody = JSON.parse(event.body)
6+
// Extract the 'question' property from the request body
7+
const question = requestBody.question
8+
console.log(`Question received: ${question}`)
9+
const bedrockRuntime = new AWS.BedrockRuntime({apiVersion: '2023-09-30'})
10+
const res = await bedrockRuntime.invokeModel({
11+
"modelId": "ai21.j2-ultra-v1",
12+
"contentType": "application/json",
13+
"accept": "*/*",
14+
"body": `{"prompt": "${question}","maxTokens":200,"temperature":0.7,"topP":1,"stopSequences":[],"countPenalty":{"scale":0},"presencePenalty":{"scale":0},"frequencyPenalty":{"scale":0}}`
15+
}).promise()
16+
17+
const responseBody = res.body.toString()
18+
return {
19+
statusCode: 200,
20+
body: responseBody,
21+
}
22+
}
23+
24+
module.exports = {
25+
handler,
26+
}

0 commit comments

Comments
 (0)