#Upgrading to GPT-Turbo

8 messages · Page 1 of 1 (latest)

cosmic hawk
#

so i have been using dav. 03 for a while and i wanted to change to the newest version of gpt turbo, since the gpt-4 isnt public yet. unfortunately there are not so many articles about this, and i was hoping that someone could help me change the model without loosing any features.

code:```default:
try {
const userId = message.author.id;
const userHistory = conversationHistory[userId] || [];
const botId = client.user.id;

                const prompt = "input: " + "\nContext: " + userHistory.join("\n") + message.content + "\nOutput:";
                var completion;


                (async () => {
                    completion = await openai.createCompletion({
                        model: "text-davinci-003",
                        prompt,
                        max_tokens: 1024
                    },
                        {
                            timeout: 10000,
                            headers: {
                                "Example-Header": "example",
                            }
                        });

                    const response = completion.data.choices[0].text.trim();
                    message.channel.send("```" + response + "```");


                    userHistory.push("Bot: " + response);
                    userHistory.push(message.content);
                    userHistory.push(response);
                    conversationHistory[userId] = userHistory;
                })();
            } catch (error) {
                if (error.response) {
                    console.log(error.response.status);
                    console.log(error.response.data);
                } else {
                    console.log(error.message);
                    message.channel.send(error.message);
                }

            }
            break; ```

The code is in javascript btw

cosmic hawk
#

Bump

jagged oak
#

there are articles on the mean website

#

hello here

cosmic hawk
# jagged oak there are articles on the mean website

i have tried to follow it and i came up with this: ```const GPT35Turbo = async (message) => {
try {
const userId = message.author.id;
const userHistory = conversationHistory[userId] || [];

    const messageObj = {
        text: message.content,
        user: userId
    };

    const response = await openai.createChatCompletion({
        model: "gpt-3.5-turbo",
        messages: [messageObj]
    });

    const botResponse = response.data.choices[0].text.trim();

    userHistory.push("Bot: " + botResponse);
    userHistory.push(message.content);
    userHistory.push(botResponse);
    conversationHistory[userId] = userHistory;

    await message.channel.send(botResponse);

    return botResponse;
} catch (error) {
    if (error.response) {
        console.log(error.response.status);
        console.log(error.response.data);
    } else {
        console.log(error.message);
    }

    return "Sorry, there was an error processing your request.";
}

};```

unfortunately it outputs this error: 400 { error: { message: "Additional properties are not allowed ('text', 'user' were unexpected) - 'messages.0'", type: 'invalid_request_error', param: null, code: null } }

#

i tried basically everything but i still cant get it to work. and when it doesnt output an error then it doesnt output anything