@ponraaj/dimple-sdk 0.0.0-alpha.11 → 0.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dimple.d.ts +10 -0
- package/dist/errors.js +245 -75
- package/dist/index.js +390 -138
- package/dist/internal/config/index.d.ts +2 -2
- package/dist/internal/config/schema.d.ts +116 -21
- package/dist/internal/embedder/index.d.ts +1 -1
- package/dist/internal/embedder/transformers.d.ts +65 -17
- package/dist/internal/store/topics/index.d.ts +2 -2
- package/dist/internal/store/topics/lifecycle.d.ts +25 -0
- package/dist/internal/workflow/index.d.ts +1 -1
- package/dist/internal/workflow/queue.d.ts +21 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DimpleConfig, EmbeddingModelConfig, EmbeddingConfig, IndexConfig, JobsConfig, TopicsConfig, } from "./schema.ts";
|
|
2
|
-
export type { DimpleConfig as DimpleConfigType, EmbeddingModelConfig as EmbeddingModelConfigType, EmbeddingConfig as EmbeddingConfigType, IndexConfig as IndexConfigType, JobsConfig as JobsConfigType, TopicsConfig as TopicsConfigType, } from "./schema.ts";
|
|
1
|
+
export { DimpleConfig, EmbeddingModelConfig, EmbeddingConfig, IndexConfig, JobsConfig, TopicsConfig, SessionOptions, mergeSessionOptions, } from "./schema.ts";
|
|
2
|
+
export type { DimpleConfig as DimpleConfigType, EmbeddingModelConfig as EmbeddingModelConfigType, EmbeddingConfig as EmbeddingConfigType, IndexConfig as IndexConfigType, JobsConfig as JobsConfigType, TopicsConfig as TopicsConfigType, SessionOptions as SessionOptionsType, } from "./schema.ts";
|
|
3
3
|
export { Service, layer, configured as configConfigured, node as configNode } from "./service.ts";
|
|
4
4
|
export { loadConfig, loadConfigFromFile } from "./loader.ts";
|
|
@@ -6,6 +6,30 @@ export declare const IndexConfig: Schema.Struct<{
|
|
|
6
6
|
}>;
|
|
7
7
|
export interface IndexConfig extends Schema.Schema.Type<typeof IndexConfig> {
|
|
8
8
|
}
|
|
9
|
+
/** ONNX Runtime session options — one shared shape for the global default
|
|
10
|
+
* (`embedding.sessionOptions`) and the per-model override, so parallel
|
|
11
|
+
* ingest workers can split cores between processes. The CUDA keys stay flat
|
|
12
|
+
* (not nested under an EP name) for backward compatibility with the
|
|
13
|
+
* existing single-purpose configs. */
|
|
14
|
+
export declare const SessionOptions: Schema.Struct<{
|
|
15
|
+
readonly intraOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
16
|
+
readonly interOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
17
|
+
readonly executionMode: Schema.optional<Schema.Literals<readonly ["sequential", "parallel"]>>;
|
|
18
|
+
readonly graphOptimizationLevel: Schema.optional<Schema.Literals<readonly ["disabled", "basic", "extended", "all", "layout"]>>;
|
|
19
|
+
readonly enableCpuMemArena: Schema.optional<Schema.Boolean>;
|
|
20
|
+
readonly enableMemPattern: Schema.optional<Schema.Boolean>;
|
|
21
|
+
readonly gpuMemLimit: Schema.optional<Schema.Number>;
|
|
22
|
+
readonly arenaExtendStrategy: Schema.optional<Schema.Literals<readonly [0, 1]>>;
|
|
23
|
+
}>;
|
|
24
|
+
export interface SessionOptions extends Schema.Schema.Type<typeof SessionOptions> {
|
|
25
|
+
}
|
|
26
|
+
/** Precedence: built-in defaults → `embedding.sessionOptions` → the model
|
|
27
|
+
* block, merged FIELD BY FIELD, so a model can override one key while
|
|
28
|
+
* inheriting the rest. `??` only falls through on an ABSENT field, which
|
|
29
|
+
* keeps `false`/`0` model values overriding a global `true`/non-zero.
|
|
30
|
+
* `undefined` when both sides are absent — the embedder then forwards no
|
|
31
|
+
* session options at all. */
|
|
32
|
+
export declare const mergeSessionOptions: (global: SessionOptions | undefined, model: SessionOptions | undefined) => SessionOptions | undefined;
|
|
9
33
|
export declare const EmbeddingModelConfig: Schema.Struct<{
|
|
10
34
|
readonly id: Schema.String;
|
|
11
35
|
readonly provider: Schema.String;
|
|
@@ -30,17 +54,32 @@ export declare const EmbeddingModelConfig: Schema.Struct<{
|
|
|
30
54
|
readonly pooling: Schema.optional<Schema.Literals<readonly ["mean", "cls", "none"]>>;
|
|
31
55
|
readonly normalize: Schema.optional<Schema.Boolean>;
|
|
32
56
|
readonly cacheDir: Schema.optional<Schema.String>;
|
|
33
|
-
/** ONNX Runtime
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
57
|
+
/** ONNX Runtime session options — `intraOpNumThreads` /
|
|
58
|
+
* `interOpNumThreads` (0 = runtime default, else the per-session thread
|
|
59
|
+
* count), `executionMode`, `graphOptimizationLevel`,
|
|
60
|
+
* `enableCpuMemArena`, `enableMemPattern`, plus the CUDA pair: the
|
|
61
|
+
* verified fix for GPUs with limited VRAM (≤8GB), where ORT's default
|
|
62
|
+
* arena is unbounded and grows by powers of two, so batch inference OOMs
|
|
63
|
+
* mid-run and poisons the process for later queries. `gpuMemLimit` caps
|
|
64
|
+
* the arena (bytes); `arenaExtendStrategy` picks the growth policy
|
|
65
|
+
* (0 = kNextPowerOfTwo, 1 = kSameAsRequested). CPU / ample-VRAM GPUs are
|
|
66
|
+
* unaffected (ORT defaults preserved when absent). Merged over
|
|
67
|
+
* `embedding.sessionOptions` field by field. */
|
|
40
68
|
readonly sessionOptions: Schema.optional<Schema.Struct<{
|
|
69
|
+
readonly intraOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
70
|
+
readonly interOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
71
|
+
readonly executionMode: Schema.optional<Schema.Literals<readonly ["sequential", "parallel"]>>;
|
|
72
|
+
readonly graphOptimizationLevel: Schema.optional<Schema.Literals<readonly ["disabled", "basic", "extended", "all", "layout"]>>;
|
|
73
|
+
readonly enableCpuMemArena: Schema.optional<Schema.Boolean>;
|
|
74
|
+
readonly enableMemPattern: Schema.optional<Schema.Boolean>;
|
|
41
75
|
readonly gpuMemLimit: Schema.optional<Schema.Number>;
|
|
42
76
|
readonly arenaExtendStrategy: Schema.optional<Schema.Literals<readonly [0, 1]>>;
|
|
43
77
|
}>>;
|
|
78
|
+
/** ONNX Runtime WASM backend — its own thread knob, which intra-op
|
|
79
|
+
* threads do NOT reach. */
|
|
80
|
+
readonly wasm: Schema.optional<Schema.Struct<{
|
|
81
|
+
readonly numThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
82
|
+
}>>;
|
|
44
83
|
/** First-use auto-install of the optional `@huggingface/transformers`
|
|
45
84
|
* peer (default true) — the package is installed with the project's
|
|
46
85
|
* own package manager on the first local-embed use (scripts skipped,
|
|
@@ -52,6 +91,19 @@ export interface EmbeddingModelConfig extends Schema.Schema.Type<typeof Embeddin
|
|
|
52
91
|
}
|
|
53
92
|
export declare const EmbeddingConfig: Schema.Struct<{
|
|
54
93
|
readonly defaultModel: Schema.String;
|
|
94
|
+
/** Session options every model inherits unless its own block overrides a
|
|
95
|
+
* field — the single knob for splitting cores across parallel ingest
|
|
96
|
+
* workers. */
|
|
97
|
+
readonly sessionOptions: Schema.optional<Schema.Struct<{
|
|
98
|
+
readonly intraOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
99
|
+
readonly interOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
100
|
+
readonly executionMode: Schema.optional<Schema.Literals<readonly ["sequential", "parallel"]>>;
|
|
101
|
+
readonly graphOptimizationLevel: Schema.optional<Schema.Literals<readonly ["disabled", "basic", "extended", "all", "layout"]>>;
|
|
102
|
+
readonly enableCpuMemArena: Schema.optional<Schema.Boolean>;
|
|
103
|
+
readonly enableMemPattern: Schema.optional<Schema.Boolean>;
|
|
104
|
+
readonly gpuMemLimit: Schema.optional<Schema.Number>;
|
|
105
|
+
readonly arenaExtendStrategy: Schema.optional<Schema.Literals<readonly [0, 1]>>;
|
|
106
|
+
}>>;
|
|
55
107
|
readonly models: Schema.$Array<Schema.Struct<{
|
|
56
108
|
readonly id: Schema.String;
|
|
57
109
|
readonly provider: Schema.String;
|
|
@@ -76,17 +128,32 @@ export declare const EmbeddingConfig: Schema.Struct<{
|
|
|
76
128
|
readonly pooling: Schema.optional<Schema.Literals<readonly ["mean", "cls", "none"]>>;
|
|
77
129
|
readonly normalize: Schema.optional<Schema.Boolean>;
|
|
78
130
|
readonly cacheDir: Schema.optional<Schema.String>;
|
|
79
|
-
/** ONNX Runtime
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
131
|
+
/** ONNX Runtime session options — `intraOpNumThreads` /
|
|
132
|
+
* `interOpNumThreads` (0 = runtime default, else the per-session thread
|
|
133
|
+
* count), `executionMode`, `graphOptimizationLevel`,
|
|
134
|
+
* `enableCpuMemArena`, `enableMemPattern`, plus the CUDA pair: the
|
|
135
|
+
* verified fix for GPUs with limited VRAM (≤8GB), where ORT's default
|
|
136
|
+
* arena is unbounded and grows by powers of two, so batch inference OOMs
|
|
137
|
+
* mid-run and poisons the process for later queries. `gpuMemLimit` caps
|
|
138
|
+
* the arena (bytes); `arenaExtendStrategy` picks the growth policy
|
|
139
|
+
* (0 = kNextPowerOfTwo, 1 = kSameAsRequested). CPU / ample-VRAM GPUs are
|
|
140
|
+
* unaffected (ORT defaults preserved when absent). Merged over
|
|
141
|
+
* `embedding.sessionOptions` field by field. */
|
|
86
142
|
readonly sessionOptions: Schema.optional<Schema.Struct<{
|
|
143
|
+
readonly intraOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
144
|
+
readonly interOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
145
|
+
readonly executionMode: Schema.optional<Schema.Literals<readonly ["sequential", "parallel"]>>;
|
|
146
|
+
readonly graphOptimizationLevel: Schema.optional<Schema.Literals<readonly ["disabled", "basic", "extended", "all", "layout"]>>;
|
|
147
|
+
readonly enableCpuMemArena: Schema.optional<Schema.Boolean>;
|
|
148
|
+
readonly enableMemPattern: Schema.optional<Schema.Boolean>;
|
|
87
149
|
readonly gpuMemLimit: Schema.optional<Schema.Number>;
|
|
88
150
|
readonly arenaExtendStrategy: Schema.optional<Schema.Literals<readonly [0, 1]>>;
|
|
89
151
|
}>>;
|
|
152
|
+
/** ONNX Runtime WASM backend — its own thread knob, which intra-op
|
|
153
|
+
* threads do NOT reach. */
|
|
154
|
+
readonly wasm: Schema.optional<Schema.Struct<{
|
|
155
|
+
readonly numThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
156
|
+
}>>;
|
|
90
157
|
/** First-use auto-install of the optional `@huggingface/transformers`
|
|
91
158
|
* peer (default true) — the package is installed with the project's
|
|
92
159
|
* own package manager on the first local-embed use (scripts skipped,
|
|
@@ -161,6 +228,19 @@ export declare const DimpleConfig: Schema.Struct<{
|
|
|
161
228
|
readonly storeUrl: Schema.String;
|
|
162
229
|
readonly embedding: Schema.optional<Schema.Struct<{
|
|
163
230
|
readonly defaultModel: Schema.String;
|
|
231
|
+
/** Session options every model inherits unless its own block overrides a
|
|
232
|
+
* field — the single knob for splitting cores across parallel ingest
|
|
233
|
+
* workers. */
|
|
234
|
+
readonly sessionOptions: Schema.optional<Schema.Struct<{
|
|
235
|
+
readonly intraOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
236
|
+
readonly interOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
237
|
+
readonly executionMode: Schema.optional<Schema.Literals<readonly ["sequential", "parallel"]>>;
|
|
238
|
+
readonly graphOptimizationLevel: Schema.optional<Schema.Literals<readonly ["disabled", "basic", "extended", "all", "layout"]>>;
|
|
239
|
+
readonly enableCpuMemArena: Schema.optional<Schema.Boolean>;
|
|
240
|
+
readonly enableMemPattern: Schema.optional<Schema.Boolean>;
|
|
241
|
+
readonly gpuMemLimit: Schema.optional<Schema.Number>;
|
|
242
|
+
readonly arenaExtendStrategy: Schema.optional<Schema.Literals<readonly [0, 1]>>;
|
|
243
|
+
}>>;
|
|
164
244
|
readonly models: Schema.$Array<Schema.Struct<{
|
|
165
245
|
readonly id: Schema.String;
|
|
166
246
|
readonly provider: Schema.String;
|
|
@@ -185,17 +265,32 @@ export declare const DimpleConfig: Schema.Struct<{
|
|
|
185
265
|
readonly pooling: Schema.optional<Schema.Literals<readonly ["mean", "cls", "none"]>>;
|
|
186
266
|
readonly normalize: Schema.optional<Schema.Boolean>;
|
|
187
267
|
readonly cacheDir: Schema.optional<Schema.String>;
|
|
188
|
-
/** ONNX Runtime
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
268
|
+
/** ONNX Runtime session options — `intraOpNumThreads` /
|
|
269
|
+
* `interOpNumThreads` (0 = runtime default, else the per-session thread
|
|
270
|
+
* count), `executionMode`, `graphOptimizationLevel`,
|
|
271
|
+
* `enableCpuMemArena`, `enableMemPattern`, plus the CUDA pair: the
|
|
272
|
+
* verified fix for GPUs with limited VRAM (≤8GB), where ORT's default
|
|
273
|
+
* arena is unbounded and grows by powers of two, so batch inference OOMs
|
|
274
|
+
* mid-run and poisons the process for later queries. `gpuMemLimit` caps
|
|
275
|
+
* the arena (bytes); `arenaExtendStrategy` picks the growth policy
|
|
276
|
+
* (0 = kNextPowerOfTwo, 1 = kSameAsRequested). CPU / ample-VRAM GPUs are
|
|
277
|
+
* unaffected (ORT defaults preserved when absent). Merged over
|
|
278
|
+
* `embedding.sessionOptions` field by field. */
|
|
195
279
|
readonly sessionOptions: Schema.optional<Schema.Struct<{
|
|
280
|
+
readonly intraOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
281
|
+
readonly interOpNumThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
282
|
+
readonly executionMode: Schema.optional<Schema.Literals<readonly ["sequential", "parallel"]>>;
|
|
283
|
+
readonly graphOptimizationLevel: Schema.optional<Schema.Literals<readonly ["disabled", "basic", "extended", "all", "layout"]>>;
|
|
284
|
+
readonly enableCpuMemArena: Schema.optional<Schema.Boolean>;
|
|
285
|
+
readonly enableMemPattern: Schema.optional<Schema.Boolean>;
|
|
196
286
|
readonly gpuMemLimit: Schema.optional<Schema.Number>;
|
|
197
287
|
readonly arenaExtendStrategy: Schema.optional<Schema.Literals<readonly [0, 1]>>;
|
|
198
288
|
}>>;
|
|
289
|
+
/** ONNX Runtime WASM backend — its own thread knob, which intra-op
|
|
290
|
+
* threads do NOT reach. */
|
|
291
|
+
readonly wasm: Schema.optional<Schema.Struct<{
|
|
292
|
+
readonly numThreads: Schema.optional<Schema.refine<number, Schema.Number>>;
|
|
293
|
+
}>>;
|
|
199
294
|
/** First-use auto-install of the optional `@huggingface/transformers`
|
|
200
295
|
* peer (default true) — the package is installed with the project's
|
|
201
296
|
* own package manager on the first local-embed use (scripts skipped,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Service as EmbeddingModelRegistry, type Interface as EmbeddingModelRegistryInterface, type EmbeddingModel, EmbeddingError, } from "./provider.ts";
|
|
2
|
-
export { layer as transformersEmbeddingLayer, layerConfig as transformersEmbeddingLayerConfig, makeTransformersModel, buildSessionOptions, } from "./transformers.ts";
|
|
2
|
+
export { layer as transformersEmbeddingLayer, layerConfig as transformersEmbeddingLayerConfig, makeTransformersModel, buildSessionOptions, applyWasmOptions, type SessionOptions, type TransformersEnv, type WasmOptions, } from "./transformers.ts";
|
|
3
3
|
export { layer as registryLayer, configured as registryConfigured, type ModelSpec, } from "./registry.ts";
|
|
@@ -1,13 +1,43 @@
|
|
|
1
1
|
import { Config, Layer } from "effect";
|
|
2
2
|
import { Service, type EmbeddingModel } from "./provider.ts";
|
|
3
|
+
/** Mirror of transformers.js's `env` — `backends.onnx` is a shallow copy of
|
|
4
|
+
* ORT's env object, so `.wasm` is the LIVE nested object the runtime reads
|
|
5
|
+
* at session creation (hence assignable before the pipeline is built). */
|
|
6
|
+
export interface TransformersEnv {
|
|
7
|
+
cacheDir?: string;
|
|
8
|
+
backends: {
|
|
9
|
+
onnx: {
|
|
10
|
+
wasm: OrtWasmEnvFlags;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** The ORT wasm env knobs dimple sets — `numThreads` is the wasm backend's
|
|
15
|
+
* own thread count (0 = system-determined, 1 = no worker threads), read
|
|
16
|
+
* when the session is created. */
|
|
17
|
+
export interface OrtWasmEnvFlags {
|
|
18
|
+
numThreads?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Per-model wasm backend options. */
|
|
21
|
+
export interface WasmOptions {
|
|
22
|
+
readonly numThreads?: number | undefined;
|
|
23
|
+
}
|
|
3
24
|
/** Mirror of transformers.js's `DeviceType` (the config schema carries the
|
|
4
25
|
* same literals) — kept local so the optional peer's types never appear
|
|
5
26
|
* in this module's surface. */
|
|
6
27
|
type DeviceType = "auto" | "gpu" | "cpu" | "wasm" | "webgpu" | "cuda" | "dml" | "coreml" | "webnn";
|
|
7
28
|
/** The ORT session-options shape transformers.js forwards to
|
|
8
|
-
* onnxruntime-node (
|
|
29
|
+
* onnxruntime-node/web unchanged (ORT reads camelCase JS keys out of the
|
|
30
|
+
* snake_case `session_options` bag). Thread counts and the arena/pattern
|
|
31
|
+
* switches are what let parallel dimple processes split cores instead of
|
|
32
|
+
* each taking one thread per physical core. */
|
|
9
33
|
interface OrtSessionOptions {
|
|
10
|
-
readonly
|
|
34
|
+
readonly enableCpuMemArena?: boolean;
|
|
35
|
+
readonly intraOpNumThreads?: number;
|
|
36
|
+
readonly interOpNumThreads?: number;
|
|
37
|
+
readonly executionMode?: "sequential" | "parallel";
|
|
38
|
+
readonly graphOptimizationLevel?: "disabled" | "basic" | "extended" | "all" | "layout";
|
|
39
|
+
readonly enableMemPattern?: boolean;
|
|
40
|
+
readonly executionProviders?: readonly [
|
|
11
41
|
{
|
|
12
42
|
readonly name: string;
|
|
13
43
|
readonly device_id: number;
|
|
@@ -16,13 +46,30 @@ interface OrtSessionOptions {
|
|
|
16
46
|
}
|
|
17
47
|
];
|
|
18
48
|
}
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
export
|
|
49
|
+
/** ONNX Runtime session options — a structural mirror of `@dimple/config`'s
|
|
50
|
+
* `SessionOptions` (the embedder does not depend on config; the config
|
|
51
|
+
* schema carries the same field names). */
|
|
52
|
+
export interface SessionOptions {
|
|
53
|
+
readonly intraOpNumThreads?: number | undefined;
|
|
54
|
+
readonly interOpNumThreads?: number | undefined;
|
|
55
|
+
readonly executionMode?: "sequential" | "parallel" | undefined;
|
|
56
|
+
readonly graphOptimizationLevel?: "disabled" | "basic" | "extended" | "all" | "layout" | undefined;
|
|
57
|
+
readonly enableCpuMemArena?: boolean | undefined;
|
|
58
|
+
readonly enableMemPattern?: boolean | undefined;
|
|
23
59
|
readonly gpuMemLimit?: number | undefined;
|
|
24
60
|
readonly arenaExtendStrategy?: 0 | 1 | undefined;
|
|
25
|
-
}
|
|
61
|
+
}
|
|
62
|
+
/** Map the dimple-level session options to ORT's session keys. Absent
|
|
63
|
+
* fields are omitted, so ORT keeps its own default; `enableCpuMemArena`
|
|
64
|
+
* always lands because it has a dimple default (bulk ingest does not need
|
|
65
|
+
* the arena). The CUDA execution provider is emitted ONLY when a CUDA key
|
|
66
|
+
* is present — injecting it unconditionally would pin every CPU-only model
|
|
67
|
+
* to a CUDA EP the runtime may not have. */
|
|
68
|
+
export declare const buildSessionOptions: (opts: SessionOptions) => OrtSessionOptions;
|
|
69
|
+
/** Map the wasm block onto transformers' ORT env, BEFORE the session is
|
|
70
|
+
* created — the wasm backend reads `numThreads` from its env, not from the
|
|
71
|
+
* session options, so `intraOpNumThreads` does not reach it. */
|
|
72
|
+
export declare const applyWasmOptions: (env: TransformersEnv, wasm: WasmOptions | undefined) => void;
|
|
26
73
|
interface TransformersOptions {
|
|
27
74
|
readonly modelId?: string;
|
|
28
75
|
readonly device?: DeviceType;
|
|
@@ -30,16 +77,17 @@ interface TransformersOptions {
|
|
|
30
77
|
readonly pooling?: "mean" | "cls" | "none";
|
|
31
78
|
readonly normalize?: boolean;
|
|
32
79
|
readonly cacheDir?: string;
|
|
33
|
-
/** ONNX Runtime
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
80
|
+
/** ONNX Runtime session options — thread counts, arena/pattern switches,
|
|
81
|
+
* execution mode, graph optimization, and the CUDA pair (the verified fix
|
|
82
|
+
* for GPUs with limited VRAM (≤8GB): ORT's default arena is unbounded
|
|
83
|
+
* (grows by powers of two), so batch inference OOMs mid-run and leaves
|
|
84
|
+
* the process unable to allocate even a cublas handle afterwards).
|
|
85
|
+
* Forwarded to the pipeline's `session_options`; absent fields keep ORT's
|
|
86
|
+
* own defaults. */
|
|
87
|
+
readonly sessionOptions?: SessionOptions;
|
|
88
|
+
/** ONNX Runtime WASM backend options — applied to the ORT env before the
|
|
89
|
+
* session is created. */
|
|
90
|
+
readonly wasm?: WasmOptions;
|
|
43
91
|
/** Declared output dimension — validated against the model's actual
|
|
44
92
|
* output on first embed (a mismatch fails typed, precisely). */
|
|
45
93
|
readonly dimensions?: number;
|
|
@@ -12,8 +12,8 @@ export * from "./tree.ts";
|
|
|
12
12
|
export * from "./routing.ts";
|
|
13
13
|
export * from "./query.ts";
|
|
14
14
|
export * from "./lifecycle.ts";
|
|
15
|
-
export { memoryEmbedHandler } from "./lifecycle.ts";
|
|
16
|
-
export type { MemoryEmbedHandler, MemoryEmbedHandlerDeps } from "./lifecycle.ts";
|
|
15
|
+
export { memoryEmbedHandler, memoryEmbedBatchHandler } from "./lifecycle.ts";
|
|
16
|
+
export type { MemoryEmbedHandler, MemoryEmbedHandlerDeps, MemoryEmbedBatchHandler, MemoryEmbedBatchPayload, } from "./lifecycle.ts";
|
|
17
17
|
export * from "./errors.ts";
|
|
18
18
|
export { splitTopic, topicSplitHandler, shouldSplit } from "./jobs.ts";
|
|
19
19
|
export type { SplitOutcome, TopicSplitHandler, TopicSplitHandlerDeps } from "./jobs.ts";
|
|
@@ -120,6 +120,16 @@ export interface MemoryEmbedPayload {
|
|
|
120
120
|
}
|
|
121
121
|
/** The `memory.embed` handler shape (see jobs.ts). */
|
|
122
122
|
export type MemoryEmbedHandler = (payload: MemoryEmbedPayload, ctx: JobContext) => Effect.Effect<unknown, JobFailure, DbBackend>;
|
|
123
|
+
/** The decoded `memory.embed.batch` payload — mirrors the queue
|
|
124
|
+
* definition's schema; `nonce` only keeps distinct enqueues distinct. */
|
|
125
|
+
export interface MemoryEmbedBatchPayload {
|
|
126
|
+
readonly memoryIds: readonly string[];
|
|
127
|
+
readonly modelKey: string;
|
|
128
|
+
readonly nonce: string;
|
|
129
|
+
}
|
|
130
|
+
/** The `memory.embed.batch` handler shape — the same deps as the per-memory
|
|
131
|
+
* handler; ids are embedded one at a time, in payload order. */
|
|
132
|
+
export type MemoryEmbedBatchHandler = (payload: MemoryEmbedBatchPayload, ctx: JobContext) => Effect.Effect<unknown, JobFailure, DbBackend>;
|
|
123
133
|
/**
|
|
124
134
|
* Factory for the `memory.embed` job handler: re-embeds one memory with the
|
|
125
135
|
* target model and routes it into that model's tree. The success schema is
|
|
@@ -130,3 +140,18 @@ export declare function memoryEmbedHandler(deps: MemoryEmbedHandlerDeps & {
|
|
|
130
140
|
readonly backend: DbBackendInterface;
|
|
131
141
|
}): Handler;
|
|
132
142
|
export declare function memoryEmbedHandler(deps: MemoryEmbedHandlerDeps): MemoryEmbedHandler;
|
|
143
|
+
/**
|
|
144
|
+
* Factory for the `memory.embed.batch` job handler: the same outcome as the
|
|
145
|
+
* per-memory job for a whole list of ids, with the STORE phase batched —
|
|
146
|
+
* one tree seed, one vector-table seed, one membership SELECT, one vector
|
|
147
|
+
* insert, one routing pass, one embedding-column UPDATE for the whole batch
|
|
148
|
+
* (per-id repeats of those dominated a 235-unit drain). The EMBED step stays
|
|
149
|
+
* per id (one model forward pass per text). A stale id (memory gone) is a
|
|
150
|
+
* success no-op, exactly like the per-memory job's; a real failure fails the
|
|
151
|
+
* ONE job, naming how many ids failed and the first failure — ids that did
|
|
152
|
+
* succeed stay committed, and a redelivery re-runs them idempotently.
|
|
153
|
+
*/
|
|
154
|
+
export declare function memoryEmbedBatchHandler(deps: MemoryEmbedHandlerDeps & {
|
|
155
|
+
readonly backend: DbBackendInterface;
|
|
156
|
+
}): Handler;
|
|
157
|
+
export declare function memoryEmbedBatchHandler(deps: MemoryEmbedHandlerDeps): MemoryEmbedBatchHandler;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Barrel: named exports with aliases (project convention).
|
|
5
5
|
*/
|
|
6
|
-
export { JobDefinition, Envelope, TopicSplit, MemoryEmbed, TopicMerge, TopicRebalance, ConceptCluster, MemoryDream, GraphRepair, AuditWrite, type AuditRow, queues, type EnvelopeSchema, } from "./queue.ts";
|
|
6
|
+
export { JobDefinition, Envelope, TopicSplit, MemoryEmbed, MemoryEmbedBatch, TopicMerge, TopicRebalance, ConceptCluster, MemoryDream, GraphRepair, AuditWrite, type AuditRow, queues, type EnvelopeSchema, } from "./queue.ts";
|
|
7
7
|
export { Service as JobRuntime, layer as jobRuntimeLayer, configured as jobRuntimeConfigured, node as jobRuntimeNode, type Interface as JobRuntimeInterface, type JobStatus, } from "./runtime.ts";
|
|
8
8
|
export { layerDurable, layerDurableLibsql, libsqlStackConfigured, layerDurableLibsqlConfigured, } from "./engine.ts";
|
|
9
9
|
export { Service as JobRegistry, layer as jobRegistryLayer, configured as jobRegistryConfigured, node as jobRegistryNode, JobFailure, type Handler, type JobContext, } from "./registry.ts";
|
|
@@ -173,6 +173,23 @@ export declare const MemoryEmbed: JobDefinition<Schema.Struct<{
|
|
|
173
173
|
memoryId: Schema.String;
|
|
174
174
|
modelKey: Schema.String;
|
|
175
175
|
}>, Schema.Void, Schema.String>;
|
|
176
|
+
/**
|
|
177
|
+
* Batch embedding backfill job — `memory.embed.batch`. Same work as
|
|
178
|
+
* `memory.embed`, one job for many memories: the bulk ingest path
|
|
179
|
+
* (`Dimple.index` with `deferEmbed`) would otherwise enqueue and drain one
|
|
180
|
+
* job per unit while the walk is still running.
|
|
181
|
+
*
|
|
182
|
+
* `nonce` keeps distinct enqueues distinct (the key function stays
|
|
183
|
+
* deterministic over the payload, so it can never collapse two different
|
|
184
|
+
* batches into one execution id); the handler is idempotent PER MEMORY, so a
|
|
185
|
+
* redelivered or overlapping batch re-embeds an already-embedded unit for
|
|
186
|
+
* nothing rather than corrupting it.
|
|
187
|
+
*/
|
|
188
|
+
export declare const MemoryEmbedBatch: JobDefinition<Schema.Struct<{
|
|
189
|
+
memoryIds: Schema.$Array<Schema.String>;
|
|
190
|
+
modelKey: Schema.String;
|
|
191
|
+
nonce: Schema.String;
|
|
192
|
+
}>, Schema.Void, Schema.String>;
|
|
176
193
|
/** Underflow maintenance job — `topic.merge` (borrow-then-merge). */
|
|
177
194
|
export declare const TopicMerge: JobDefinition<Schema.Struct<{
|
|
178
195
|
topicId: Schema.String;
|
|
@@ -270,6 +287,10 @@ export declare const queues: readonly [JobDefinition<Schema.Struct<{
|
|
|
270
287
|
}>, Schema.Void, Schema.String>, JobDefinition<Schema.Struct<{
|
|
271
288
|
memoryId: Schema.String;
|
|
272
289
|
modelKey: Schema.String;
|
|
290
|
+
}>, Schema.Void, Schema.String>, JobDefinition<Schema.Struct<{
|
|
291
|
+
memoryIds: Schema.$Array<Schema.String>;
|
|
292
|
+
modelKey: Schema.String;
|
|
293
|
+
nonce: Schema.String;
|
|
273
294
|
}>, Schema.Void, Schema.String>, JobDefinition<Schema.Struct<{
|
|
274
295
|
topicId: Schema.String;
|
|
275
296
|
modelKey: Schema.String;
|
package/package.json
CHANGED