Skip to content

Commit

Permalink
fix nasty bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiAbdou committed Sep 14, 2024
1 parent d1fb71e commit 290d6f9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/core/src/modules/slack/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ async function getMostRelevantThreads(
return !options.exclude?.includes(match.id);
});

const messages = await Promise.all(
let messages = await Promise.all(
filteredMatches.map(async (match) => {
const [thread, replies] = await Promise.all([
db
Expand Down Expand Up @@ -517,22 +517,22 @@ async function getMostRelevantThreads(
})
);

// We filter out any messages that don't have replies, since this
// is most likely a question that never got answered.
messages = messages.filter((message) => {
return !!message.replies.length;
});

// This next step is an important one -- we're going to rerank the messages
// based on their relevance to the question. This helps us get the most
// relevant threads to the LLM. Reranking models are different from
// vector search which are optimized for fast retrieval. Reranking models are
// more accurate at assessing relevance, but they are slower and more
// expensive to compute.

const documents = messages
.filter((message) => {
// We filter out any messages that don't have replies, since this
// is most likely a question that never got answered.
return !!message.replies.length;
})
.map((message) => {
return [message.createdAt, message.message, message.replies].join('\n');
});
const documents = messages.map((message) => {
return [message.createdAt, message.message, message.replies].join('\n');
});

const rerankingResult = await rerankDocuments(question, documents, {
topK: options.topK,
Expand Down

0 comments on commit 290d6f9

Please sign in to comment.