Skip to content

Commit

Permalink
Merge pull request #25 from uzornakovre/v3.5_with_context
Browse files Browse the repository at this point in the history
feat: update gpt model
  • Loading branch information
uzornakovre authored Oct 8, 2023
2 parents 7ff6103 + 0021bc8 commit 8abdb71
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,18 @@ bot.on('message', async (msg) => {

pushMessages(chatId);

bot.sendMessage(chatId, toolTips.waitMessage)
bot
.sendMessage(chatId, toolTips.waitMessage)
.then((message) => {
waitMessageId = message.message_id;
}).then(() => bot.sendChatAction(chatId, 'typing'));
})
.then(() => bot.sendChatAction(chatId, 'typing'));

messages[chatId].push({ role: 'user', content: text });

try {
const completion = await openai.createChatCompletion({
model: 'gpt-3.5-turbo',
model: 'gpt-3.5-turbo-16k-0613',
messages: messages[chatId],
});

Expand All @@ -133,7 +135,10 @@ bot.on('message', async (msg) => {
sendLongMessage(chatId, output);
} catch (err) {
if (err.response.status === 429) {
return bot.sendMessage(chatId, errorMessages.TOO_MANY_REQUESTS(err.response.status));
return bot.sendMessage(
chatId,
errorMessages.TOO_MANY_REQUESTS(err.response.status),
);
}
if (err.response.data.error.code === 'context_length_exceeded') {
history[chatId] = [];
Expand All @@ -143,7 +148,10 @@ bot.on('message', async (msg) => {
}
return bot.sendMessage(
chatId,
errorMessages.DEFAULT(err.response.status, err.response.data.error.message),
errorMessages.DEFAULT(
err.response.status,
err.response.data.error.message,
),
);
}
});
Expand Down

0 comments on commit 8abdb71

Please sign in to comment.