Simple OpenAI to FHIR Webapp with Lambda
use functions lambda
set timeout to something like 15
export const handler = async(event) => {
var incoming = JSON.parse(event.body)
//minimal security
if (incoming.key !== "9227668b-d6ca-463f-8a49-2d5f49bb9ee6"){return JSON.stringify({statusCode:500})}
var outgoing = {
"model": "text-davinci-003",
"prompt": incoming.prompt,
"temperature": 0.4,
"max_tokens": 710,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}
var openai = await fetch("<https://api.openai.com/v1/completions>",{
method: "POST",
headers: {"Content-type": "application/json","Authorization":"Bearer <YOUR TOKEN>"},
body: JSON.stringify(outgoing),
}).then(function(d){
return d.json()
}).then(function(e){ return e })
const response = {
statusCode: 200,
body: JSON.stringify(openai)
};
return response;
};