fix: remove pgvector dependency from AI knowledge retrieval
This commit is contained in:
@@ -350,7 +350,7 @@ GOOGLE_GENERATIVE_AI_API_KEY=...
|
||||
ANTHROPIC_API_KEY=sk-ant-...
|
||||
```
|
||||
|
||||
## Scenario: Elder AI Analysis MVP With LangChain And pgvector
|
||||
## Scenario: Elder AI Analysis MVP With LangChain And PostgreSQL JSONB Embeddings
|
||||
|
||||
### 1. Scope / Trigger
|
||||
|
||||
@@ -369,7 +369,7 @@ ANTHROPIC_API_KEY=sk-ant-...
|
||||
- `DELETE /api/ai/knowledge/[id]`
|
||||
- DB:
|
||||
- `ai_knowledge_entries`
|
||||
- `ai_knowledge_chunks` with `vector(1536)`
|
||||
- `ai_knowledge_chunks` with `jsonb` `embedding` arrays
|
||||
- `elder_ai_analyses`
|
||||
- Runtime env:
|
||||
- `AI_API_KEY` required for generation and embedding.
|
||||
@@ -394,6 +394,7 @@ ANTHROPIC_API_KEY=sk-ant-...
|
||||
- `errorCategory` / `errorReason`: sanitized only for failed rows
|
||||
- Failed rows must not store prompts, full resident context snapshots, API keys, or raw provider errors.
|
||||
- Knowledge retrieval may return enabled platform knowledge and enabled active-organization knowledge only.
|
||||
- Knowledge retrieval first filters enabled platform / active-organization chunks in SQL, then computes cosine similarity in `modules/ai/server/knowledge.ts`; this keeps the MVP deployable on plain PostgreSQL without the `vector` extension.
|
||||
- Completed elder analysis `resultJson.citations` must be derived from citation IDs actually referenced by `keyFindings[].citationIds` and `recommendations[].citationIds`; do not append unused available citations.
|
||||
|
||||
### 4. Validation & Error Matrix
|
||||
@@ -420,7 +421,7 @@ ANTHROPIC_API_KEY=sk-ant-...
|
||||
### 6. Tests Required
|
||||
|
||||
- Permission seeding assertions for `ai:*` and `knowledge:*` default role grants.
|
||||
- Knowledge retrieval tests for platform shared, own organization, other organization, and disabled entry filtering.
|
||||
- Knowledge retrieval tests for platform shared, own organization, other organization, disabled entry filtering, and cosine-score ordering from JSONB embeddings.
|
||||
- Analysis tests for missing config, schema validation failure, failed-history sanitization, and data-scope redaction.
|
||||
- Analysis tests for unknown citation rejection and referenced-only citation persistence.
|
||||
- Route tests for auth/permission failures and standard response shape.
|
||||
|
||||
Reference in New Issue
Block a user