#API incorrect reply

7 messages · Page 1 of 1 (latest)

faint dock
#

Good night everyone. I have a little problem with GPT 3.5 Turbo.
I'm trying to make GPT create a random word with 5 letters, but he only generate incomplete words, like "tha" (that) and random characters like ' , / .... Can someone help me with this? Thank you

vivid otter
faint dock
#
const engineID = 'davinci';

async function getGeneratedText(prompt){
    const response = await fetch("https://api.openai.com/v1/completions", {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "Authorization": "Bearer " + apiKey,
        },
        body: JSON.stringify({
            prompt: prompt,
            temperature: 1,
            max_tokens: 1,
            model: engineID,
            frequency_penalty: 2,
            presence_penalty: 2,
        }),
    });
    const data = await response.json();[]
    return data.choices[0].text.trim().replace(/[^a-zA-Z0-9\s]/g, '').split(' ');
    
}

let dailyWord;
getGeneratedText("").then(result => {
        dailyWord = result;
        console.log(dailyWord)

    });




async function checkWord() {
    const inputWord = document.getElementById("word-input").value;

    if (inputWord.toLowerCase() === dailyWord){
        document.getElementById("result").textContent = "Você está correto!";
    } else {
        document.getElementById("result").textContent = "Tente novamente amanhã!";
    }
}
#

this is the code

vivid otter
#

Try using the right model and endpoint.