@workglow/ai 0.2.29 → 0.2.31
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/README.md +22 -14
- package/dist/browser.js +46 -26
- package/dist/browser.js.map +7 -7
- package/dist/bun.js +46 -26
- package/dist/bun.js.map +7 -7
- package/dist/model/ModelRegistry.d.ts +14 -6
- package/dist/model/ModelRegistry.d.ts.map +1 -1
- package/dist/node.js +46 -26
- package/dist/node.js.map +7 -7
- package/dist/provider/AiProviderRegistry.d.ts +21 -3
- package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
- package/dist/task/ChunkVectorUpsertTask.d.ts +1 -1
- package/dist/task/ChunkVectorUpsertTask.d.ts.map +1 -1
- package/dist/task/DocumentUpsertTask.d.ts.map +1 -1
- package/dist/task/KbToDocumentsTask.d.ts.map +1 -1
- package/dist/worker.js +17 -8
- package/dist/worker.js.map +3 -3
- package/package.json +11 -11
|
@@ -3,19 +3,27 @@
|
|
|
3
3
|
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { ServiceRegistry } from "@workglow/util";
|
|
6
7
|
import { ModelRepository } from "./ModelRepository";
|
|
7
8
|
/**
|
|
8
9
|
* Service token for the global model repository
|
|
9
10
|
*/
|
|
10
11
|
export declare const MODEL_REPOSITORY: import("@workglow/util").ServiceToken<ModelRepository>;
|
|
11
12
|
/**
|
|
12
|
-
* Gets the
|
|
13
|
-
*
|
|
13
|
+
* Gets the model repository from the given registry (defaults to global).
|
|
14
|
+
* Lazily registers the default in-memory repository when the token isn't
|
|
15
|
+
* present yet — same pattern as `getLogger`. Makes scoped registries
|
|
16
|
+
* (e.g. from `createOrchestrationContext`) safe without an explicit
|
|
17
|
+
* `registerModelDefaults(registry)` call.
|
|
14
18
|
*/
|
|
15
|
-
export declare function getGlobalModelRepository(): ModelRepository;
|
|
19
|
+
export declare function getGlobalModelRepository(registry?: ServiceRegistry): ModelRepository;
|
|
16
20
|
/**
|
|
17
|
-
* Sets the
|
|
18
|
-
* @param repository The model repository instance to register
|
|
21
|
+
* Sets the model repository instance on the given registry (defaults to global).
|
|
19
22
|
*/
|
|
20
|
-
export declare function setGlobalModelRepository(repository: ModelRepository): void;
|
|
23
|
+
export declare function setGlobalModelRepository(repository: ModelRepository, registry?: ServiceRegistry): void;
|
|
24
|
+
/**
|
|
25
|
+
* Registers the model repository default factory and the "model" input resolver/compactor
|
|
26
|
+
* on the given registry. Called by `bootstrapWorkglow` and `createOrchestrationContext`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function registerModelDefaults(registry?: ServiceRegistry): void;
|
|
21
29
|
//# sourceMappingURL=ModelRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelRegistry.d.ts","sourceRoot":"","sources":["../../src/model/ModelRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"ModelRegistry.d.ts","sourceRoot":"","sources":["../../src/model/ModelRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAKL,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;GAEG;AACH,eAAO,MAAM,gBAAgB,wDAA0D,CAAC;AAExF;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,GAAE,eAAuC,GAChD,eAAe,CAKjB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,eAAe,EAC3B,QAAQ,GAAE,eAAuC,GAChD,IAAI,CAEN;AAqCD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,eAAuC,GAAG,IAAI,CAQ7F"}
|
package/dist/node.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { getLogger } from "@workglow/util/worker";
|
|
11
11
|
|
|
12
12
|
// src/provider/AiProviderRegistry.ts
|
|
13
|
-
import { globalServiceRegistry, WORKER_MANAGER } from "@workglow/util/worker";
|
|
13
|
+
import { createServiceToken, globalServiceRegistry, WORKER_MANAGER } from "@workglow/util/worker";
|
|
14
14
|
class AiProviderRegistry {
|
|
15
15
|
runFnRegistry = new Map;
|
|
16
16
|
streamFnRegistry = new Map;
|
|
@@ -143,13 +143,20 @@ class AiProviderRegistry {
|
|
|
143
143
|
return runFn;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
var
|
|
147
|
-
function getAiProviderRegistry() {
|
|
148
|
-
|
|
146
|
+
var AI_PROVIDER_REGISTRY = createServiceToken("ai.provider.registry");
|
|
147
|
+
function getAiProviderRegistry(registry = globalServiceRegistry) {
|
|
148
|
+
if (!registry.has(AI_PROVIDER_REGISTRY)) {
|
|
149
|
+
registerAiProviderDefaults(registry);
|
|
150
|
+
}
|
|
151
|
+
return registry.get(AI_PROVIDER_REGISTRY);
|
|
152
|
+
}
|
|
153
|
+
function setAiProviderRegistry(pr, registry = globalServiceRegistry) {
|
|
154
|
+
registry.registerInstance(AI_PROVIDER_REGISTRY, pr);
|
|
149
155
|
}
|
|
150
|
-
function
|
|
151
|
-
|
|
156
|
+
function registerAiProviderDefaults(registry = globalServiceRegistry) {
|
|
157
|
+
registry.registerIfAbsent(AI_PROVIDER_REGISTRY, () => new AiProviderRegistry, true);
|
|
152
158
|
}
|
|
159
|
+
registerAiProviderDefaults();
|
|
153
160
|
|
|
154
161
|
// src/errors/ImageGenerationErrors.ts
|
|
155
162
|
class ProviderUnsupportedFeatureError extends Error {
|
|
@@ -701,41 +708,48 @@ class InMemoryModelRepository extends ModelRepository {
|
|
|
701
708
|
|
|
702
709
|
// src/model/ModelRegistry.ts
|
|
703
710
|
import {
|
|
704
|
-
createServiceToken,
|
|
711
|
+
createServiceToken as createServiceToken2,
|
|
705
712
|
globalServiceRegistry as globalServiceRegistry2,
|
|
706
713
|
registerInputCompactor,
|
|
707
714
|
registerInputResolver
|
|
708
715
|
} from "@workglow/util";
|
|
709
|
-
var MODEL_REPOSITORY =
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
716
|
+
var MODEL_REPOSITORY = createServiceToken2("model.repository");
|
|
717
|
+
function getGlobalModelRepository(registry = globalServiceRegistry2) {
|
|
718
|
+
if (!registry.has(MODEL_REPOSITORY)) {
|
|
719
|
+
registerModelDefaults(registry);
|
|
720
|
+
}
|
|
721
|
+
return registry.get(MODEL_REPOSITORY);
|
|
713
722
|
}
|
|
714
|
-
function setGlobalModelRepository(repository) {
|
|
715
|
-
|
|
723
|
+
function setGlobalModelRepository(repository, registry = globalServiceRegistry2) {
|
|
724
|
+
registry.registerInstance(MODEL_REPOSITORY, repository);
|
|
716
725
|
}
|
|
717
|
-
async function resolveModelFromRegistry(id,
|
|
718
|
-
const modelRepo =
|
|
726
|
+
async function resolveModelFromRegistry(id, _format, registry) {
|
|
727
|
+
const modelRepo = getGlobalModelRepository(registry);
|
|
719
728
|
const model = await modelRepo.findByName(id);
|
|
720
729
|
if (!model) {
|
|
721
730
|
throw new Error(`Model "${id}" not found in repository`);
|
|
722
731
|
}
|
|
723
732
|
return model;
|
|
724
733
|
}
|
|
725
|
-
|
|
726
|
-
registerInputCompactor("model", async (value, _format, registry) => {
|
|
734
|
+
async function compactModel(value, _format, registry) {
|
|
727
735
|
if (typeof value === "object" && value !== null && "model_id" in value) {
|
|
728
736
|
const id = value.model_id;
|
|
729
737
|
if (typeof id !== "string")
|
|
730
738
|
return;
|
|
731
|
-
const modelRepo =
|
|
739
|
+
const modelRepo = getGlobalModelRepository(registry);
|
|
732
740
|
const model = await modelRepo.findByName(id);
|
|
733
741
|
if (!model)
|
|
734
742
|
return;
|
|
735
743
|
return id;
|
|
736
744
|
}
|
|
737
745
|
return;
|
|
738
|
-
}
|
|
746
|
+
}
|
|
747
|
+
function registerModelDefaults(registry = globalServiceRegistry2) {
|
|
748
|
+
registry.registerIfAbsent(MODEL_REPOSITORY, () => new InMemoryModelRepository, true);
|
|
749
|
+
registerInputResolver("model", resolveModelFromRegistry, registry);
|
|
750
|
+
registerInputCompactor("model", compactModel, registry);
|
|
751
|
+
}
|
|
752
|
+
registerModelDefaults();
|
|
739
753
|
|
|
740
754
|
// src/provider/AiProvider.ts
|
|
741
755
|
import { globalServiceRegistry as globalServiceRegistry3, WORKER_MANAGER as WORKER_MANAGER2 } from "@workglow/util/worker";
|
|
@@ -1971,7 +1985,7 @@ var outputSchema2 = {
|
|
|
1971
1985
|
|
|
1972
1986
|
class ChunkVectorUpsertTask extends Task3 {
|
|
1973
1987
|
static type = "ChunkVectorUpsertTask";
|
|
1974
|
-
static category = "
|
|
1988
|
+
static category = "Document";
|
|
1975
1989
|
static title = "Add to Vector Store";
|
|
1976
1990
|
static description = "Store chunks + their embeddings in a knowledge base (1:1 aligned)";
|
|
1977
1991
|
static cacheable = false;
|
|
@@ -2748,8 +2762,11 @@ var documentEnricher = (input, config) => {
|
|
|
2748
2762
|
Workflow9.prototype.documentEnricher = CreateWorkflow9(DocumentEnricherTask);
|
|
2749
2763
|
|
|
2750
2764
|
// src/task/DocumentUpsertTask.ts
|
|
2751
|
-
import {
|
|
2752
|
-
|
|
2765
|
+
import {
|
|
2766
|
+
Document,
|
|
2767
|
+
DocumentMetadataSchema,
|
|
2768
|
+
TypeKnowledgeBase as TypeKnowledgeBase3
|
|
2769
|
+
} from "@workglow/knowledge-base";
|
|
2753
2770
|
import { CreateWorkflow as CreateWorkflow10, Task as Task6, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
2754
2771
|
var inputSchema5 = {
|
|
2755
2772
|
type: "object",
|
|
@@ -2797,7 +2814,7 @@ var outputSchema5 = {
|
|
|
2797
2814
|
|
|
2798
2815
|
class DocumentUpsertTask extends Task6 {
|
|
2799
2816
|
static type = "DocumentUpsertTask";
|
|
2800
|
-
static category = "
|
|
2817
|
+
static category = "Document";
|
|
2801
2818
|
static title = "Add Document";
|
|
2802
2819
|
static description = "Persist a parsed document tree to a knowledge base";
|
|
2803
2820
|
static cacheable = false;
|
|
@@ -4133,7 +4150,7 @@ var outputSchema8 = {
|
|
|
4133
4150
|
|
|
4134
4151
|
class KbToDocumentsTask extends Task9 {
|
|
4135
4152
|
static type = "KbToDocumentsTask";
|
|
4136
|
-
static category = "
|
|
4153
|
+
static category = "Document";
|
|
4137
4154
|
static title = "Knowledge Base to Documents";
|
|
4138
4155
|
static description = "List documents from a knowledge base, optionally filtering to only those that need embedding";
|
|
4139
4156
|
static cacheable = false;
|
|
@@ -7267,7 +7284,9 @@ export {
|
|
|
7267
7284
|
setAiProviderRegistry,
|
|
7268
7285
|
resolveAiProviderGpuQueueConcurrency,
|
|
7269
7286
|
reranker,
|
|
7287
|
+
registerModelDefaults,
|
|
7270
7288
|
registerAiTasks,
|
|
7289
|
+
registerAiProviderDefaults,
|
|
7271
7290
|
queryExpander,
|
|
7272
7291
|
poseLandmarker,
|
|
7273
7292
|
objectDetection,
|
|
@@ -7441,7 +7460,8 @@ export {
|
|
|
7441
7460
|
AiImageOutputTask,
|
|
7442
7461
|
AiChatTask,
|
|
7443
7462
|
AiChatOutputSchema,
|
|
7444
|
-
AiChatInputSchema
|
|
7463
|
+
AiChatInputSchema,
|
|
7464
|
+
AI_PROVIDER_REGISTRY
|
|
7445
7465
|
};
|
|
7446
7466
|
|
|
7447
|
-
//# debugId=
|
|
7467
|
+
//# debugId=F492A0962866F72464756E2164756E21
|