Skip to content

Commit

Permalink
improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Jun 7, 2024
1 parent b0c8821 commit aabe6f7
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ export function registerContextFunction({
messages.filter((message) => message.message.role === MessageRole.User)
);

const userPrompt = userMessage?.message.content!;
const queries = compact([{ text: userPrompt, boost: 3 }, { text: screenDescription }]);
const userPrompt = userMessage?.message.content;
const queries = [{ text: userPrompt, boost: 3 }, { text: screenDescription }].filter(
({ text }) => text
) as Array<{ text: string; boost?: number }>;

const suggestions = await retrieveSuggestions({ client, queries });
if (suggestions.length === 0) {
Expand All @@ -90,7 +92,7 @@ export function registerContextFunction({
});

analytics.reportEvent<RecallRanking>(RecallRankingEventType, {
prompt: `${screenDescription} | ${userPrompt}`,
prompt: queries.map((query) => query.text).join('|'),
scoredDocuments: suggestions.map((suggestion) => {
const llmScore = scores.find((score) => score.id === suggestion.id);
return {
Expand Down

0 comments on commit aabe6f7

Please sign in to comment.