fix: handle potential undefined embedding vectors in buildEmbeddedPatterns
- Add nullish coalescing to ensure embedding dimensions default correctly to 384 - Prevent runtime errors when accessing embeddingMap values
This commit is contained in:
parent
04477fef84
commit
27cc699555
1 changed files with 3 additions and 1 deletions
|
|
@ -78,7 +78,9 @@ async function buildEmbeddedPatterns() {
|
|||
console.log(`✅ Generated embeddings for ${embeddingMap.size} patterns`)
|
||||
|
||||
// Convert embeddings to compact binary format
|
||||
const embeddingDim = embeddingMap.size > 0 ? embeddingMap.values().next().value.length : 384
|
||||
const embeddingDim = embeddingMap.size > 0 ?
|
||||
Array.from(embeddingMap.values())[0]?.length ?? 384 :
|
||||
384
|
||||
const totalFloats = libraryData.patterns.length * embeddingDim
|
||||
const buffer = new ArrayBuffer(totalFloats * 4)
|
||||
const view = new DataView(buffer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue