feat: add opt-in Pinecone retrieval practice#23
Conversation
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughChangesContext Retrieval Backend
CI Build Retries
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant EmotionContextRetriever
participant OpenAIEmbeddings
participant PineconeIndex
EmotionContextRetriever->>OpenAIEmbeddings: Create embedding for emotion labels
OpenAIEmbeddings-->>EmotionContextRetriever: Return embedding vector
EmotionContextRetriever->>PineconeIndex: Query vector with metadata
PineconeIndex-->>EmotionContextRetriever: Return matched context text
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35be09ea38
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| query = " ".join(emotions) | ||
| vector = OpenAI().embeddings.create( | ||
| model=os.getenv("EMBEDDING_MODEL", "text-embedding-3-small"), | ||
| input=query, |
There was a problem hiding this comment.
Avoid blocking the API event loop during embedding requests
When EMOTION_CONTEXT_BACKEND=pinecone, the async /rag, /explain, and /full-analysis handlers call this synchronous OpenAI request directly through retrieve(). While the external request is in flight, the worker's event loop cannot serve unrelated predictions or health checks, so ordinary Pinecone/OpenAI latency or a timeout can stall the entire API under concurrent traffic; use the asynchronous clients or offload the hosted retrieval to a thread pool.
Useful? React with 👍 / 👎.
| query = " ".join(emotions) | ||
| vector = OpenAI().embeddings.create( | ||
| model=os.getenv("EMBEDDING_MODEL", "text-embedding-3-small"), | ||
| input=query, |
There was a problem hiding this comment.
Handle an empty emotion list before requesting an embedding
The request model permits {"emotions": []}, and the local backend previously returned an empty context for that input, but the Pinecone path converts it to input=""; the OpenAI embeddings API rejects an empty string, causing this otherwise valid API request to surface as a server error. Either require at least one emotion in EmotionRequest or return an empty context before invoking the embedding API.
Useful? React with 👍 / 👎.
| ### Architecture flowchart | ||
| ### Optional Pinecone context retrieval | ||
|
|
||
| The psychology-context component supports a hosted Pinecone index without changing the deterministic default. Install `requirements-pinecone.txt`, set `EMOTION_CONTEXT_BACKEND=pinecone`, and provide the Pinecone/OpenAI secrets through deployment configuration. Keep `local` for CI and offline tests. |
There was a problem hiding this comment.
Document and provision the Pinecone index contract
Following these setup instructions is insufficient to obtain hosted context: the adapter assumes an already-populated namespace whose records contain text in a metadata field named exactly text, but the README does not describe index creation, dimension/metric compatibility, upserts, or that metadata schema. A repo-wide search finds no ingestion utility or alternate schema documentation, so a user configuring a fresh index as directed receives empty context even though retrieval succeeds; document the required corpus/index format and provide a reproducible ingestion step or fixture.
Useful? React with 👍 / 👎.
Summary
Implements the Pinecone and portfolio engineering practices from SentinelAI issue #13 for Facial Emotion Recognition.
Validation
The repository's existing CI, tests, security scans, and benchmark workflows should validate the change. Pinecone network calls are not required for default CI.
Refs CoreyLeath-code/SentinelAI#13
Summary by CodeRabbit
New Features
Documentation
Chores