@context-vault/core 3.0.0 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/capture.ts +2 -2
- package/src/index.ts +4 -2
package/package.json
CHANGED
package/src/capture.ts
CHANGED
|
@@ -266,7 +266,7 @@ export function updateEntryFile(
|
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
export async function captureAndIndex(ctx: BaseCtx, data: CaptureInput): Promise<CaptureResult> {
|
|
269
|
+
export async function captureAndIndex(ctx: BaseCtx, data: CaptureInput, precomputedEmbedding?: Float32Array | null): Promise<CaptureResult> {
|
|
270
270
|
let previousContent: string | null = null;
|
|
271
271
|
if (categoryFor(data.kind) === "entity" && data.identity_key) {
|
|
272
272
|
const identitySlug = slugify(data.identity_key);
|
|
@@ -279,7 +279,7 @@ export async function captureAndIndex(ctx: BaseCtx, data: CaptureInput): Promise
|
|
|
279
279
|
|
|
280
280
|
const entry = writeEntry(ctx, data);
|
|
281
281
|
try {
|
|
282
|
-
await indexEntry(ctx, entry);
|
|
282
|
+
await indexEntry(ctx, entry, precomputedEmbedding);
|
|
283
283
|
if (entry.supersedes?.length && ctx.stmts.updateSupersededBy) {
|
|
284
284
|
for (const supersededId of entry.supersedes) {
|
|
285
285
|
if (typeof supersededId === "string" && supersededId.trim()) {
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ const EMBED_BATCH_SIZE = 32;
|
|
|
13
13
|
export async function indexEntry(
|
|
14
14
|
ctx: BaseCtx,
|
|
15
15
|
entry: IndexEntryInput & { supersedes?: string[] | null; related_to?: string[] | null },
|
|
16
|
+
precomputedEmbedding?: Float32Array | null,
|
|
16
17
|
): Promise<void> {
|
|
17
18
|
const {
|
|
18
19
|
id, kind, category, title, body, meta, tags, source,
|
|
@@ -92,8 +93,9 @@ export async function indexEntry(
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
if (cat !== "event") {
|
|
95
|
-
const
|
|
96
|
-
|
|
96
|
+
const embedding = precomputedEmbedding !== undefined
|
|
97
|
+
? precomputedEmbedding
|
|
98
|
+
: await ctx.embed([title, body].filter(Boolean).join(" "));
|
|
97
99
|
|
|
98
100
|
if (embedding) {
|
|
99
101
|
try { ctx.deleteVec(rowid); } catch { /* no-op */ }
|