Skip to content

Commit b8c8c88

Browse files
feat(service-knowledge): register EMBEDDER_SERVICE from the ai.embedder_* settings when the knowledge service is mounted (#37265)
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Fixes #37094 Clause-②: yes (widening) — `@objectstack/embedder-openai` gains one export, `documentedMaxBatchSize(model): number | undefined` Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:开源部署挂上知识服务后,管理员在设置页「嵌入服务」里保存服务商和密钥、重启,知识检索就能用上这个嵌入器;设置页提示改动需重启生效。 - 为什么做:知识检索平台化专题的开源版嵌入器一项——此前设置页的嵌入配置在开源版没人读,应用只能自己写代码注册嵌入器。 - 出错会怎样:没配置时照常启动,需要嵌入的检索和建索引会报错并点名缺哪项设置,不向外发任何请求;已有嵌入器(云版注册的)保持不动;保存的批量大小超过模型公布上限时按上限发送。可直接撤回。 - 要你做的:无。 ## What changes - **`KnowledgeServicePlugin` registers `EMBEDDER_SERVICE` from the `ai.embedder_*` settings** (`packages/services/service-knowledge/src/knowledge-service-plugin.ts`). Read once, at `kernel:bootstrapped`: - **Already registered → kept.** One `info` line, settings not applied. A registration the sync accessor cannot hand out (an async factory) counts as registered too. - **Saved and complete → an `@objectstack/embedder-openai` embedder** for the saved provider. The saved Base URL applies to the custom and Azure providers; every other provider uses its preset endpoint. The boot line names the endpoint host. "Saved" = any layer but the manifest default (`source !== 'default'`, the same reading `plugin-email` uses for `branding.workspace_name`); an `OS_*` override counts as saved. "Complete" = the settings page's own Test embedder check (`aiTestEmbedderActionHandler`), handed only the saved values: reused, not forked. - **Batch size passed only when saved, held to the model's documented cap.** Unsaved (default 64) → the embedder batches at the model's documented cap. Saved → `Math.min(saved, documentedMaxBatchSize(model))` when the saved model has a documented cap, the saved size as saved otherwise (no saved model, or a model the table does not know). - **Dimensions and batch size are read as positive integers**, as numbers or as their decimal text (an `OS_AI_EMBEDDER_DIMENSIONS=256` override). Any other saved value is refused: `EMBEDDER_SERVICE` is the `UnconfiguredEmbedder`, with a `warn` boot line naming the key. - **Nothing configured** (no provider saved, `none` saved, incomplete, settings service absent, or the `ai` namespace without the embedder keys) → an `UnconfiguredEmbedder` is registered: `embed()` (non-empty) and `dimensions` refuse with a message naming the missing settings, where to save them and that a restart is needed. Boot succeeds; nothing is sent. Boot line is `info` when nothing asked for an embedder, `warn` when saved settings do not build one. - The API key never reaches a log line or an error message. Pinned on the configured path, on incomplete settings and on a provider answering 401. - **Restart note on the settings page**: a `description` on `embedder_provider` in `ai.manifest.ts` ("Read when the server starts: a saved change to any embedder setting takes effect after the next restart."), and its `help` copy in all 11 locale bundles. The translations are required by the gate: `settings-translation-coverage.test.ts` reds a described field with no `keys.KEY.help` in any locale. - **`@objectstack/embedder-openai` exports `documentedMaxBatchSize(model): number | undefined`** (seat direction, issue comment 7156326561): the documented per-request cap, read from the SAME module table `OpenAIEmbedder` batches by. No copy, and the constructor now reads the table through the same function. `OpenAIEmbedder` is unchanged: an explicit `maxBatchSize` is still used as given, above the cap included (pinned). - **Docs**: `content/docs/ai/knowledge-rag.mdx` gains "Configuring the embedder from Settings". - **Dependency edge (one, workspace, no external)**: `@objectstack/service-knowledge` → `@objectstack/embedder-openai`. Why this side: service-knowledge already depends on `core` (plugin contract) and `service-settings` (the settings reader and the reused completeness check), so the knowledge plugin needs exactly one new edge; a plugin in `embedder-openai` would need `core` and `service-settings` (two edges, a crypto library among the transitive ones) and a host would have to mount it by hand, which is the gap the card is about. Services depending on plugins has precedent (`service-storage`, `service-print`, `service-automation`). `embedder-openai` depends only on `spec`: no cycle. ### Why `kernel:bootstrapped` (the phase measurement) `ObjectKernel.bootstrap()` / `LiteKernel.bootstrap()` run every `init()`, then every `start()`, then `kernel:ready` handlers in plugin order, then `kernel:bootstrapped` once every `kernel:ready` handler has settled (`plugin-lifecycle-events.ts`). An embedder registered in `init()`, `start()` or any `kernel:ready` handler (where a settings-reading provider would register, since the settings engine binds in `kernel:ready`) is therefore visible at `kernel:bootstrapped`, regardless of plugin order. Pinned both ways: a host embedder registered at `init` and one registered in a `kernel:ready` handler are each kept. Only a registration in `kernel:bootstrapped` / `kernel:listening` or after boot would collide; the changeset says so. Settings are read after `kernel:ready` for the same reason the settings plugin documents: a read in the pre-bind window answers the default without consulting the store. Cloud reading (cloud-confirm 7159003875 on #37094, read at cloud main `packages/service-ai/src/plugin.ts`): `service-ai` applies its embedder in a `kernel:ready` hook (`bindSettings` → `applyEmbedder`), so its boot-time registration comes before this placeholder exists. Every later `ai` settings save calls `replaceService`, never `registerService`, so it replaces the placeholder without throwing. A cold boot with a configured provider still logs the existing `[AI] Failed to apply embedder settings` warning, as it does on main with nothing registered; the placeholder does not make that worse. No cloud deployment mounts the open `KnowledgeServicePlugin` beside `service-ai`. ## Tests New top-level `describe` in the knowledge+settings harness file (`src/__tests__/knowledge-settings-contribution.test.ts`), through the real registration path: settings SAVED via `SettingsService.setMany` in a `kernel:ready` handler, provider reached through a stubbed global `fetch`, and an adapter that looks up `EMBEDDER_SERVICE` where it embeds. No hand-built embedder. - saved settings → `indexDocument` sends one `POST https://api.openai.com/v1/embeddings` with the saved key and model; nothing sent at boot; key in no log line - custom endpoint → the saved Base URL - pre-registered at `init` / at `kernel:ready` → same instance kept, zero requests, one `info` line - unsaved batch size on DashScope `text-embedding-v3` → requests of 10, 10, 5 (not one of 25: the default 64 is not a saved value) - saved batch size 4 → requests of 4, 4, 1 - **pin (a)** saved 64 on `text-embedding-v3` (documented 10) → requests of 10, 10, 5, and the boot line names the saved 64 - **pin (b)** saved 50 on a custom model with no documented cap → requests of 50, 10 (kept as saved) - `embedder-openai`: `documentedMaxBatchSize` answers 10 / 2048 / `undefined` (unknown, and a prototype key); the embedder with no `maxBatchSize` batches at exactly that value; an explicit `maxBatchSize: 25` on a cap-10 model still sends 25 - no settings → boot succeeds; `indexDocument` and the adapter's `search` reject naming `ai.embedder_provider` and the restart; `KnowledgeService.search` answers `[]` and logs that error per source; `dimensions` refuses; zero requests; boot line `info` - `none` saved → refusal says so; incomplete (provider without key) → the page check's own message, boot line `warn` - a preset provider uses its preset endpoint even when a Base URL is saved → one request to the preset endpoint; the boot line names `endpoint=api.openai.com` - `OS_AI_EMBEDDER_DIMENSIONS=256` (arrives as text) → `dimensions` is 256 and the request carries `dimensions: 256` - `OS_AI_EMBEDDER_DIMENSIONS=large` → refused naming `ai.embedder_dimensions`, a `warn` boot line, zero requests - unsaved batch size on a custom model with no documented cap, 70 inputs → requests of 10 × 7 - the API key in no log line and no error: incomplete settings (`custom` without a Base URL), and a provider answering 401 Ablations (one-shot, `scripts/ablation-replace.mjs`, each mutation landed and restored to blob == HEAD, `git diff HEAD` empty): - treating the manifest default as saved (`if (!entry) return undefined;`) → 1 failed / 15 passed: exactly "an unsaved batch size on a model with no documented cap is the embedder fallback, not the default 64". - clamp removed (the `Math.min` line → `savedBatch`) → 1 failed / 15 passed: exactly pin (a). The first attempt at this one was a no-op: the replacement text already occurred in the anchor, the tool refused before running, and it was re-run with a distinct replacement. - the Base URL provider check removed → 1 failed / 15 passed: exactly "a preset provider uses its preset endpoint even when a Base URL is saved". - decimal text not read as a number → 1 failed / 15 passed: exactly the `'256'` case. - a value that is not a positive integer dropped instead of refused → 1 failed / 15 passed: exactly the `'large'` case. - the API key appended to the incomplete-settings refusal → 1 failed / 15 passed: exactly the key-not-logged case. ## Acceptance notes - **The clamp needed a surface widening, ruled by the seat** (comment 7156326561, option A): one read-only export from `embedder-openai`. With no saved model the embedder uses its own default model; no cap is looked up for a model the plugin does not name, so the saved size passes as saved. The field's maximum (2048) equals that default model's documented cap. - **Contract review owed**: Clause-② is yes, so the seat's direction asks for a same-head contract review at the tier these paths require, on top of L1. - **Declared beyond the named surface (mechanically forced):** `packages/services/service-knowledge/vitest.config.ts` gains one alias for `@objectstack/embedder-openai` (without it `check:test-source-alias` reds: the tests would read the embedder's `dist/`); `pnpm-lock.yaml` records the new workspace edge. - **Search reports, it does not throw.** `KnowledgeService.search` already catches a per-source adapter failure, logs it at `error` and answers no hits from that source; with no embedder that logged error is the named reason. Indexing throws it. That catch lives in `knowledge-service.ts`, outside this card. - **No open-edition adapter consumes `EMBEDDER_SERVICE` yet** (`knowledge-memory` uses its own sparse vectors; `knowledge-ragflow` embeds server-side), so in the open edition today the registered embedder is used by custom adapters and by the coming pgvector adapter. The `EMBEDDER_SERVICE` doc comment in `packages/spec/src/contracts/embedder.ts` still says it is "Registered by `@objectstack/service-ai`"; spec prose was not touched here. - An unknown model with no saved batch size still gets the embedder's own fallback of 10 and its one construction warning, unchanged. ## Verification Two-minute check: `pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/knowledge-settings-contribution.test.ts -t 37094` → 16 passed. Read first, by risk: 1. `knowledge-service-plugin.ts` `provideEmbedder()` and `embedderFromSettings()`: the phase, the registered check, the saved-vs-default reading, the clamp. 2. `UnconfiguredEmbedder`: a registered placeholder means `EMBEDDER_SERVICE` is never absent once the knowledge service is mounted. 3. `embedder-openai/src/index.ts` `documentedMaxBatchSize` and the constructor's use of it. Local readings, head `fa818f4d` (service-settings and the dispatch-gates run at `f329965b`; the later commits touch neither service-settings nor the derived gate set): <details><summary>Package tests, typecheck, derived gates</summary> - `pnpm --filter @objectstack/embedder-openai test` → 31/31; build + `typecheck` (tsc + `check:test-typecheck`) exit 0. - `pnpm --filter @objectstack/service-knowledge test` → Test Files 8/8, Tests 186/186; `typecheck` exit 0, 0 errors. - `pnpm --filter @objectstack/service-settings test` → Test Files 77/77, Tests 1523/1523; `typecheck` exit 0 (head `35c742d2`; the later commits do not touch service-settings). - Dependency closure built with declarations first. - `node scripts/pm/dispatch-gates.mjs --commands` (21 paths): 115 commands, each exit captured before any pipe: 114 exit 0, among them `check:startup-registry-verdict`, `check:test-source-alias`, `check:undeclared-dep-imports`, `check:workspace-manifest-cycles`, `check:published-readme-links`, `check:dual-build-cjs-loads`, `check:settings-bind-window`, `check:doc-authoring`, `check:issue-citations`, `check:nul-bytes`, `check:changeset-fixed`, `check-empty-changeset`, `check-changeset-no-major`, `check-adr-0087-registration`, `check:type-check-coverage`. - 1 exit 3, PREREQUISITE NOT MET, so NOT MEASURED here (CI runs it): `check-plugin-teardown-shape --self-test` (shallow clone cannot read its pinned fixture). - `dispatch-gates --ran`: 115 derived, 115 run, 0 unrun. - Repo-wide scans (`pnpm lint`) and dogfood are CI's (no `!` in the title, no narrowing arm). </details> Signed: repo:objectstack#4 · os-justin · session_01QSeKYofJfCPWsxaVYkmaVF ## Provenance Opened by seat repo:objectstack#4 on the maintainer's authorization in the seat session (「#37094 开 PR 被拦:放行」). The developer's own `pr_create` in zone a4-K's dev session was refused twice by a permission check; the dev stopped without retrying and handed the material over. Branch `claude/issue-37094-open-embedder-settings` @ `fa818f4d40749e28de09bbd747e9ca3c829f17ed`. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (spec untouched) - [x] 2. Every name I added uses the casing for its kind. - [ ] 3. No formatter ran; `pnpm lint` passes. (No formatter ran; `pnpm lint` was not run locally — CI's run decides.) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the 维护者速读 block is the fleet's required Chinese summary). - [ ] The *Before Submitting* list in CONTRIBUTING.md is done. (Not walked item by item; the local readings above are what ran.) --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 02520ab commit b8c8c88

21 files changed

Lines changed: 837 additions & 5 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/service-knowledge': patch
3+
'@objectstack/service-settings': patch
4+
'@objectstack/embedder-openai': patch
5+
---
6+
7+
feat(service-knowledge): the open edition registers `EMBEDDER_SERVICE` from the `ai.embedder_*` settings when the knowledge service is mounted
8+
9+
Clause-②: yes (widening) — `@objectstack/embedder-openai` gains one export, `documentedMaxBatchSize(model): number | undefined`
10+
Metadata-protocol: none
11+
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`.
13+
- **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.
14+
- **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.
15+
- **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.
16+
- **A saved change waits for a restart, and the page says so** — help under the Embedder provider field (`@objectstack/service-settings`, all locales). There is no hot replacement.
17+
- **New export `documentedMaxBatchSize(model)` from `@objectstack/embedder-openai`**: the provider-documented per-request input cap for a model, read from the same known-model table `OpenAIEmbedder` batches by, or `undefined` for a model the table does not document. Read-only. `OpenAIEmbedder` is unchanged: an explicit `maxBatchSize` passed to it directly is still used as given, above the documented cap included.
18+
- If your own plugin registers `EMBEDDER_SERVICE` after `kernel:ready` (in `kernel:bootstrapped` or later, or after boot), move that registration into `init()`, `start()` or `kernel:ready`: the knowledge plugin has registered one by then, and a second registration of the name is refused.

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ installed ([Connect an MCP Client](/docs/ai/connect-mcp)).
104104
- **Inline event sync.** When records on indexed objects change, the kernel's `IRealtimeService` events drive `KnowledgeService.handleRecordUpsert/Delete` automatically. No cron, no queue (yet — Phase 2).
105105
- **Adapter swap, zero caller changes.** Move from `memory` to `ragflow` to a custom adapter without touching your `search` calls, the `search_knowledge` tool, or any agent prompt.
106106

107+
## Configuring the embedder from Settings
108+
109+
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:
110+
111+
- **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.
112+
- **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.
113+
- **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.
114+
- **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.
115+
- **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.
116+
117+
**A saved change takes effect after a restart** — the page says so under the provider field. There is no hot replacement.
118+
119+
An adapter that embeds resolves the service where it embeds, not at boot:
120+
121+
```ts
122+
const embedder = ctx.getService<IEmbedder>(EMBEDDER_SERVICE); // from @objectstack/spec/contracts
123+
const vectors = await embedder.embed(chunks.map((c) => c.content));
124+
```
125+
107126
## Splitting documents into passages
108127

109128
The knowledge service cuts each document into passages once, and every adapter that takes passages (`knowledge-memory` does) indexes the same ones. An object source chooses how with `split`:

‎packages/plugins/embedder-openai/src/__tests__/openai-embedder.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { describe, it, expect, vi } from 'vitest';
44
import {
55
OpenAIEmbedder,
66
createOpenAIEmbedder,
7+
documentedMaxBatchSize,
78
OPENAI_COMPATIBLE_PRESETS,
89
} from '../index';
910
import { estimateTokens } from '@objectstack/spec/shared';
@@ -207,6 +208,24 @@ describe('OpenAIEmbedder batching (per-request input cap)', () => {
207208
expect(out).toEqual(Array.from({ length: 7 }, (_, i) => [i]));
208209
});
209210

211+
it('documentedMaxBatchSize answers the cap the embedder batches by, and nothing for an unknown model', async () => {
212+
expect(documentedMaxBatchSize('text-embedding-v3')).toBe(10);
213+
expect(documentedMaxBatchSize('text-embedding-3-small')).toBe(2048);
214+
expect(documentedMaxBatchSize('my-gateway-model')).toBeUndefined();
215+
expect(documentedMaxBatchSize('constructor')).toBeUndefined();
216+
// The same table: with no maxBatchSize, the embedder batches at exactly that cap.
217+
const f = echoFetch();
218+
await new OpenAIEmbedder({ apiKey: 'k', model: 'text-embedding-v3', fetch: f as unknown as typeof fetch }).embed(inputs(12));
219+
expect(sentSizes(f)).toEqual([documentedMaxBatchSize('text-embedding-v3'), 2]);
220+
});
221+
222+
it('an explicit maxBatchSize above the documented cap is still used as given', async () => {
223+
const f = echoFetch();
224+
const e = new OpenAIEmbedder({ apiKey: 'k', model: 'text-embedding-v3', maxBatchSize: 25, fetch: f as unknown as typeof fetch });
225+
await e.embed(inputs(30));
226+
expect(sentSizes(f)).toEqual([25, 5]);
227+
});
228+
210229
it('refuses a maxBatchSize that is not a positive integer', () => {
211230
for (const bad of [0, -1, 1.5, Number.NaN]) {
212231
expect(() => new OpenAIEmbedder({ apiKey: 'k', maxBatchSize: bad })).toThrow(

‎packages/plugins/embedder-openai/src/index.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ const KNOWN_MAX_BATCH_SIZE: Record<string, number> = {
120120
*/
121121
const DEFAULT_MAX_BATCH_SIZE = 10;
122122

123+
/**
124+
* The provider-documented per-request input cap for `model`, read from the
125+
* known-model table `OpenAIEmbedder` batches by, or `undefined` when the table
126+
* documents none (the embedder then falls back to {@link DEFAULT_MAX_BATCH_SIZE}
127+
* with a warning).
128+
*
129+
* Read-only: a caller that takes a batch size from elsewhere — an operator's
130+
* saved setting — can hold it at or under the model's cap before passing it as
131+
* `maxBatchSize`. It changes nothing about `OpenAIEmbedder` itself: an explicit
132+
* `maxBatchSize` is still used as given, above the documented cap included.
133+
*/
134+
export function documentedMaxBatchSize(model: string): number | undefined {
135+
return Object.prototype.hasOwnProperty.call(KNOWN_MAX_BATCH_SIZE, model) ? KNOWN_MAX_BATCH_SIZE[model] : undefined;
136+
}
137+
123138
/**
124139
* Documented per-input token limits (the longest single text one
125140
* `/embeddings` input may be). A model listed here refuses an over-limit
@@ -263,15 +278,16 @@ export class OpenAIEmbedder implements IEmbedder {
263278
// Once per instance, in ONE warning: the configuration is what is
264279
// unknown, not any one call.
265280
const unknown: string[] = [];
281+
const documentedCap = documentedMaxBatchSize(this.model);
266282
if (opts.maxBatchSize !== undefined) {
267283
if (!Number.isInteger(opts.maxBatchSize) || opts.maxBatchSize < 1) {
268284
throw new Error(
269285
`OpenAIEmbedder: maxBatchSize must be a positive integer, got ${String(opts.maxBatchSize)}`,
270286
);
271287
}
272288
this.maxBatchSize = opts.maxBatchSize;
273-
} else if (KNOWN_MAX_BATCH_SIZE[this.model] !== undefined) {
274-
this.maxBatchSize = KNOWN_MAX_BATCH_SIZE[this.model];
289+
} else if (documentedCap !== undefined) {
290+
this.maxBatchSize = documentedCap;
275291
} else {
276292
this.maxBatchSize = DEFAULT_MAX_BATCH_SIZE;
277293
unknown.push(

‎packages/services/service-knowledge/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@objectstack/core": "workspace:*",
36+
"@objectstack/embedder-openai": "workspace:*",
3637
"@objectstack/service-settings": "workspace:*",
3738
"@objectstack/spec": "workspace:*"
3839
},

0 commit comments

Comments
 (0)