Skip to content

Commit

Permalink
Merge pull request #305 from b8000h/master
Browse files Browse the repository at this point in the history
Fix: gpt.ts conversation tracking issue
  • Loading branch information
navopw committed Oct 27, 2023
2 parents cbd544f + 0d5cc65 commit 3096f7d
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/handlers/gpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const handleMessageGPT = async (message: Message, prompt: string) => {
if (lastConversationId) {
// Handle message with previous conversation
response = await chatgpt.sendMessage(prompt, {
conversationId: lastConversationId
parentMessageId: lastConversationId
});
} else {
let promptBuilder = "";
Expand All @@ -56,18 +56,14 @@ const handleMessageGPT = async (message: Message, prompt: string) => {
promptBuilder += prompt + "\n\n";
}

// Generate converstation id
const conversationId = randomUUID();

// Handle message with new conversation
response = await chatgpt.sendMessage(promptBuilder, {
conversationId: conversationId
});
response = await chatgpt.sendMessage(promptBuilder);

// Set conversation id
conversations[message.from] = response.conversationId;
cli.print(`[GPT] New conversation for ${message.from} (ID: ${response.conversationId})`);
cli.print(`[GPT] New conversation for ${message.from} (ID: ${response.id})`);
}

// Set conversation id
conversations[message.from] = response.id;

const end = Date.now() - start;

Expand Down

0 comments on commit 3096f7d

Please sign in to comment.