Skip to content

feat: add RAG model for project search and recommendations (closes #2)#6

Open
misakaAron wants to merge 1 commit into
Fahad-Dezloper:mainfrom
misakaAron:feat/add-rag-model
Open

feat: add RAG model for project search and recommendations (closes #2)#6
misakaAron wants to merge 1 commit into
Fahad-Dezloper:mainfrom
misakaAron:feat/add-rag-model

Conversation

@misakaAron

Copy link
Copy Markdown

Summary

This PR implements a Retrieval-Augmented Generation (RAG) model for project search and recommendations, as requested in #2.

Changes

1. Database Schema (prisma/schema.prisma)

  • Added embedding field (pgvector 768-dim) to the Project model for storing vector embeddings

2. Embedding Utilities (lib/embedding.ts)

  • getEmbedding(): Generates embeddings using Google's ext-embedding-004 model
  • embeddingToPgVector(): Converts embedding arrays to PostgreSQL vector format
  • projectToText(): Builds a text representation of a project for embedding generation

3. RAG Core (lib/rag.ts)

agSearch(): Performs semantic search over projects using cosine similarity via pgvector

  • updateProjectEmbedding(): Generates and stores embedding for a single project

ebuildAllEmbeddings(): Batch rebuilds embeddings for all projects

4. API Routes

  • GET /api/rag/search?q=: Semantic search endpoint returning similar projects with similarity scores
  • GET /api/rag/recommend?projectId=: Returns projects similar to a given project
  • POST /api/rag/recommend: Triggers embedding generation (single project or all)

5. Chat Integration (�i/actions.ts)

  • Updated generateRecommendations() to first retrieve semantically similar projects from the database (RAG retrieval step), then use those as context for the LLM to generate better recommendations

Requirements

  • Requires pgvector extension enabled on the PostgreSQL database
  • Requires GOOGLE_GENERATIVE_AI_API_KEY environment variable

- Add embedding field to Project model (pgvector, 768-dim)
- Create lib/embedding.ts for Google text-embedding-004 integration
- Create lib/rag.ts with semantic search and embedding utilities
- Add GET /api/rag/search for RAG-based project search
- Add GET/POST /api/rag/recommend for similar project recommendations
- Integrate RAG retrieval into existing AI chat recommendations
- Augments LLM prompts with semantically similar projects from DB

Closes Fahad-Dezloper#2
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

@misakaAron is attempting to deploy a commit to the fahad-dezloper's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant