Add organizations, semantic search, and user personas
From the PR description
Summary
This PR introduces three major features to the platform:
Organizations & Team Management - Users can now create organizations, invite team members by email, and manage org-level settings (jurisdictions, practice areas, custom instructions, language).
Semantic Search - Documents are now indexed using Voyage AI's legal-optimized embeddings (voyage-law-2), enabling semantic similarity search across document chunks with page number tracking.
User Personas - Extended user profiles to capture professional context (role, practice areas, bar number, custom instructions) and organization membership, which enriches LLM system prompts.
Key Changes
Backend
New routes:
POST/GET/PATCH /organizations- Create, retrieve, and update organizationsGET /organizations/:id/members- List org members with enriched profile dataPOST/GET/DELETE /organizations/:id/invites- Manage email-based invitations (7-day expiry)POST /organizations/:id/join- Accept pending invitationsPOST /search/semantic- Semantic search across documents using embeddingsGET/PATCH /user/persona- Fetch and update user persona fields
New libraries:
lib/embeddings.ts- Text chunking (800 chars, 150 overlap), Voyage AI API integration, vector persistencelib/persona.ts- Fetch and build persona context from user + org datalib/llm/openrouter.ts- OpenRouter API client with streaming and tool support
Database migrations:
001_add_openrouter_voyage.sql- pgvector extension, document_chunks table with 1024-dim embeddings, cosine similarity RPC002_personas.sql- organizations, organization_members, organization_invites tables; extended user_profiles with persona fields
Tool additions:
- Added
semantic_searchtool to chat tools for LLM-driven document search
- Added
Frontend
New pages:
account/company/page.tsx- Full org management UI (create, edit, invite, member list, leave)account/page.tsx- Extended with persona fields (role, practice areas, bar number, custom instructions)
New components:
SemanticSearchWidget.tsx- Debounced search UI with result display and click handlers
API client updates:
- Added organization, invite, and persona endpoints to
mikeApi.ts - Added semantic search endpoint
- Added organization, invite, and persona endpoints to
Context & utilities:
- Extended
UserProfileContextwith persona fields and openrouter API key - Updated
modelAvailability.tsto support OpenRouter as a provider - Updated
ModelToggle.tsxto include OpenRouter models
- Extended
UI components:
- Added
Textareacomponent for multi-line inputs
- Added
Integration Points
- Chat and project chat routes now fetch and inject persona context into system prompts
- Document upload flow triggers semantic indexing via
indexDocumentVersion() - Model selection now includes OpenRouter models alongside Claude and Gemini
- Project page includes semantic search widget for document discovery
Notable Implementation Details
- Organization invites use email-based upsert with 7-day expiry
- Slugs are auto-generated with random suffix to ensure uniqueness
- Document chunks preserve page numbers from PDF [Page N] markers
- Persona context is hierarchical: user settings override org defaults in prompts
- Semantic search supports filtering by document IDs and configurable result count (top_k)
- OpenRouter client uses OpenAI SDK with custom base URL for compatibility
Our analysis
OpenRouter multi-model + Voyage AI semantic search — read the full analysis →
OpenRouter multi-model + Voyage AI semantic search — read the full analysis →
Think the analysis missed something the PR description covers?
Commits in this PR (4)
| SHA | Subject | Author | Date | |
|---|---|---|---|---|
3279a584 | Add OpenRouter multi-model support and Voyage AI semantic search | Claude | 2026-05-07 | ↗ GitHub |
commit bodyOpenRouter: extends the LLM provider abstraction to support GPT-4o, GPT-4 Turbo, Mistral Large, Llama 3.3 70B, and Gemma 3 27B via a single OpenRouter API key. Follows the same provider pattern as Claude and Gemini - new openrouter.ts adapter, model routing by prefix, per-user API key stored in user_profiles, and full UI integration (model toggle, availability checks, account settings key field). Semantic search: adds Voyage AI embeddings (voyage-law-2, optimised for legal documents) to index document chunks at upload time (fire-and-forget, controlled by VOYAGE_API_KEY env var). Chunks are stored in a new document_chunks pgvector table. A /search/semantic endpoint and a semantic_search LLM tool enable concept-level retrieval. A new SemanticSearchWidget in ProjectPage exposes document search by meaning. https://claude.ai/code/session_01NJxa5NasJ9qhaMkzEyqr2u | ||||
3279a584 | Add OpenRouter multi-model support and Voyage AI semantic search | Claude | 2026-05-07 | ↗ GitHub |
commit bodyOpenRouter: extends the LLM provider abstraction to support GPT-4o, GPT-4 Turbo, Mistral Large, Llama 3.3 70B, and Gemma 3 27B via a single OpenRouter API key. Follows the same provider pattern as Claude and Gemini - new openrouter.ts adapter, model routing by prefix, per-user API key stored in user_profiles, and full UI integration (model toggle, availability checks, account settings key field). Semantic search: adds Voyage AI embeddings (voyage-law-2, optimised for legal documents) to index document chunks at upload time (fire-and-forget, controlled by VOYAGE_API_KEY env var). Chunks are stored in a new document_chunks pgvector table. A /search/semantic endpoint and a semantic_search LLM tool enable concept-level retrieval. A new SemanticSearchWidget in ProjectPage exposes document search by meaning. https://claude.ai/code/session_01NJxa5NasJ9qhaMkzEyqr2u | ||||
4f16dc2b | feat: personas, company/team management, organisation context injection | Claude | 2026-05-08 | ↗ GitHub |
commit body- Company & Team tab: create/join/edit orgs, manage members and invites, admin roles - My Profile section in General tab: role, practice areas, bar number, personal AI instructions - DB: organizations, organization_members, organization_invites tables + user_profiles persona columns - Persona context injected into every chat and project chat system prompt - REST API: /organizations/* CRUD + /user/persona GET/PATCH - Textarea UI component https://claude.ai/code/session_01NJxa5NasJ9qhaMkzEyqr2u | ||||
4f16dc2b | feat: personas, company/team management, organisation context injection | Claude | 2026-05-08 | ↗ GitHub |
commit body- Company & Team tab: create/join/edit orgs, manage members and invites, admin roles - My Profile section in General tab: role, practice areas, bar number, personal AI instructions - DB: organizations, organization_members, organization_invites tables + user_profiles persona columns - Persona context injected into every chat and project chat system prompt - REST API: /organizations/* CRUD + /user/persona GET/PATCH - Textarea UI component https://claude.ai/code/session_01NJxa5NasJ9qhaMkzEyqr2u | ||||
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-1.md from
inside the repo you want the changes in.