Skip to content

Wire RAG Semantic Search + Add Deadline Extraction to AI #23

Description

@krishnasahoo11156

Two problems:
(1) The AI doesn’t extract deadlines from emails
(2) embedEmail() and searchSimilarEmails() exist in code but have NO API endpoints or UI integration. We need to fix both.

Acceptance Criteria:
• Update AI service: add deadlines: string[] to structured output schema
• Add deadline field to ActionItem model, deadlines to EmailAnalysis model
• Create backend/src/routes/rag.routes.ts:
– POST /api/rag/index — trigger embedding for email(s)
– POST /api/rag/search — semantic search with cosine similarity
• Ensure pgvector extension enabled in PostgreSQL
• Add embedding vector(1536) to Email model (raw SQL for vector type)
• Create BullMQ background job indexEmailsJob for batch indexing
• Add semantic search UI to frontend (search bar with “AI-powered” toggle)

Technical Notes
• Use chrono-node as fallback if LLM misses dates
• Search must complete in <500ms for 100K+ emails
• Filter by user_id for privacy
• Must handle emails with no body (skip indexing)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions