The chatGPT API is clipping the response text. Is there a way to resolve this? If there is no way to solve it, how can I remove the paragraph that had the text cut off. Can someone help me?
// API_URL = https://api.openai.com/v1/completions
async function newUserMessage(newMessage) {
try {
const response = await axios.post(API_URL, {
prompt: newMessage,
model: 'text-davinci-003',
max_tokens: 150
}, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${API_KEY}`,
},
});
const { text } = response.data.choices[0];
const newText = text.replace(/(\r\n|\n|\r)/gm, "");
setResponse(newText);
setQuery("");
} catch (error) {
console.error(error);
}
};