im trying to get chatgpt setup on my lambda server .
having issues getting a response .
here is the server side .
specifically just the async function sendtochatgpt that is setup to receive a user message from my client
wont let me copy the whole code so here is the part that is relevent to processing the usser message from my client and sending it to gpt
try {
const requestData = {
model: "gpt-3.5-turbo",
messages: [
{
role: "system",
content: "You are a helpful assistant."
},
{
role: "user",
content: userMessage
}
]
};
const config = {
headers: {
'Authorization': `Bearer MY_API`,
'Content-Type': 'application/json'
}
};
const response = await axios.post('https://api.openai.com/v1/engines/gpt-3.5-turbo/completions', requestData, config);
return response.data.choices[0].message.content;
} catch (error) {
console.error('Error sending message to ChatGPT:', error);
return 'An error occurred while communicating with ChatGPT.';
}
}