Skip to content

PSMDB-2143 Implement OpenAI-compatible embedding provider#17

Open
igorsol wants to merge 5 commits into
mainfrom
psmdb-2143
Open

PSMDB-2143 Implement OpenAI-compatible embedding provider#17
igorsol wants to merge 5 commits into
mainfrom
psmdb-2143

Conversation

@igorsol

@igorsol igorsol commented Jul 20, 2026

Copy link
Copy Markdown

No description provided.

@igorsol
igorsol requested a review from Copilot July 20, 2026 12:40
@it-percona-cla

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI 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.

Pull request overview

Implements an OpenAI-compatible embedding provider end-to-end, enabling auto-embedding against any server that speaks the OpenAI /v1/embeddings API (e.g., Ollama/vLLM/TEI/OpenAI/Azure OpenAI), including support for keyless local engines and an operator-editable on-disk model catalog.

Changes:

  • Added OPENAI_COMPATIBLE provider support across config parsing, model config/credentials types, client factory wiring, and vector-param resolution.
  • Introduced OpenAiCompatClient and OpenAiApiSchema to serialize requests and decode embeddings (base64 float32 LE and fallback JSON float arrays).
  • Shipped and tested a default OpenAI-compatible catalog (including on-disk override behavior) and updated bootstrap/config logic to keep OpenAI-compatible models usable even without Voyage credentials.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test/unit/java/com/xgen/mongot/embedding/providers/config/OpenAiApiSchemaTest.java Adds unit coverage for OpenAI embeddings request/response BSON/JSON handling.
src/test/unit/java/com/xgen/mongot/embedding/providers/config/BUILD Registers the new schema test in the suite.
src/test/unit/java/com/xgen/mongot/embedding/providers/clients/OpenAiCompatClientTest.java Adds extensive unit coverage for auth headers, dimensions forwarding, prefixes, retry/error semantics, and HttpClient renewal behavior.
src/test/unit/java/com/xgen/mongot/embedding/providers/clients/EmbeddingClientFactoryTest.java Verifies factory wiring for OPENAI_COMPATIBLE across tiers and flex-tier isolation.
src/test/unit/java/com/xgen/mongot/embedding/providers/clients/BUILD Registers the new OpenAI-compatible client test in the suite.
src/test/unit/java/com/xgen/mongot/config/provider/community/embedding/EmbeddingServiceManagerConfigTest.java Expands tests for provider parsing, keyless behavior, and on-disk catalog overrides/fallbacks.
src/test/unit/java/com/xgen/mongot/config/provider/community/CommunityMongotBootstrapperTest.java Ensures global endpoint override applies to Voyage only and does not leak into OpenAI-compatible models.
src/test/unit/java/com/xgen/mongot/config/provider/community/CommunityConfigTest.java Updates config deserialization tests for the new modelConfigFile field.
src/main/resources/config/community/embedding-service-configs.yml Adds OpenAI-compatible model entries (bge-m3, nomic-embed-text) and Azure template documentation.
src/main/resources/config/community/BUILD Exposes the catalog filegroup to //deploy:__pkg__ for packaging.
src/main/java/com/xgen/mongot/index/definition/VectorAutoEmbedFieldSpecification.java Resolves vector params via the polymorphic ModelConfig interface (not Voyage-only) and uses “configured” getters.
src/main/java/com/xgen/mongot/embedding/providers/configs/OpenAiApiSchema.java Implements OpenAI embeddings wire schema with base64 float decoding + JSON float-array tolerance.
src/main/java/com/xgen/mongot/embedding/providers/configs/EmbeddingServiceConfig.java Adds OPENAI_COMPATIBLE, introduces OpenAiModelConfig/OpenAiEmbeddingCredentials, and extends ModelConfig with “configured” accessors.
src/main/java/com/xgen/mongot/embedding/providers/configs/EmbeddingModelConfig.java Adds consolidation logic for OpenAI model configs and supports OpenAI credentials overrides.
src/main/java/com/xgen/mongot/embedding/providers/configs/EmbeddingConfigFactory.java Extends polymorphic parsing to OpenAI model configs and credentials.
src/main/java/com/xgen/mongot/embedding/providers/configs/BUILD.bazel Includes OpenAiApiSchema.java in the library.
src/main/java/com/xgen/mongot/embedding/providers/clients/OpenAiCompatClient.java Adds the OpenAI-compatible HTTP client implementation (auth, retry classification, decoding, HttpClient refresh/renewal).
src/main/java/com/xgen/mongot/embedding/providers/clients/EmbeddingClientFactory.java Wires OPENAI_COMPATIBLE to build OpenAiCompatClient.
src/main/java/com/xgen/mongot/embedding/providers/clients/BUILD Includes OpenAiCompatClient.java in the clients library.
src/main/java/com/xgen/mongot/config/provider/community/embedding/EmbeddingServiceManagerConfig.java Adds on-disk catalog override support and keyless model loading behavior; injects provider discriminators/credentials.
src/main/java/com/xgen/mongot/config/provider/community/embedding/EmbeddingConfig.java Adds modelConfigFile to community embedding config schema.
src/main/java/com/xgen/mongot/config/provider/community/CommunityMongotBootstrapper.java Enables auto-embedding without Voyage keys, adds “empty manager” helper, and scopes endpoint override to Voyage only.
deploy/community-resources/mongot Sets -Dmongot.embeddingModelConfigFile to point at the on-disk shipped catalog.
deploy/community-resources/config.default.yml Documents Voyage-only endpoint override and the new on-disk catalog override option.
deploy/BUILD Packages the default embedding model catalog into the deploy tar.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@igorsol
igorsol force-pushed the psmdb-2143 branch 2 times, most recently from 63f6dde to d7da0b9 Compare July 21, 2026 16:56
…schema)

Generic embedding client for any server speaking the OpenAI
/v1/embeddings protocol (OpenAI, Azure OpenAI, Ollama, vLLM, llama.cpp,
LM Studio, LocalAI, HF TEI). Optional API key (keyless local engines),
Authorization: Bearer or Azure api-key auth header, fail-fast on
HTTP 401/403, tier-aware query/document input prefixes, opt-in
dimensions forwarding resolved from the request context, float-only
day 1 (quantization requests fail fast).

Replaces the hard VoyageModelConfig cast in
VectorAutoEmbedFieldSpecification with polymorphic ModelConfig
accessors so non-Voyage providers resolve numDimensions, quantization,
and similarity.

Co-authored-by: Oleksandr Miroshnychenko <alex.miroshnychenko@percona.com>
igorsol and others added 4 commits July 23, 2026 11:52
Auto-embedding now enables whenever an embedding: config section is
present: Voyage API keys are optional, VOYAGE catalog entries are
dropped with a warning when no keys are configured, and keyless
OPENAI_COMPATIBLE models are kept. The model catalog can be overridden
on disk via embedding.modelConfigFile or the
mongot.embeddingModelConfigFile system property, falling back to the
bundled resource. The global providerEndpoint override applies to
VOYAGE models only; OPENAI_COMPATIBLE models keep their per-model
catalog endpoints. Bundled catalog gains two local Ollama models
(bge-m3, nomic-embed-text) plus a commented Azure OpenAI template.

Co-authored-by: Oleksandr Miroshnychenko <alex.miroshnychenko@percona.com>
Ship embedding-service-configs.yml next to the JAR in the community
tarball and point the launcher at it via
-Dmongot.embeddingModelConfigFile so operators can edit the model
catalog and restart without rebuilding. Document modelConfigFile and
the VOYAGE-only scope of providerEndpoint in config.default.yml.

Co-authored-by: Oleksandr Miroshnychenko <alex.miroshnychenko@percona.com>
Operators can put modelConfig/credentials under query, collectionScan, or
changeStream in an on-disk catalog without the internal discriminator;
inject those the same way as the base fields so parsing succeeds.
Avoid silently falling back to the bundled catalog (localhost endpoints)
when an operator-set modelConfigFile is missing or invalid; keep soft
fallback only for the launcher system-property path, and assert ERROR logs.
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.

3 participants