Skip to content

Commit

Permalink
naming is hard
Browse files Browse the repository at this point in the history
  • Loading branch information
thezanke committed Aug 29, 2023
1 parent f6ec39d commit 2ff2318
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ export class ChatService {
}

private async handleMention(initialMessage: Message) {
const messages: CreateChatCompletionRequestMessage[] = [];
const chain = this.discordService.messageChainGenerator(initialMessage);
const discordMessages =
this.discordService.messageChainGenerator(initialMessage);

for await (const message of chain) {
messages.push(
const openAIMessages: CreateChatCompletionRequestMessage[] = [];

for await (const message of discordMessages) {
openAIMessages.push(
createUserMessage(message.content, message.author.username),
);
}

messages.reverse();
// faster to reverse at the end than to unshift
openAIMessages.reverse();

const response = await this.openAIChatService.getCompletion(messages);
const response = await this.openAIChatService.getCompletion(openAIMessages);

await initialMessage.reply(response);
}
Expand Down

0 comments on commit 2ff2318

Please sign in to comment.