feat: pgvector similar-incident retrieval + SimilarIncidentsPanel

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
This commit is contained in:
2026-07-11 16:31:02 +08:00
co-authored by Claude Sonnet 4.6
parent f10fa071f9
commit 547cc6e817
4 changed files with 136 additions and 0 deletions
+9
View File
@@ -109,5 +109,14 @@ export async function POST(request: Request) {
sendNewIncidentEmail(incident.id, zone.site_id, incident.reference_no ?? '', input.incident_type)
.catch(err => console.error('email notification failed:', err))
// Embed description asynchronously for future similarity search
import('@/lib/claude/embed').then(({ embedText }) =>
embedText(input.description.trim()).then(embedding =>
supabase.from('incidents').update({
embedding: `[${embedding.join(',')}]` as unknown as string,
}).eq('id', incident.id)
)
).catch(err => console.error('embed error:', err))
return NextResponse.json({ id: incident.id, reference_no: incident.reference_no }, { status: 201 })
}