This code was working just fine 2 days ago. Nothing changed on my end but now I am getting error 400 and I can’t figure out why. Help please…
const myAction = async (tokens, preamble, instructions, prompt) => {
const axios = require('axios')
const endpoint = 'https://api.openai.com/v1/completions'
if (tokens !== undefined) {
tokens = tokens
} else {
tokens = 200
}
const inputData = JSON.stringify({
frequency_penalty: 0.7,
model: 'text-davinci-003',
presence_penalty: 1.2,
stop: [' Human:', ' AI:'],
prompt: `"${preamble} ${instructions}: ${prompt}"`,
max_tokens: tokens,
temperature: 0.5,
top_p: 1
})
const config = {
method: 'post',
url: endpoint,
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer myAPIKey'
},
data: inputData,
withCredentials: false
}
const result = await axios(config)
const { data } = result
temp.chatGPTResponse = data.choices[0].text
}
return myAction(args.tokens, args.preamble, args.instructions, args.prompt)