chore(llm): remove some lesser used fields from LLM response

This commit is contained in:
Elian Doran
2026-04-04 09:59:00 +03:00
parent 5138a63d23
commit 027280954a
3 changed files with 15 additions and 22 deletions

View File

@@ -25,11 +25,7 @@ export const attachmentTools = defineTools({
role: attachment.role,
mime: attachment.mime,
title: attachment.title,
position: attachment.position,
blobId: attachment.blobId,
dateModified: attachment.dateModified,
utcDateModified: attachment.utcDateModified,
utcDateScheduledForErasureSince: attachment.utcDateScheduledForErasureSince,
contentLength: attachment.contentLength
};
}

View File

@@ -6,6 +6,7 @@ import { z } from "zod";
import becca from "../../../becca/becca.js";
import attributeService from "../../attributes.js";
import { flag } from "./helpers.js";
import { defineTools } from "./tool_registry.js";
export const attributeTools = defineTools({
@@ -27,7 +28,7 @@ export const attributeTools = defineTools({
type: attr.type,
name: attr.name,
value: attr.value,
isInheritable: attr.isInheritable
isInheritable: flag(attr.isInheritable)
}));
}
},
@@ -49,7 +50,7 @@ export const attributeTools = defineTools({
type: attribute.type,
name: attribute.name,
value: attribute.value,
isInheritable: attribute.isInheritable
isInheritable: flag(attribute.isInheritable)
};
}
},

View File

@@ -11,6 +11,16 @@ import markdownImport from "../../import/markdown.js";
const CONTENT_PREVIEW_MAX_LENGTH = 500;
const ATTACHMENT_PREVIEW_MAX_LENGTH = 200;
/**
* Return `true` if the value is truthy, otherwise `undefined`.
* Since `undefined` values are omitted from JSON serialization,
* this effectively includes the field only when true.
* Usage: `{ isInheritable: flag(attr.isInheritable) }`
*/
export function flag(value: boolean | undefined): true | undefined {
return value ? true : undefined;
}
/**
* Convert note content to a format suitable for LLM consumption.
* Text notes are converted from HTML to Markdown to reduce token usage.
@@ -139,45 +149,31 @@ export function getNoteMeta(note: BNote, limits: NoteMetaLimits) {
const allAttributes = note.getAttributes().map((attr) => ({
attributeId: attr.attributeId,
noteId: attr.noteId,
type: attr.type,
name: attr.name,
value: attr.value,
position: attr.position,
isInheritable: attr.isInheritable,
utcDateModified: attr.utcDateModified
isInheritable: flag(attr.isInheritable)
}));
const allAttachments = note.getAttachments().map((att) => ({
attachmentId: att.attachmentId,
ownerId: att.ownerId,
role: att.role,
mime: att.mime,
title: att.title,
position: att.position,
blobId: att.blobId,
dateModified: att.dateModified,
utcDateModified: att.utcDateModified,
utcDateScheduledForErasureSince: att.utcDateScheduledForErasureSince,
contentLength: att.contentLength,
contentPreview: getAttachmentContentPreview(att)
}));
return {
noteId: note.noteId,
isProtected: note.isProtected,
isProtected: flag(note.isProtected),
title: note.title,
type: note.type,
mime: note.mime,
blobId: note.blobId,
dateCreated: note.dateCreated,
dateModified: note.dateModified,
utcDateCreated: note.utcDateCreated,
utcDateModified: note.utcDateModified,
parentNoteIds: note.getParentNotes().map((p) => p.noteId),
childNotes: truncated(allChildNotes, limits.childNotes),
parentBranchIds: note.getParentBranches().map((p) => p.branchId),
childBranchIds: note.getChildBranches().map((ch) => ch.branchId),
attributes: truncated(allAttributes, limits.attributes),
contentPreview: getContentPreview(note),
attachments: truncated(allAttachments, limits.attachments)