Skip to content

feat: Support OpenAI-compatible embeddings base URL#69

Merged
BhagyaAmarasinghe merged 1 commit into
mainfrom
openai-url
May 6, 2026
Merged

feat: Support OpenAI-compatible embeddings base URL#69
BhagyaAmarasinghe merged 1 commit into
mainfrom
openai-url

Conversation

@BhagyaAmarasinghe
Copy link
Copy Markdown
Contributor

Summary

  • Add EMBEDDING_BASE_URL as an optional config/env/Helm value for EMBEDDING_PROVIDER=openai.
  • Wire the base URL through API, worker, and backfill embedding client creation so Hub can target OpenAI-compatible self-hosted embedding runtimes.
  • Validate custom base URLs and reject them for non-OpenAI providers.
  • Add tests for config normalization/validation, provider validation, and explicit base URL precedence over OPENAI_BASE_URL.

Validation

  • go test ./internal/... ./cmd/... ./pkg/...
  • make lint GOLANGCI_LINT="$(go env GOPATH)/bin/golangci-lint"
  • git diff --cached --check
  • helm lint /Users/bhagya/work/formbricks/hub/charts/hub
  • helm template hub /Users/bhagya/work/formbricks/hub/charts/hub --set secrets.stringData.DATABASE_URL=postgres://example --set secrets.stringData.API_KEY=test-key

Notes

go test ./... still requires the local integration Postgres on localhost:5432; that dependency was unavailable in this environment, so the DB-backed tests/ package could not be validated locally.

@BhagyaAmarasinghe BhagyaAmarasinghe changed the title [codex] Support OpenAI-compatible embeddings base URL feat: Support OpenAI-compatible embeddings base URL May 5, 2026
@BhagyaAmarasinghe BhagyaAmarasinghe marked this pull request as ready for review May 5, 2026 19:57
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Walkthrough

This change introduces support for configuring a custom base URL for embeddings services. A new optional environment variable EMBEDDING_BASE_URL is added to configuration files and validated through a refactored URL normalization helper. The configuration value is threaded through embedding client initialization in all relevant entry points (API, worker, backfill commands) and wired into the OpenAI client with a new WithBaseURL option. Validation ensures the base URL is only used with the OpenAI provider. Comprehensive tests verify URL normalization, provider-specific restrictions, and explicit base URL precedence over environment variables.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: Support OpenAI-compatible embeddings base URL' accurately describes the main change—adding support for a configurable base URL for OpenAI-compatible embeddings.
Description check ✅ Passed The PR description covers the what, how to test, and validation steps. While the checklist is not explicitly marked with checkboxes, the validation section demonstrates testing and confirmation of the changes made.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/service/embedding_client_factory_test.go`:
- Around line 104-114: Add parallel test cases for the "google-gemini" provider
mirroring the existing "google" BaseURL restriction checks in
TestNewEmbeddingClient and TestValidateEmbeddingConfig: create entries using
Provider set to EmbeddingProviderGoogleGemini (or the constant used for
google-gemini), ProviderAPIKey "key", Model "text-embedding-004", BaseURL
"https://embeddings.example.com/v1", and expect wantErr true with errIs
ErrEmbeddingBaseURLUnsupported; place them alongside the existing google case so
both provider variants assert the same BaseURL restriction.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cc88769e-4305-4916-85a1-91a12b9a2919

📥 Commits

Reviewing files that changed from the base of the PR and between 3d3f819 and fec8e77.

📒 Files selected for processing (11)
  • .env.example
  • charts/hub/values.yaml
  • cmd/api/app.go
  • cmd/backfill-embeddings/main.go
  • cmd/worker/app.go
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/openai/client.go
  • internal/openai/client_test.go
  • internal/service/embedding_client_factory.go
  • internal/service/embedding_client_factory_test.go

Comment thread internal/service/embedding_client_factory_test.go
Copy link
Copy Markdown
Contributor

@xernobyl xernobyl left a comment

Choose a reason for hiding this comment

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

LGTM

@BhagyaAmarasinghe BhagyaAmarasinghe added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit 843fa7d May 6, 2026
11 checks passed
@BhagyaAmarasinghe BhagyaAmarasinghe deleted the openai-url branch May 6, 2026 11:47
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.

2 participants