@rlabs-inc/memory 0.5.11 → 0.5.12
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
CHANGED
|
@@ -275,8 +275,9 @@ async function migrateFile(
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
const hasNullEmbedding = !parsed.frontmatter.embedding || parsed.frontmatter.embedding === null
|
|
278
|
+
const hasWrongDimensions = !hasNullEmbedding && Array.isArray(parsed.frontmatter.embedding) && parsed.frontmatter.embedding.length !== 384
|
|
278
279
|
const needsSchema = needsV3Migration(parsed.frontmatter)
|
|
279
|
-
const needsEmbedding = options.embeddings && hasNullEmbedding
|
|
280
|
+
const needsEmbedding = options.embeddings && (hasNullEmbedding || hasWrongDimensions)
|
|
280
281
|
|
|
281
282
|
// Nothing to do
|
|
282
283
|
if (!needsSchema && !needsEmbedding) {
|
package/src/core/retrieval.ts
CHANGED
|
@@ -288,6 +288,13 @@ export class SmartVectorRetrieval {
|
|
|
288
288
|
}
|
|
289
289
|
const v1 = vec1 instanceof Float32Array ? vec1 : new Float32Array(vec1)
|
|
290
290
|
const v2 = vec2 instanceof Float32Array ? vec2 : new Float32Array(vec2)
|
|
291
|
+
|
|
292
|
+
// Skip mismatched dimensions instead of crashing
|
|
293
|
+
if (v1.length !== v2.length) {
|
|
294
|
+
logger.debug(`Vector dimension mismatch: ${v1.length} vs ${v2.length}, skipping`, 'retrieval')
|
|
295
|
+
return 0.0
|
|
296
|
+
}
|
|
297
|
+
|
|
291
298
|
const similarity = cosineSimilarity(v1, v2)
|
|
292
299
|
|
|
293
300
|
// Collect samples to understand similarity range
|