feat(insights): fix DBSCAN, Persian embeddings crash, D3 physics layouts, and D3 node not found runtime error
This commit is contained in:
@@ -333,26 +333,27 @@ export class SemanticSearchService {
|
||||
* SECURITY: Uses parameterized bind params ($1, $2).
|
||||
* noteId validated via assertSafeId().
|
||||
*/
|
||||
async indexNote(noteId: string): Promise<void> {
|
||||
async indexNote(noteId: string, options?: { force?: boolean }): Promise<void> {
|
||||
try {
|
||||
assertSafeId(noteId, 'noteId')
|
||||
|
||||
const note = await prisma.note.findUnique({
|
||||
where: { id: noteId },
|
||||
select: { content: true, lastAiAnalysis: true }
|
||||
select: { content: true, title: true, lastAiAnalysis: true, sourceUrl: true }
|
||||
})
|
||||
|
||||
if (!note) throw new Error('Note not found')
|
||||
if (!note?.content?.trim()) return
|
||||
|
||||
const shouldRegenerate = embeddingService.shouldRegenerateEmbedding(
|
||||
note.content,
|
||||
null,
|
||||
note.lastAiAnalysis
|
||||
note.lastAiAnalysis,
|
||||
{ force: options?.force, isClip: Boolean(note.sourceUrl?.trim()) },
|
||||
)
|
||||
|
||||
if (!shouldRegenerate) return
|
||||
|
||||
const { embedding } = await embeddingService.generateEmbedding(note.content)
|
||||
const { embedding } = await embeddingService.generateNoteEmbedding(note.title, note.content)
|
||||
const vecStr = embeddingService.toVectorString(embedding)
|
||||
|
||||
await prisma.$queryRawUnsafe(
|
||||
|
||||
Reference in New Issue
Block a user