my code is pretty simple - its for a little generator as part of showing my team how to work with gpt - but i did it ages ago and now its deprecated
so i tried to update it to be
model: "gpt-3.5-turbo-instruct"
instead of
model: "davinci-003"
but it just stopped working - is there something im missing in how to reformat this?
the console error im getting is
Failed to load resource: the server responded with a status of 502 () /.netlify/functions/open:1
which seems to imply its line one of the Open.js file
but when i check the API tracking its being called whenever i load the site - so it must be making it past the first line?
Open.js
import axios from "axios";
[API KEY LOGIC]
exports.handler = async function (event, context) {
const { word } = JSON.parse(event.body);
const prompt = word?.length
? `Generate a.... [long prompt here cut out for brevity]`
: `Generate a...[long prompt here].`;
const response = await axios.post( "https://api.openai.com/v1/completions",
{
temperature: 0.4,
prompt,
max_tokens: 400,
n: 1,
model: "text-davinci-003",
},
{
[API KEY LOGIC]
}
);
// const haikuText = response.data.choices[0].text.trim();
let haikuText = response.data.choices[0].text.trim();
// Clean up the haiku text
haikuText = haikuText.replace(/[^a-zA-Z,.'\s-ñ˜]+/g, '');
return {
statusCode: 200,
body: JSON.stringify({ haikuText }),
};
};