#chatgpt in lambda AWS server

1 messages · Page 1 of 1 (latest)

heavy dock
#

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.';
    }
}
heavy dock
#

I don't get any errors client side

But server side in the aws log for my lambda server I get a axios 400 error

Axios is unable to reach openai for some reason. My api key is active so I'm not sure what it is , maybe it's a payload format issue

heavy dock
#

still looking for help

dark grove
#

Look at the API documentation for the proper endpoint, ttps://api.openai.com/v1/engines/gpt-3.5-turbo/completions doesn't exist/work

heavy dock
# dark grove You are using a super old endpoint

oh yeah haha that fixed . but now im having a odd issue .

chat gpt seems to only want to responed when i say its name

it seems to fail everytime i ask it a question or try to use it for anything.

dark grove
#

Hard to debug this without your full implementation, I don't know how your application works, can you share more details

heavy dock
#

@dark grove

#

possibly timing out after only 3 seconds

#

nvm i think its a lambda function setting