PSMDB-2143 Implement OpenAI-compatible embedding provider#17
Conversation
|
|
There was a problem hiding this comment.
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_COMPATIBLEprovider support across config parsing, model config/credentials types, client factory wiring, and vector-param resolution. - Introduced
OpenAiCompatClientandOpenAiApiSchemato 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.
63f6dde to
d7da0b9
Compare
…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>
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.
No description provided.