Skip to content

feat: add opt-in Pinecone retrieval practice#23

Merged
CoreyLeath-code merged 11 commits into
mainfrom
feat/pinecone-portfolio-practice-20260725
Jul 26, 2026
Merged

feat: add opt-in Pinecone retrieval practice#23
CoreyLeath-code merged 11 commits into
mainfrom
feat/pinecone-portfolio-practice-20260725

Conversation

@CoreyLeath-code

@CoreyLeath-code CoreyLeath-code commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the Pinecone and portfolio engineering practices from SentinelAI issue #13 for Facial Emotion Recognition.

  • preserves the existing local/offline vector backend as the default
  • adds an opt-in Pinecone adapter with environment-only secrets
  • adds Pinecone configuration and optional dependency documentation
  • adds a linked Pinecone badge to the README
  • documents hosted retrieval benchmark requirements separately from local measurements
  • keeps production and domain claims explicitly bounded

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

    • Added optional Pinecone-powered psychology-context retrieval.
    • Added configuration options for selecting local or hosted context retrieval and embedding settings.
    • Added optional Pinecone and OpenAI package requirements.
  • Documentation

    • Documented hosted context retrieval setup and evaluation considerations.
    • Clarified that local retrieval remains the default for offline testing.
    • Added guidance on responsible use of the emotion classifier.
  • Chores

    • Improved container builds by retrying failed builds up to three times.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@CoreyLeath-code, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c851c3e6-5607-4786-80e3-ec2e3af6e73f

📥 Commits

Reviewing files that changed from the base of the PR and between 8e2bee1 and 206b2bd.

📒 Files selected for processing (2)
  • src/src/rag/context_retriever.py
  • tests/production/test_context.py
📝 Walkthrough

Walkthrough

Changes

Context Retrieval Backend

Layer / File(s) Summary
Retrieval configuration and documentation
.env.example, requirements-pinecone.txt, README.md
Adds Pinecone and embedding configuration, optional dependencies, setup guidance, evaluation requirements, and usage constraints.
Backend selection and retrieval
src/src/rag/context_retriever.py
Adds validated local/Pinecone backend selection, Pinecone initialization, OpenAI embedding generation, Pinecone querying, and local fallback lookup.

CI Build Retries

Layer / File(s) Summary
Retryable container build
.github/workflows/ci.yml
Retries Docker image builds up to three times with increasing delays and explicit final failure handling.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding opt-in Pinecone retrieval support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pinecone-portfolio-practice-20260725

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/src/rag/context_retriever.py Outdated
Comment on lines +63 to +66
query = " ".join(emotions)
vector = OpenAI().embeddings.create(
model=os.getenv("EMBEDDING_MODEL", "text-embedding-3-small"),
input=query,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread src/src/rag/context_retriever.py Outdated
Comment on lines +63 to +66
query = " ".join(emotions)
vector = OpenAI().embeddings.create(
model=os.getenv("EMBEDDING_MODEL", "text-embedding-3-small"),
input=query,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread README.md
### 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@CoreyLeath-code
CoreyLeath-code merged commit f721b3d into main Jul 26, 2026
7 checks passed
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