Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion server/aiServer/aiModelFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export class AiModelFactory {
await prisma.notes.findMany({
where: {
accountId: accountId,
isRecycle: false,
isArchived: false,
id: {
in: _.uniqWith(filteredResults.map((i) => Number(i.metadata?.id))).filter((i) => !!i) as number[],
},
Expand Down Expand Up @@ -132,7 +134,7 @@ export class AiModelFactory {
return { ...i, score: filteredResults.find((t) => Number(t.metadata?.id) == i.id)?.score ?? 0 };
}) ?? [];

let aiContext = notes.map((i) => i.content + '\n') || '';
let aiContext = notes.map((i) => i.content).join('\n');
return { notes, aiContext: aiContext };
}

Expand Down
4 changes: 3 additions & 1 deletion server/aiServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ export class AiService {
if (withRAG) {
let { notes, aiContext } = await AiModelFactory.queryVector(question, Number(ctx.id));
ragNote = notes;
ragNoteString = `This is the note content ${ragNote.map((i) => i.content).join('\n')} ${aiContext}`;
if (ragNote.length > 0) {
ragNoteString = `This is the note content:\n${aiContext}`;
}
}

const contextParts = [
Expand Down
Loading