chore: snapshot before performance optimization
This commit is contained in:
@@ -77,11 +77,11 @@ export class MemoryEchoService {
|
||||
return [] // Need at least 2 notes to find connections
|
||||
}
|
||||
|
||||
// Parse embeddings
|
||||
// Parse embeddings (already native Json from PostgreSQL)
|
||||
const notesWithEmbeddings = notes
|
||||
.map(note => ({
|
||||
...note,
|
||||
embedding: note.embedding ? JSON.parse(note.embedding) : null
|
||||
embedding: note.embedding ? JSON.parse(note.embedding) as number[] : null
|
||||
}))
|
||||
.filter(note => note.embedding && Array.isArray(note.embedding))
|
||||
|
||||
@@ -108,7 +108,7 @@ export class MemoryEchoService {
|
||||
}
|
||||
|
||||
// Calculate cosine similarity
|
||||
const similarity = cosineSimilarity(note1.embedding, note2.embedding)
|
||||
const similarity = cosineSimilarity(note1.embedding!, note2.embedding!)
|
||||
|
||||
// Similarity threshold for meaningful connections
|
||||
if (similarity >= similarityThreshold) {
|
||||
@@ -348,9 +348,9 @@ Explain in one brief sentence (max 15 words) why these notes are connected. Focu
|
||||
feedbackType: feedback,
|
||||
feature: 'memory_echo',
|
||||
originalContent: JSON.stringify({ insightId }),
|
||||
metadata: JSON.stringify({
|
||||
metadata: {
|
||||
timestamp: new Date().toISOString()
|
||||
})
|
||||
} as any
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -426,8 +426,9 @@ Explain in one brief sentence (max 15 words) why these notes are connected. Focu
|
||||
return []
|
||||
}
|
||||
|
||||
// Parse target note embedding
|
||||
const targetEmbedding = JSON.parse(targetNote.embedding)
|
||||
// Target note embedding (already native Json from PostgreSQL)
|
||||
const targetEmbedding = targetNote.embedding ? JSON.parse(targetNote.embedding) as number[] : null
|
||||
if (!targetEmbedding) return []
|
||||
|
||||
// Check if user has demo mode enabled
|
||||
const settings = await prisma.userAISettings.findUnique({
|
||||
@@ -444,7 +445,8 @@ Explain in one brief sentence (max 15 words) why these notes are connected. Focu
|
||||
for (const otherNote of otherNotes) {
|
||||
if (!otherNote.embedding) continue
|
||||
|
||||
const otherEmbedding = JSON.parse(otherNote.embedding)
|
||||
const otherEmbedding = otherNote.embedding ? JSON.parse(otherNote.embedding) as number[] : null
|
||||
if (!otherEmbedding) continue
|
||||
|
||||
// Check if this connection was dismissed
|
||||
const pairKey1 = `${targetNote.id}-${otherNote.id}`
|
||||
|
||||
Reference in New Issue
Block a user