@ponraaj/dimple-sdk 0.0.0-alpha.11 → 0.0.0-alpha.12
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 +171 -59
- package/dist/index.js +316 -122
- package/dist/internal/embedder/transformers.d.ts +6 -2
- 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
|
@@ -7,7 +7,11 @@ type DeviceType = "auto" | "gpu" | "cpu" | "wasm" | "webgpu" | "cuda" | "dml" |
|
|
|
7
7
|
/** The ORT session-options shape transformers.js forwards to
|
|
8
8
|
* onnxruntime-node (executionProviders with a bounded CUDA arena). */
|
|
9
9
|
interface OrtSessionOptions {
|
|
10
|
-
|
|
10
|
+
/** ORT JS session options are camelCase; transformers.js reads them from
|
|
11
|
+
* a snake_case `session_options` bag. The CPU arena pre-allocates and
|
|
12
|
+
* holds memory across runs (onnxruntime#11627). */
|
|
13
|
+
readonly enableCpuMemArena?: boolean;
|
|
14
|
+
readonly executionProviders?: readonly [
|
|
11
15
|
{
|
|
12
16
|
readonly name: string;
|
|
13
17
|
readonly device_id: number;
|
|
@@ -34,7 +38,7 @@ interface TransformersOptions {
|
|
|
34
38
|
* limited VRAM (≤8GB): ORT's default arena is unbounded (grows by
|
|
35
39
|
* powers of two), so batch inference OOMs mid-run and leaves the
|
|
36
40
|
* process unable to allocate even a cublas handle afterwards. Forwarded
|
|
37
|
-
* to the pipeline's
|
|
41
|
+
* to the pipeline's `session_options`; absent = ORT defaults (CPU and
|
|
38
42
|
* ample-VRAM GPUs unaffected). */
|
|
39
43
|
readonly sessionOptions?: {
|
|
40
44
|
readonly gpuMemLimit?: number | undefined;
|
|
@@ -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