diff --git a/src/execution.ts b/src/execution.ts index 5ece5a1..ea05d6d 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -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";