Log message data when an error occurs
This commit is contained in:
parent
9c3f25312b
commit
67d4361c26
1 changed files with 7 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import DiscordApi, { GuildTextBasedChannel } from "discord.js";
|
||||
import { ChatCompletionRequestMessage } from "openai";
|
||||
|
||||
import { database, openai } from "./index";
|
||||
import Moderation from "./moderation";
|
||||
|
@ -220,6 +221,7 @@ async function executeFromQueue(channel: string) {
|
|||
const channelQueue = channelsRunning.get(channel) as ChannelQueue;
|
||||
const message = channelQueue.at(0) as RequestMessage;
|
||||
let functionRanCounter = 0;
|
||||
let OpenAImessages: ChatCompletionRequestMessage[] = [];
|
||||
|
||||
// ignore if we can't even send anything to reply
|
||||
if (!canReplyToRequest(message)) return;
|
||||
|
@ -238,7 +240,7 @@ async function executeFromQueue(channel: string) {
|
|||
message.deferReply();
|
||||
}
|
||||
|
||||
const OpenAImessages = toOpenAIMessages(messages);
|
||||
OpenAImessages = toOpenAIMessages(messages);
|
||||
let answer = await openai.createChatCompletion({
|
||||
...config.chatCompletionConfig,
|
||||
messages: OpenAImessages,
|
||||
|
@ -299,6 +301,10 @@ async function executeFromQueue(channel: string) {
|
|||
} catch (e) {
|
||||
console.error(`Error ocurred while handling chat completion request (${(e as object).constructor.name}):`);
|
||||
console.error(e);
|
||||
if (OpenAImessages.length != 0) {
|
||||
console.error("Messages:");
|
||||
console.error(OpenAImessages);
|
||||
}
|
||||
|
||||
let errorText = "\n";
|
||||
|
||||
|
|
Loading…
Reference in a new issue