do a better job of building the context

This commit is contained in:
perf3ct
2025-03-20 19:35:20 +00:00
parent 9c1ab4f322
commit 1be70f1163
3 changed files with 254 additions and 19 deletions

View File

@@ -670,6 +670,12 @@ async function sendMessage(req: Request, res: Response) {
content: context
};
// DEBUG: Log context details before sending to LLM
log.info(`CONTEXT BEING SENT TO LLM: ${context.length} chars`);
log.info(`Context begins with: "${context.substring(0, 200)}..."`);
log.info(`Context ends with: "...${context.substring(context.length - 200)}"`);
log.info(`Number of notes included: ${sourceNotes.length}`);
// Format all messages for the AI (advanced context case)
const aiMessages: Message[] = [
contextMessage,
@@ -679,6 +685,12 @@ async function sendMessage(req: Request, res: Response) {
}))
];
// DEBUG: Log message structure being sent to LLM
log.info(`Message structure being sent to LLM: ${aiMessages.length} messages total`);
aiMessages.forEach((msg, idx) => {
log.info(`Message ${idx}: role=${msg.role}, content length=${msg.content.length} chars, begins with: "${msg.content.substring(0, 50)}..."`);
});
// Configure chat options from session metadata
const chatOptions: ChatCompletionOptions = {
temperature: session.metadata.temperature || 0.7,