My app was working fine before and I was getting response to my API calls fine but since yesterday I keep getting 502 or 504 errors on local testing and after uploading the app respectively
here is my app.js file
var client;
init();
async function init() {
client = await app.initialized();
client.events.on('app.activated', renderText);
}
function jsonEscape(str) {
return str.replace(/\n/g, " ").replace(/\\/g," ")
}
async function renderText() {
const textElement = document.getElementById('apptext');
const ticketData = await client.data.get('ticket');
const {
ticket: { description_text }
} = ticketData;
try {
let response = await client.request.invokeTemplate(
"ChatGPT", {
"context": {},
"body": JSON.stringify({
"model": "gpt-3.5-turbo",
"messages": [{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Provide Customer Sentiment in the Service Ticket raised below and the best way to make them happy\n" + description_text}
]
})
})
//textElement = JSON.stringify(response)
var rep = JSON.parse(jsonEscape(response.response));
var rep2 = rep.choices[0].message.content;
textElement.innerHTML = rep2;
}
catch(err){
textElement.innerHTML = "Error request fail: " + JSON.stringify(err);
}
}
and here is my requests.json file
{
"ChatGPT": {
"schema": {
"method": "POST",
"host": "api.openai.com",
"path": "/v1/chat/completions",
"headers": {
"Authorization": "Bearer <my-api-key>",
"Content-Type": "application/json"
}
}
}
}```