do a wayyy better job at building the messages with context

This commit is contained in:
perf3ct
2025-03-28 22:50:15 +00:00
parent ea4d3ac800
commit 72c380b6f4
9 changed files with 856 additions and 468 deletions

View File

@@ -956,8 +956,8 @@ async function sendMessage(req: Request, res: Response) {
log.info(`Context ends with: "...${context.substring(context.length - 200)}"`);
log.info(`Number of notes included: ${sourceNotes.length}`);
// Get messages with context properly formatted for the specific LLM provider
const aiMessages = contextService.buildMessagesWithContext(
// Format messages for the LLM using the proper context
const aiMessages = await contextService.buildMessagesWithContext(
session.messages.slice(-LLM_CONSTANTS.SESSION.MAX_SESSION_MESSAGES).map(msg => ({
role: msg.role,
content: msg.content
@@ -1104,7 +1104,7 @@ async function sendMessage(req: Request, res: Response) {
const context = buildContextFromNotes(relevantNotes, messageContent);
// Get messages with context properly formatted for the specific LLM provider
const aiMessages = contextService.buildMessagesWithContext(
const aiMessages = await contextService.buildMessagesWithContext(
session.messages.slice(-LLM_CONSTANTS.SESSION.MAX_SESSION_MESSAGES).map(msg => ({
role: msg.role,
content: msg.content