Skip to content

feat(ai): default Anthropic installs to pgvector RAG (4/5)#1986

Draft
gariasf wants to merge 1 commit into
feature/anthropic-pdffrom
feature/anthropic-rag-pgvector
Draft

feat(ai): default Anthropic installs to pgvector RAG (4/5)#1986
gariasf wants to merge 1 commit into
feature/anthropic-pdffrom
feature/anthropic-rag-pgvector

Conversation

@gariasf
Copy link
Copy Markdown
Collaborator

@gariasf gariasf commented May 25, 2026

Summary

Closes the Anthropic RAG loop. PR 4 of 5, stacked on #1985.

Background

The provider-agnostic vector store stack already shipped to main:

  • VectorStore::Pgvector — local pgvector adapter with chunk + embed pipeline
  • VectorStore::Embeddable — embeddings via any OpenAI-compatible endpoint (EMBEDDING_URI_BASE, EMBEDDING_ACCESS_TOKEN)
  • VectorStore::RegistryVECTOR_STORE_PROVIDER env routes between openai, pgvector, qdrant
  • db/migrate/20260316120000_create_vector_store_chunks.rb — pgvector table + index

This PR makes Anthropic the first-class citizen of that stack.

What changed

  • VectorStore::Registry.adapter_name now returns :pgvector when Setting.llm_provider == "anthropic" and no explicit VECTOR_STORE_PROVIDER override is set. Anthropic has no hosted vector store, so the local pgvector adapter is the only correct default. Explicit VECTOR_STORE_PROVIDER=... still wins.
  • Assistant::Function::SearchFamilyFiles updates its "no adapter" error message to mention pgvector + EMBEDDING_URI_BASE as the supported Anthropic-only path, instead of pointing exclusively at OpenAI.

What didn't change (intentional)

  • Embedding generation is decoupled from the chat provider. Anthropic installs point EMBEDDING_URI_BASE at Voyage AI (Anthropic's recommended embeddings partner), a local Ollama instance, or OpenAI's text-embedding-3-small. No new gem; no new credentials beyond what already exists.
  • VectorStore::Pgvector, VectorStore::Embeddable, the migration, and the vector_store_chunks schema are unchanged.

Setup checklist for Anthropic-only installs

# 1. Enable pgvector in Postgres (one-time)
psql -d sure_production -c "CREATE EXTENSION vector;"

# 2. Run the existing migration
bin/rails db:migrate

# 3. Configure embeddings — examples:
#    OpenAI embeddings (cheap, no chat-provider dep)
EMBEDDING_URI_BASE=https://api.openai.com/v1/
EMBEDDING_ACCESS_TOKEN=sk-...
EMBEDDING_MODEL=text-embedding-3-small
EMBEDDING_DIMENSIONS=1536

#    Voyage AI
EMBEDDING_URI_BASE=https://api.voyageai.com/v1/
EMBEDDING_ACCESS_TOKEN=pa-...
EMBEDDING_MODEL=voyage-3

#    Ollama (fully local)
EMBEDDING_URI_BASE=http://localhost:11434/v1/
EMBEDDING_MODEL=nomic-embed-text
EMBEDDING_DIMENSIONS=1024

With LLM_PROVIDER=anthropic set, VectorStore.adapter now resolves to pgvector automatically — no extra VECTOR_STORE_PROVIDER needed.

Test plan

  • test/models/vector_store/registry_test.rb — 3 new tests:
    • defaults to pgvector when LLM_PROVIDER=anthropic
    • routes to pgvector even when an OpenAI key is also present
    • explicit VECTOR_STORE_PROVIDER=qdrant still wins on Anthropic installs
  • All existing registry tests untouched and still pass
  • Full suite: 4380 runs, 18086 assertions, 0 failures, 26 pre-existing skips, 1 pre-existing libvips env error
  • bin/rubocop clean
  • bin/brakeman --no-pager clean

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91dd230e-f36f-4053-9fc7-01a290e430a6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/anthropic-rag-pgvector

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 and usage tips.

@gariasf gariasf force-pushed the feature/anthropic-pdf branch from 4f826b0 to 84651bc Compare May 25, 2026 17:50
@gariasf gariasf force-pushed the feature/anthropic-rag-pgvector branch from 58c88d9 to 6d92ea2 Compare May 25, 2026 17:50
gariasf added a commit that referenced this pull request May 25, 2026
Adds the Anthropic panel and the install-wide LLM provider selector to
the self-hosting settings page, plus a shared data-retention
disclosure that covers both OpenAI and Anthropic.

- New _llm_provider_selector partial: select for Setting.llm_provider
  (openai | anthropic), respects the LLM_PROVIDER env var (disables the
  control + shows the "configured through environment variables" hint
  when set, mirroring the existing OpenAI panel behaviour), and renders
  a compact data-handling block with one-line retention statements for
  each provider.
- New _anthropic_settings partial mirrors _openai_settings exactly:
  password-field for the API key with **** redaction, optional
  base_url (for AWS Bedrock / GCP Vertex), optional default model. All
  three fields disable when their ENV var is set.
- show.html.erb renders provider selector + OpenAI panel + Anthropic
  panel under the same "General" section so users can configure either
  (or both) without switching pages.
- Settings::HostingsController#update now permits and persists
  anthropic_access_token (ignoring the **** placeholder, same pattern
  as OpenAI), anthropic_base_url, anthropic_model, and llm_provider
  (validated against %w[openai anthropic]). On Setting::ValidationError
  the rescue branch preserves anthropic_base_url / anthropic_model
  input so the form re-renders with the user's typed values intact —
  parity with the issue #1824 fix for OpenAI.
- Locale keys added under settings.hostings.{llm_provider_selector,
  anthropic_settings}.

Tests cover token update + placeholder redaction, base_url + model
update, llm_provider switch to anthropic, and rejection of unknown
provider values. The existing GET render test still passes, exercising
all three new partials.

Closes the 5/5 Anthropic series stacked on #1986.
@gariasf gariasf force-pushed the feature/anthropic-pdf branch from 84651bc to dae1599 Compare May 25, 2026 17:58
@gariasf gariasf force-pushed the feature/anthropic-rag-pgvector branch from 6d92ea2 to bb4fee3 Compare May 25, 2026 17:58
gariasf added a commit that referenced this pull request May 25, 2026
Adds the Anthropic panel and the install-wide LLM provider selector to
the self-hosting settings page, plus a shared data-retention
disclosure that covers both OpenAI and Anthropic.

- New _llm_provider_selector partial: select for Setting.llm_provider
  (openai | anthropic), respects the LLM_PROVIDER env var (disables the
  control + shows the "configured through environment variables" hint
  when set, mirroring the existing OpenAI panel behaviour), and renders
  a compact data-handling block with one-line retention statements for
  each provider.
- New _anthropic_settings partial mirrors _openai_settings exactly:
  password-field for the API key with **** redaction, optional
  base_url (for AWS Bedrock / GCP Vertex), optional default model. All
  three fields disable when their ENV var is set.
- show.html.erb renders provider selector + OpenAI panel + Anthropic
  panel under the same "General" section so users can configure either
  (or both) without switching pages.
- Settings::HostingsController#update now permits and persists
  anthropic_access_token (ignoring the **** placeholder, same pattern
  as OpenAI), anthropic_base_url, anthropic_model, and llm_provider
  (validated against %w[openai anthropic]). On Setting::ValidationError
  the rescue branch preserves anthropic_base_url / anthropic_model
  input so the form re-renders with the user's typed values intact —
  parity with the issue #1824 fix for OpenAI.
- Locale keys added under settings.hostings.{llm_provider_selector,
  anthropic_settings}.

Tests cover token update + placeholder redaction, base_url + model
update, llm_provider switch to anthropic, and rejection of unknown
provider values. The existing GET render test still passes, exercising
all three new partials.

Closes the 5/5 Anthropic series stacked on #1986.
@gariasf gariasf force-pushed the feature/anthropic-pdf branch from dae1599 to 826e56b Compare May 25, 2026 18:34
The provider-agnostic vector store stack (VectorStore::Pgvector + the
Embeddable concern) already shipped to main. This PR closes the
Anthropic loop:

- VectorStore::Registry.adapter_name now returns :pgvector when
  Setting.llm_provider == "anthropic" and no explicit
  VECTOR_STORE_PROVIDER override is set. Anthropic has no hosted vector
  store, so falling back to the local pgvector adapter is the only
  correct default. Explicit VECTOR_STORE_PROVIDER still wins.
- SearchFamilyFiles surfaces a longer message when no adapter is wired
  up — calling out pgvector + EMBEDDING_URI_BASE as the supported
  Anthropic-only path so the user is not stuck with an "OpenAI required"
  hint that is no longer accurate.

The Embeddable concern already pulls embeddings from
EMBEDDING_URI_BASE / EMBEDDING_ACCESS_TOKEN (with OpenAI as fallback),
so Anthropic installs point this at Voyage AI, a local Ollama instance,
or OpenAI embeddings — independent of the chat provider.

Tests cover the new default routing, the existing OpenAI default
staying intact, and explicit VECTOR_STORE_PROVIDER overriding the
Anthropic default.

Stacked on #1985 (PR 3/5). 5/5 settings UI + retention disclosure next.
@gariasf gariasf force-pushed the feature/anthropic-rag-pgvector branch from bb4fee3 to 06762d0 Compare May 25, 2026 18:34
gariasf added a commit that referenced this pull request May 25, 2026
Adds the Anthropic panel and the install-wide LLM provider selector to
the self-hosting settings page, plus a shared data-retention
disclosure that covers both OpenAI and Anthropic.

- New _llm_provider_selector partial: select for Setting.llm_provider
  (openai | anthropic), respects the LLM_PROVIDER env var (disables the
  control + shows the "configured through environment variables" hint
  when set, mirroring the existing OpenAI panel behaviour), and renders
  a compact data-handling block with one-line retention statements for
  each provider.
- New _anthropic_settings partial mirrors _openai_settings exactly:
  password-field for the API key with **** redaction, optional
  base_url (for AWS Bedrock / GCP Vertex), optional default model. All
  three fields disable when their ENV var is set.
- show.html.erb renders provider selector + OpenAI panel + Anthropic
  panel under the same "General" section so users can configure either
  (or both) without switching pages.
- Settings::HostingsController#update now permits and persists
  anthropic_access_token (ignoring the **** placeholder, same pattern
  as OpenAI), anthropic_base_url, anthropic_model, and llm_provider
  (validated against %w[openai anthropic]). On Setting::ValidationError
  the rescue branch preserves anthropic_base_url / anthropic_model
  input so the form re-renders with the user's typed values intact —
  parity with the issue #1824 fix for OpenAI.
- Locale keys added under settings.hostings.{llm_provider_selector,
  anthropic_settings}.

Tests cover token update + placeholder redaction, base_url + model
update, llm_provider switch to anthropic, and rejection of unknown
provider values. The existing GET render test still passes, exercising
all three new partials.

Closes the 5/5 Anthropic series stacked on #1986.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant