vector search#388
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
Code Review
This pull request introduces AI embedding generation and caching capabilities. It adds a new EMBEDDING type to the GraphQL schema, implements a createEmbedding utility using Google Vertex AI with support for media chunking, and includes comprehensive tests. Feedback focuses on a breaking change in the createAIResponse utility that affects existing callers, the lack of handling for concurrent 'LOADING' states which could lead to redundant API calls, and opportunities to improve performance by parallelizing media chunk processing and reusing AI clients. Additionally, the AIEmbedding GraphQL type should include the text field to expose error messages.
| if ( | ||
| cached && | ||
| cached.status === 'SUCCESS' && | ||
| Array.isArray(cached.embeddings) && | ||
| cached.embeddings.length > 0 | ||
| ) { | ||
| return cached.embeddings as EmbeddingChunk[]; | ||
| } |
There was a problem hiding this comment.
The current logic only returns cached embeddings if the status is SUCCESS. If an embedding is currently being generated (status: 'LOADING'), this code will proceed to call createAIResponse, which likely creates a duplicate loading record and starts a redundant generation process. It should instead wait for the existing process to complete.
| fields: { | ||
| ...commonAiResponseFields, | ||
| }, |
There was a problem hiding this comment.
770f044 to
cbfc471
Compare
b88be5e to
0e01635
Compare
366b8d2 to
299be47
Compare
db134bc to
a42a369
Compare
Add dense-vector (kNN) retrieval to ListArticles/ListReplies, opt-in via the `embedding` similarity filter. kNN narrows the candidate set and the existing BM25 / perceptual-hash scoring ranks the results. - Embed articles and replies on create; backfill script for old docs. - Audio/video embed as a single vector capped at 80s (no duration probe). - Media queries reuse the doc-side embedding by content hash, else fetch bytes from the query URL and embed — search never persists to GCS, so no orphan files. - All Gemini calls (embeddings + transcription) use the Developer API and feed media via the Files API; Vertex AI is removed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GEMINI_API_KEY)generativelanguage.googleapis.comlocation)gs://、HTTPS URL、inlineDatags://、inlineData混合搜尋(kNN 檢索 + BM25 排序)使用說明
如何啟用
在
ListArticles/ListReplies的filter加上embedding欄位:embedding→ 純 BM25(預設,完全向後相容)。embedding是一個Float,直接給門檻值即可,不是物件。範例
文字查詢