Skip to content

Commit fa818f4

Browse files
committed
docs(service-knowledge): state the Base URL rule as plain behaviour
Claude-Session: https://claude.ai/code/session_01QSeKYofJfCPWsxaVYkmaVF Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8e8243d commit fa818f4

4 files changed

Lines changed: 7 additions & 12 deletions

File tree

‎.changeset/37094-open-embedder-from-settings.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ feat(service-knowledge): the open edition registers `EMBEDDER_SERVICE` from the
99
Clause-②: yes (widening) — `@objectstack/embedder-openai` gains one export, `documentedMaxBatchSize(model): number | undefined`
1010
Metadata-protocol: none
1111

12-
- **An embedder from the settings page.** `KnowledgeServicePlugin` reads the saved `ai.embedder_*` settings once, at `kernel:bootstrapped`, and registers an `@objectstack/embedder-openai` embedder as `EMBEDDER_SERVICE` (`'embedder'`) for the saved provider. The saved Base URL is used only for `custom` and `azure`, the two providers whose form offers it; every other provider uses its preset endpoint, so a Base URL left saved from an earlier custom endpoint never receives another provider's key. The boot line names the endpoint host, never the key. "Saved" means any layer but the manifest default, an `OS_*` override included; `ai.embedder_dimensions` and `ai.embedder_batch_size` are read as positive integers whether they arrive as numbers or as text (an `OS_AI_EMBEDDER_DIMENSIONS=256` override), and a value that is not one is refused with a `warn`, not dropped. Completeness is the Test embedder button's own check. `@objectstack/service-knowledge` now depends on `@objectstack/embedder-openai`.
12+
- **An embedder from the settings page.** `KnowledgeServicePlugin` reads the saved `ai.embedder_*` settings once, at `kernel:bootstrapped`, and registers an `@objectstack/embedder-openai` embedder as `EMBEDDER_SERVICE` (`'embedder'`) for the saved provider. The saved Base URL applies only to the custom and Azure providers; other providers use their preset endpoint. The boot line names the endpoint host. "Saved" means any layer but the manifest default, an `OS_*` override included; `ai.embedder_dimensions` and `ai.embedder_batch_size` are read as positive integers whether they arrive as numbers or as text (an `OS_AI_EMBEDDER_DIMENSIONS=256` override), and a value that is not one is refused with a `warn`, not dropped. Completeness is the Test embedder button's own check. `@objectstack/service-knowledge` now depends on `@objectstack/embedder-openai`.
1313
- **An embedder already registered is kept.** One registered by ObjectOS Cloud or by a host's own plugin in `init()`, `start()` or a `kernel:ready` handler is kept, with one `info` line, and the settings are not applied.
1414
- **The batch size is passed only when it was saved, and is held to the model's documented cap.** Unsaved (the form shows 64), the embedder batches at the model's documented cap. Saved, it is passed as `min(saved, documented cap)` when the saved model has a documented cap (DashScope `text-embedding-v3`: a saved 64 sends 10 per request), and as saved for a model with none.
1515
- **No embedder configured: the boot succeeds, and every use of the embedder answers an error naming the missing settings.** With no provider saved, `none` saved, or incomplete settings, `EMBEDDER_SERVICE` is an embedder whose `embed()` and `dimensions` refuse with that reason and the restart it needs, so an adapter that embeds refuses indexing and search with it. Nothing is sent to a provider until one is saved, and the API key is never logged or put in an error.

‎content/docs/ai/knowledge-rag.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ installed ([Connect an MCP Client](/docs/ai/connect-mcp)).
8484
When `KnowledgeServicePlugin` is mounted beside the settings service, Settings → AI & Embedder offers an **Embedder** section (`ai.embedder_*`): provider, API key, model, Base URL (for a custom or Azure endpoint), dimensions and batch size. The knowledge plugin reads those settings once, when the server starts, and registers the `EMBEDDER_SERVICE` (`'embedder'`) that knowledge adapters embed with:
8585

8686
- **An embedder is already registered** — by ObjectOS Cloud, or by your own plugin — **it is kept.** The plugin logs one line saying so and does not apply the settings. It checks at `kernel:bootstrapped`, after every plugin's `init()`, `start()` and `kernel:ready` handler, so an embedder registered in any of those is seen. Register yours there, not later.
87-
- **A provider is saved and complete** → an `@objectstack/embedder-openai` embedder for that provider. A custom or Azure endpoint uses the saved Base URL; every other provider uses its preset endpoint, even when a Base URL is still saved from an earlier custom endpoint, so a new provider's key never goes to the old host. The boot line names the endpoint host. "Complete" is what the **Test embedder** button checks: a provider, an API key (Ollama excepted) and, for a custom or Azure endpoint, a Base URL.
87+
- **A provider is saved and complete** → an `@objectstack/embedder-openai` embedder for that provider. The saved Base URL applies only to the custom and Azure providers; other providers use their preset endpoint. The boot line names the endpoint host. "Complete" is what the **Test embedder** button checks: a provider, an API key (Ollama excepted) and, for a custom or Azure endpoint, a Base URL.
8888
- **Dimensions and batch size are positive integers**, saved as numbers or set as text through an `OS_*` override (`OS_AI_EMBEDDER_DIMENSIONS=256`). A value that is not a positive integer is refused, with a `warn` at boot and the error below on every use — never silently ignored.
8989
- **The batch size is passed only when you saved it.** Left unsaved (the form shows 64), the embedder sends as many inputs per request as the model's documented cap allows — 10 for DashScope `text-embedding-v3`, 2048 for OpenAI `text-embedding-3-*` — and 10 for a model it does not know. A saved batch size is held to the saved model's documented cap (`documentedMaxBatchSize(model)` from `@objectstack/embedder-openai`): a saved 64 on `text-embedding-v3` sends 10. For a model without a documented cap the saved size is sent as saved.
9090
- **Nothing is configured** — no provider saved, `none` saved, or the saved settings incomplete → the server still boots, and every use of the embedder answers an error naming the missing settings: an adapter that embeds refuses indexing and search with it, and nothing is sent anywhere. Nothing is sent to a provider until you have saved one, and the API key is never logged or put in an error.

‎packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,17 +493,14 @@ describe('#37094 — the open edition registers EMBEDDER_SERVICE from the ai.emb
493493
expect(requests.map((r) => r.inputs.length)).toEqual([50, 10]);
494494
});
495495

496-
it('a Base URL left saved from a custom endpoint is not applied under a preset provider', async () => {
496+
it('a preset provider uses its preset endpoint even when a Base URL is saved', async () => {
497497
const requests = stubProvider();
498-
// The operator once saved `custom` with a gateway, then switched to OpenAI
499-
// with a new key: the Base URL row stays saved, but the form no longer
500-
// offers the field, and the new key must not go to the old gateway.
501498
const { embedder, lines } = await bootEmbedder({
502499
saved: {
503500
embedder_provider: 'openai',
504501
embedder_api_key: API_KEY,
505502
embedder_model: 'text-embedding-3-small',
506-
embedder_base_url: 'https://old-gateway.example.com/v1',
503+
embedder_base_url: 'https://gateway.example.com/v1',
507504
},
508505
});
509506
await embedder.embed(['x']);

‎packages/services/service-knowledge/src/knowledge-service-plugin.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,9 @@ async function embedderFromSettings(ctx: PluginContext): Promise<EmbedderFromSet
227227
const preset = Object.prototype.hasOwnProperty.call(OPENAI_COMPATIBLE_PRESETS, providerId)
228228
? (providerId as OpenAICompatiblePreset)
229229
: undefined;
230-
// The saved Base URL applies only where the form offers the field (`custom`,
231-
// `azure`, the manifest's `visible` rule). A URL saved under one of those and
232-
// left behind when the operator switches to a preset provider must not carry
233-
// the new provider's key to the old host: every other provider uses its
234-
// preset endpoint.
230+
// The saved Base URL applies only to the providers whose form offers the
231+
// field (`custom`, `azure`, the manifest's `visible` rule); every other
232+
// provider uses its preset endpoint.
235233
const baseUrl =
236234
BASE_URL_PROVIDERS.has(providerId) && typeof saved.embedder_base_url === 'string'
237235
? saved.embedder_base_url.trim()

0 commit comments

Comments
 (0)