@workglow/ai 0.0.52
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/LICENSE +201 -0
- package/README.md +531 -0
- package/dist/browser.js +1371 -0
- package/dist/browser.js.map +30 -0
- package/dist/bun.js +1398 -0
- package/dist/bun.js.map +32 -0
- package/dist/common.d.ts +15 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/job/AiJob.d.ts +28 -0
- package/dist/job/AiJob.d.ts.map +1 -0
- package/dist/model/Model.d.ts +26 -0
- package/dist/model/Model.d.ts.map +1 -0
- package/dist/model/ModelRegistry.d.ts +9 -0
- package/dist/model/ModelRegistry.d.ts.map +1 -0
- package/dist/model/ModelRepository.d.ts +146 -0
- package/dist/model/ModelRepository.d.ts.map +1 -0
- package/dist/model/storage/InMemoryModelRepository.d.ts +18 -0
- package/dist/model/storage/InMemoryModelRepository.d.ts.map +1 -0
- package/dist/model/storage/IndexedDbModelRepository.d.ts +18 -0
- package/dist/model/storage/IndexedDbModelRepository.d.ts.map +1 -0
- package/dist/model/storage/PostgresModelRepository.d.ts +19 -0
- package/dist/model/storage/PostgresModelRepository.d.ts.map +1 -0
- package/dist/model/storage/SqliteModelRepository.d.ts +18 -0
- package/dist/model/storage/SqliteModelRepository.d.ts.map +1 -0
- package/dist/node.js +1397 -0
- package/dist/node.js.map +32 -0
- package/dist/provider/AiProviderRegistry.d.ts +35 -0
- package/dist/provider/AiProviderRegistry.d.ts.map +1 -0
- package/dist/source/Document.d.ts +56 -0
- package/dist/source/Document.d.ts.map +1 -0
- package/dist/source/DocumentConverter.d.ts +15 -0
- package/dist/source/DocumentConverter.d.ts.map +1 -0
- package/dist/source/DocumentConverterMarkdown.d.ts +13 -0
- package/dist/source/DocumentConverterMarkdown.d.ts.map +1 -0
- package/dist/source/DocumentConverterText.d.ts +13 -0
- package/dist/source/DocumentConverterText.d.ts.map +1 -0
- package/dist/source/MasterDocument.d.ts +27 -0
- package/dist/source/MasterDocument.d.ts.map +1 -0
- package/dist/source/index.d.ts +10 -0
- package/dist/source/index.d.ts.map +1 -0
- package/dist/task/DocumentSplitterTask.d.ts +58 -0
- package/dist/task/DocumentSplitterTask.d.ts.map +1 -0
- package/dist/task/DownloadModelTask.d.ts +118 -0
- package/dist/task/DownloadModelTask.d.ts.map +1 -0
- package/dist/task/TextEmbeddingTask.d.ts +268 -0
- package/dist/task/TextEmbeddingTask.d.ts.map +1 -0
- package/dist/task/TextGenerationTask.d.ts +140 -0
- package/dist/task/TextGenerationTask.d.ts.map +1 -0
- package/dist/task/TextQuestionAnswerTask.d.ts +124 -0
- package/dist/task/TextQuestionAnswerTask.d.ts.map +1 -0
- package/dist/task/TextRewriterTask.d.ts +113 -0
- package/dist/task/TextRewriterTask.d.ts.map +1 -0
- package/dist/task/TextSummaryTask.d.ts +95 -0
- package/dist/task/TextSummaryTask.d.ts.map +1 -0
- package/dist/task/TextTranslationTask.d.ts +158 -0
- package/dist/task/TextTranslationTask.d.ts.map +1 -0
- package/dist/task/VectorSimilarityTask.d.ts +334 -0
- package/dist/task/VectorSimilarityTask.d.ts.map +1 -0
- package/dist/task/base/AiTask.d.ts +47 -0
- package/dist/task/base/AiTask.d.ts.map +1 -0
- package/dist/task/base/AiTaskSchemas.d.ts +156 -0
- package/dist/task/base/AiTaskSchemas.d.ts.map +1 -0
- package/dist/task/index.d.ts +17 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +67 -0
package/dist/browser.js
ADDED
|
@@ -0,0 +1,1371 @@
|
|
|
1
|
+
// src/job/AiJob.ts
|
|
2
|
+
import {
|
|
3
|
+
AbortSignalJobError,
|
|
4
|
+
Job,
|
|
5
|
+
JobStatus,
|
|
6
|
+
PermanentJobError
|
|
7
|
+
} from "@workglow/job-queue";
|
|
8
|
+
|
|
9
|
+
// src/model/storage/InMemoryModelRepository.ts
|
|
10
|
+
import { InMemoryTabularRepository } from "@workglow/storage";
|
|
11
|
+
|
|
12
|
+
// src/model/ModelRepository.ts
|
|
13
|
+
import { EventEmitter } from "@workglow/util";
|
|
14
|
+
var ModelSchema = {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
name: { type: "string" },
|
|
18
|
+
details: { type: "string" }
|
|
19
|
+
},
|
|
20
|
+
required: ["name", "details"],
|
|
21
|
+
additionalProperties: false
|
|
22
|
+
};
|
|
23
|
+
var ModelPrimaryKeyNames = ["name"];
|
|
24
|
+
var Task2ModelSchema = {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
task: { type: "string" },
|
|
28
|
+
model: { type: "string" }
|
|
29
|
+
},
|
|
30
|
+
required: ["task", "model"],
|
|
31
|
+
additionalProperties: false
|
|
32
|
+
};
|
|
33
|
+
var Task2ModelPrimaryKeyNames = ["task", "model"];
|
|
34
|
+
|
|
35
|
+
class ModelRepository {
|
|
36
|
+
type = "ModelRepository";
|
|
37
|
+
events = new EventEmitter;
|
|
38
|
+
on(name, fn) {
|
|
39
|
+
this.events.on(name, fn);
|
|
40
|
+
}
|
|
41
|
+
off(name, fn) {
|
|
42
|
+
this.events.off(name, fn);
|
|
43
|
+
}
|
|
44
|
+
once(name, fn) {
|
|
45
|
+
this.events.once(name, fn);
|
|
46
|
+
}
|
|
47
|
+
waitOn(name) {
|
|
48
|
+
return this.events.waitOn(name);
|
|
49
|
+
}
|
|
50
|
+
async addModel(model) {
|
|
51
|
+
await this.modelTabularRepository.put({ name: model.name, details: JSON.stringify(model) });
|
|
52
|
+
this.models.set(model.name, model);
|
|
53
|
+
this.events.emit("model_added", model);
|
|
54
|
+
return model;
|
|
55
|
+
}
|
|
56
|
+
async findModelsByTask(task) {
|
|
57
|
+
if (typeof task != "string")
|
|
58
|
+
return;
|
|
59
|
+
const junctions = await this.task2ModelTabularRepository.search({ task });
|
|
60
|
+
if (!junctions || junctions.length === 0)
|
|
61
|
+
return;
|
|
62
|
+
const models = [];
|
|
63
|
+
for (const junction of junctions) {
|
|
64
|
+
const model = await this.modelTabularRepository.get({ name: junction.model });
|
|
65
|
+
if (model)
|
|
66
|
+
models.push(JSON.parse(model.details));
|
|
67
|
+
}
|
|
68
|
+
models.forEach((m) => this.models.set(m.name, m));
|
|
69
|
+
this.taskModels.set(task, models);
|
|
70
|
+
return models;
|
|
71
|
+
}
|
|
72
|
+
models = new Map;
|
|
73
|
+
taskModels = new Map;
|
|
74
|
+
async findTasksByModel(model) {
|
|
75
|
+
if (typeof model != "string")
|
|
76
|
+
return;
|
|
77
|
+
const junctions = await this.task2ModelTabularRepository.search({ model });
|
|
78
|
+
if (!junctions || junctions.length === 0)
|
|
79
|
+
return;
|
|
80
|
+
return junctions.map((junction) => junction.task);
|
|
81
|
+
}
|
|
82
|
+
async enumerateAllTasks() {
|
|
83
|
+
const junctions = await this.task2ModelTabularRepository.getAll();
|
|
84
|
+
if (!junctions || junctions.length === 0)
|
|
85
|
+
return;
|
|
86
|
+
const uniqueTasks = [...new Set(junctions.map((junction) => junction.task))];
|
|
87
|
+
return uniqueTasks;
|
|
88
|
+
}
|
|
89
|
+
async enumerateAllModels() {
|
|
90
|
+
const models = await this.modelTabularRepository.getAll();
|
|
91
|
+
if (!models || models.length === 0)
|
|
92
|
+
return;
|
|
93
|
+
const parsedModels = models.map((model) => JSON.parse(model.details));
|
|
94
|
+
parsedModels.forEach((m) => this.models.set(m.name, m));
|
|
95
|
+
return parsedModels;
|
|
96
|
+
}
|
|
97
|
+
async connectTaskToModel(task, model) {
|
|
98
|
+
await this.task2ModelTabularRepository.put({ task, model });
|
|
99
|
+
this.events.emit("task_model_connected", task, model);
|
|
100
|
+
}
|
|
101
|
+
async findByName(name) {
|
|
102
|
+
if (typeof name != "string")
|
|
103
|
+
return;
|
|
104
|
+
const modelstr = await this.modelTabularRepository.get({ name });
|
|
105
|
+
if (!modelstr)
|
|
106
|
+
return;
|
|
107
|
+
const model = JSON.parse(modelstr.details);
|
|
108
|
+
this.models.set(model.name, model);
|
|
109
|
+
return model;
|
|
110
|
+
}
|
|
111
|
+
async size() {
|
|
112
|
+
return await this.modelTabularRepository.size();
|
|
113
|
+
}
|
|
114
|
+
async clear() {
|
|
115
|
+
await this.modelTabularRepository.deleteAll();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/model/storage/InMemoryModelRepository.ts
|
|
120
|
+
class InMemoryModelRepository extends ModelRepository {
|
|
121
|
+
modelTabularRepository;
|
|
122
|
+
task2ModelTabularRepository;
|
|
123
|
+
type = "InMemoryModelRepository";
|
|
124
|
+
constructor() {
|
|
125
|
+
super();
|
|
126
|
+
this.modelTabularRepository = new InMemoryTabularRepository(ModelSchema, ModelPrimaryKeyNames);
|
|
127
|
+
this.task2ModelTabularRepository = new InMemoryTabularRepository(Task2ModelSchema, Task2ModelPrimaryKeyNames, ["model"]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/model/ModelRegistry.ts
|
|
132
|
+
class FallbackModelRegistry extends InMemoryModelRepository {
|
|
133
|
+
}
|
|
134
|
+
var modelRegistry;
|
|
135
|
+
function getGlobalModelRepository() {
|
|
136
|
+
if (!modelRegistry)
|
|
137
|
+
modelRegistry = new FallbackModelRegistry;
|
|
138
|
+
return modelRegistry;
|
|
139
|
+
}
|
|
140
|
+
function setGlobalModelRepository(pr) {
|
|
141
|
+
modelRegistry = pr;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/provider/AiProviderRegistry.ts
|
|
145
|
+
import { globalServiceRegistry, WORKER_MANAGER } from "@workglow/util";
|
|
146
|
+
|
|
147
|
+
class AiProviderRegistry {
|
|
148
|
+
runFnRegistry = new Map;
|
|
149
|
+
registerRunFn(modelProvider, taskType, runFn) {
|
|
150
|
+
if (!this.runFnRegistry.has(taskType)) {
|
|
151
|
+
this.runFnRegistry.set(taskType, new Map);
|
|
152
|
+
}
|
|
153
|
+
this.runFnRegistry.get(taskType).set(modelProvider, runFn);
|
|
154
|
+
}
|
|
155
|
+
registerAsWorkerRunFn(modelProvider, taskType) {
|
|
156
|
+
const workerFn = async (input, model, update_progress, signal) => {
|
|
157
|
+
const workerManager = globalServiceRegistry.get(WORKER_MANAGER);
|
|
158
|
+
const result = await workerManager.callWorkerFunction(modelProvider, taskType, [input, model], {
|
|
159
|
+
signal,
|
|
160
|
+
onProgress: update_progress
|
|
161
|
+
});
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
this.registerRunFn(modelProvider, taskType, workerFn);
|
|
165
|
+
}
|
|
166
|
+
getDirectRunFn(modelProvider, taskType) {
|
|
167
|
+
const taskTypeMap = this.runFnRegistry.get(taskType);
|
|
168
|
+
const runFn = taskTypeMap?.get(modelProvider);
|
|
169
|
+
if (!runFn) {
|
|
170
|
+
throw new Error(`No run function found for task type ${taskType} and model provider ${modelProvider}`);
|
|
171
|
+
}
|
|
172
|
+
return runFn;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
var providerRegistry;
|
|
176
|
+
function getAiProviderRegistry() {
|
|
177
|
+
if (!providerRegistry)
|
|
178
|
+
providerRegistry = new AiProviderRegistry;
|
|
179
|
+
return providerRegistry;
|
|
180
|
+
}
|
|
181
|
+
function setAiProviderRegistry(pr) {
|
|
182
|
+
providerRegistry = pr;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/job/AiJob.ts
|
|
186
|
+
class AiJob extends Job {
|
|
187
|
+
async execute(input, context) {
|
|
188
|
+
if (context.signal.aborted || this.status === JobStatus.ABORTING) {
|
|
189
|
+
throw new AbortSignalJobError("Abort signal aborted before execution of job");
|
|
190
|
+
}
|
|
191
|
+
let abortHandler;
|
|
192
|
+
try {
|
|
193
|
+
const abortPromise = new Promise((_resolve, reject) => {
|
|
194
|
+
const handler = () => {
|
|
195
|
+
reject(new AbortSignalJobError("Abort signal seen, ending job"));
|
|
196
|
+
};
|
|
197
|
+
context.signal.addEventListener("abort", handler, { once: true });
|
|
198
|
+
abortHandler = () => context.signal.removeEventListener("abort", handler);
|
|
199
|
+
});
|
|
200
|
+
const runFn = async () => {
|
|
201
|
+
const fn = getAiProviderRegistry().getDirectRunFn(input.aiProvider, input.taskType);
|
|
202
|
+
if (!fn) {
|
|
203
|
+
throw new PermanentJobError(`No run function found for task type ${input.taskType} and model provider ${input.aiProvider}`);
|
|
204
|
+
}
|
|
205
|
+
const modelName = input.taskInput.model;
|
|
206
|
+
const model = await getGlobalModelRepository().findByName(modelName);
|
|
207
|
+
if (modelName && !model) {
|
|
208
|
+
throw new PermanentJobError(`Model ${modelName} not found`);
|
|
209
|
+
}
|
|
210
|
+
if (context.signal?.aborted) {
|
|
211
|
+
throw new AbortSignalJobError("Job aborted");
|
|
212
|
+
}
|
|
213
|
+
return await fn(input.taskInput, model, context.updateProgress, context.signal);
|
|
214
|
+
};
|
|
215
|
+
const runFnPromise = runFn();
|
|
216
|
+
return await Promise.race([runFnPromise, abortPromise]);
|
|
217
|
+
} finally {
|
|
218
|
+
if (abortHandler) {
|
|
219
|
+
abortHandler();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// src/source/Document.ts
|
|
225
|
+
class Document {
|
|
226
|
+
metadata;
|
|
227
|
+
constructor(content, metadata = { title: "" }) {
|
|
228
|
+
this.metadata = metadata;
|
|
229
|
+
if (content) {
|
|
230
|
+
if (Array.isArray(content)) {
|
|
231
|
+
for (const line of content) {
|
|
232
|
+
this.addContent(line);
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
this.addContent(content);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
addContent(content) {
|
|
240
|
+
if (typeof content === "string") {
|
|
241
|
+
this.addText(content);
|
|
242
|
+
} else if (content instanceof DocumentBaseFragment || content instanceof DocumentSection) {
|
|
243
|
+
this.fragments.push(content);
|
|
244
|
+
} else {
|
|
245
|
+
throw new Error("Unknown content type");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
addSection(content, metadata) {
|
|
249
|
+
const section = new DocumentSection(this, content, metadata);
|
|
250
|
+
this.fragments.push(section);
|
|
251
|
+
return section;
|
|
252
|
+
}
|
|
253
|
+
addText(content) {
|
|
254
|
+
const f = new TextFragment(content);
|
|
255
|
+
this.fragments.push(f);
|
|
256
|
+
return f;
|
|
257
|
+
}
|
|
258
|
+
addImage(content) {
|
|
259
|
+
const f = new ImageFragment(content);
|
|
260
|
+
this.fragments.push(f);
|
|
261
|
+
return f;
|
|
262
|
+
}
|
|
263
|
+
addTable(content) {
|
|
264
|
+
const f = new TableFragment(content);
|
|
265
|
+
this.fragments.push(f);
|
|
266
|
+
return f;
|
|
267
|
+
}
|
|
268
|
+
fragments = [];
|
|
269
|
+
toJSON() {
|
|
270
|
+
return {
|
|
271
|
+
type: "document" /* DOCUMENT */,
|
|
272
|
+
metadata: this.metadata,
|
|
273
|
+
fragments: this.fragments.map((f) => f.toJSON())
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
class DocumentSection extends Document {
|
|
279
|
+
parent;
|
|
280
|
+
constructor(parent, content, metadata) {
|
|
281
|
+
super(content, metadata);
|
|
282
|
+
this.parent = parent;
|
|
283
|
+
this.parent = parent;
|
|
284
|
+
}
|
|
285
|
+
toJSON() {
|
|
286
|
+
return {
|
|
287
|
+
type: "section" /* SECTION */,
|
|
288
|
+
metadata: this.metadata,
|
|
289
|
+
fragments: this.fragments.map((f) => f.toJSON())
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
class DocumentBaseFragment {
|
|
295
|
+
metadata;
|
|
296
|
+
constructor(metadata) {
|
|
297
|
+
this.metadata = metadata;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
class TextFragment extends DocumentBaseFragment {
|
|
302
|
+
content;
|
|
303
|
+
constructor(content, metadata) {
|
|
304
|
+
super(metadata);
|
|
305
|
+
this.content = content;
|
|
306
|
+
}
|
|
307
|
+
toJSON() {
|
|
308
|
+
return {
|
|
309
|
+
type: "text" /* TEXT */,
|
|
310
|
+
metadata: this.metadata,
|
|
311
|
+
content: this.content
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
class TableFragment extends DocumentBaseFragment {
|
|
317
|
+
content;
|
|
318
|
+
constructor(content, metadata) {
|
|
319
|
+
super(metadata);
|
|
320
|
+
this.content = content;
|
|
321
|
+
}
|
|
322
|
+
toJSON() {
|
|
323
|
+
return {
|
|
324
|
+
type: "table" /* TABLE */,
|
|
325
|
+
metadata: this.metadata,
|
|
326
|
+
content: this.content
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
class ImageFragment extends DocumentBaseFragment {
|
|
332
|
+
content;
|
|
333
|
+
constructor(content, metadata) {
|
|
334
|
+
super(metadata);
|
|
335
|
+
this.content = content;
|
|
336
|
+
}
|
|
337
|
+
toJSON() {
|
|
338
|
+
return {
|
|
339
|
+
type: "image" /* IMAGE */,
|
|
340
|
+
metadata: this.metadata,
|
|
341
|
+
content: this.content
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// src/source/DocumentConverter.ts
|
|
346
|
+
class DocumentConverter {
|
|
347
|
+
metadata;
|
|
348
|
+
constructor(metadata) {
|
|
349
|
+
this.metadata = metadata;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/source/DocumentConverterMarkdown.ts
|
|
354
|
+
class DocumentConverterMarkdown extends DocumentConverter {
|
|
355
|
+
markdown;
|
|
356
|
+
constructor(metadata, markdown) {
|
|
357
|
+
super(metadata);
|
|
358
|
+
this.markdown = markdown;
|
|
359
|
+
}
|
|
360
|
+
convert() {
|
|
361
|
+
const parser = new MarkdownParser(this.metadata.title);
|
|
362
|
+
const document = parser.parse(this.markdown);
|
|
363
|
+
return document;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
class MarkdownParser {
|
|
368
|
+
document;
|
|
369
|
+
currentSection;
|
|
370
|
+
textBuffer = [];
|
|
371
|
+
constructor(title) {
|
|
372
|
+
this.document = new Document(title);
|
|
373
|
+
this.currentSection = this.document;
|
|
374
|
+
}
|
|
375
|
+
parse(markdown) {
|
|
376
|
+
const lines = markdown.split(`
|
|
377
|
+
`);
|
|
378
|
+
lines.forEach((line, index) => {
|
|
379
|
+
if (this.isHeader(line)) {
|
|
380
|
+
this.flushTextBuffer();
|
|
381
|
+
const { level, content } = this.parseHeader(line);
|
|
382
|
+
this.currentSection = level === 1 ? this.document.addSection(content) : this.currentSection.addSection(content);
|
|
383
|
+
} else if (this.isTableStart(line)) {
|
|
384
|
+
this.flushTextBuffer();
|
|
385
|
+
const tableLines = this.collectTableLines(lines, index);
|
|
386
|
+
this.currentSection.addTable(tableLines.join(`
|
|
387
|
+
`));
|
|
388
|
+
} else if (this.isImageInline(line)) {
|
|
389
|
+
this.parseLineWithPossibleImages(line);
|
|
390
|
+
} else {
|
|
391
|
+
this.textBuffer.push(line);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
this.flushTextBuffer();
|
|
395
|
+
return this.document;
|
|
396
|
+
}
|
|
397
|
+
flushTextBuffer() {
|
|
398
|
+
if (this.textBuffer.length > 0) {
|
|
399
|
+
const textContent = this.textBuffer.join(`
|
|
400
|
+
`).trim();
|
|
401
|
+
if (textContent) {
|
|
402
|
+
this.currentSection.addText(textContent);
|
|
403
|
+
}
|
|
404
|
+
this.textBuffer = [];
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
parseLineWithPossibleImages(line) {
|
|
408
|
+
const parts = line.split(/(!\[.*?\]\(.*?\))/).filter((part) => part !== "");
|
|
409
|
+
parts.forEach((part) => {
|
|
410
|
+
if (this.isImage(part)) {
|
|
411
|
+
const { alt, src } = this.parseImage(part);
|
|
412
|
+
this.flushTextBuffer();
|
|
413
|
+
this.currentSection.addImage({ alt, src });
|
|
414
|
+
} else {
|
|
415
|
+
this.textBuffer.push(part);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
this.flushTextBuffer();
|
|
419
|
+
}
|
|
420
|
+
isHeader(line) {
|
|
421
|
+
return /^#{1,6}\s/.test(line);
|
|
422
|
+
}
|
|
423
|
+
parseHeader(line) {
|
|
424
|
+
const match = line.match(/^(#{1,6})\s+(.*)$/);
|
|
425
|
+
return match ? { level: match[1].length, content: match[2] } : { level: 0, content: "" };
|
|
426
|
+
}
|
|
427
|
+
isTableStart(line) {
|
|
428
|
+
return line.trim().startsWith("|") && line.includes("|", line.indexOf("|") + 1);
|
|
429
|
+
}
|
|
430
|
+
collectTableLines(lines, startIndex) {
|
|
431
|
+
const tableLines = [];
|
|
432
|
+
for (let i = startIndex;i < lines.length && this.isTableLine(lines[i]); i++) {
|
|
433
|
+
tableLines.push(lines[i]);
|
|
434
|
+
}
|
|
435
|
+
return tableLines;
|
|
436
|
+
}
|
|
437
|
+
isTableLine(line) {
|
|
438
|
+
return line.includes("|");
|
|
439
|
+
}
|
|
440
|
+
isImageInline(line) {
|
|
441
|
+
return line.includes(";
|
|
442
|
+
}
|
|
443
|
+
isImage(part) {
|
|
444
|
+
return /^!\[.*\]\(.*\)$/.test(part);
|
|
445
|
+
}
|
|
446
|
+
parseImage(markdown) {
|
|
447
|
+
const match = markdown.match(/^!\[(.*)\]\((.*)\)$/);
|
|
448
|
+
return match ? { alt: match[1], src: match[2] } : { alt: "", src: "" };
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
// src/source/DocumentConverterText.ts
|
|
452
|
+
class DocumentConverterText extends DocumentConverter {
|
|
453
|
+
text;
|
|
454
|
+
constructor(metadata, text) {
|
|
455
|
+
super(metadata);
|
|
456
|
+
this.text = text;
|
|
457
|
+
}
|
|
458
|
+
convert() {
|
|
459
|
+
return new Document(this.text, this.metadata);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
// src/task/base/AiTask.ts
|
|
463
|
+
import {
|
|
464
|
+
JobQueueTask,
|
|
465
|
+
TaskConfigurationError
|
|
466
|
+
} from "@workglow/task-graph";
|
|
467
|
+
function schemaFormat(schema) {
|
|
468
|
+
return typeof schema === "object" && schema !== null && "format" in schema ? schema.format : undefined;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
class AiTask extends JobQueueTask {
|
|
472
|
+
static type = "AiTask";
|
|
473
|
+
modelCache;
|
|
474
|
+
constructor(input = {}, config = {}) {
|
|
475
|
+
config.name ||= `${new.target.type || new.target.name}${input.model ? " with model " + input.model : ""}`;
|
|
476
|
+
super(input, config);
|
|
477
|
+
}
|
|
478
|
+
async createJob(input, queue) {
|
|
479
|
+
if (typeof input.model !== "string") {
|
|
480
|
+
console.error("AiTask: Model is not a string", input);
|
|
481
|
+
throw new TaskConfigurationError("AiTask: Model is not a string, only create job for single model tasks");
|
|
482
|
+
}
|
|
483
|
+
const runtype = this.constructor.runtype ?? this.constructor.type;
|
|
484
|
+
const model = await this.getModelForInput(input);
|
|
485
|
+
const queueName = queue?.queueName ?? await this.getDefaultQueueName(input);
|
|
486
|
+
if (!queueName) {
|
|
487
|
+
throw new TaskConfigurationError("JobQueueTask: Unable to determine queue for AI provider");
|
|
488
|
+
}
|
|
489
|
+
const job = new AiJob({
|
|
490
|
+
queueName,
|
|
491
|
+
jobRunId: this.config.runnerId,
|
|
492
|
+
input: {
|
|
493
|
+
taskType: runtype,
|
|
494
|
+
aiProvider: model.provider,
|
|
495
|
+
taskInput: input
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
return job;
|
|
499
|
+
}
|
|
500
|
+
async getModelForInput(input) {
|
|
501
|
+
const modelname = input.model;
|
|
502
|
+
if (!modelname)
|
|
503
|
+
throw new TaskConfigurationError("AiTask: No model name found");
|
|
504
|
+
if (this.modelCache && this.modelCache.name === modelname) {
|
|
505
|
+
return this.modelCache.model;
|
|
506
|
+
}
|
|
507
|
+
const model = await getGlobalModelRepository().findByName(modelname);
|
|
508
|
+
if (!model) {
|
|
509
|
+
throw new TaskConfigurationError(`JobQueueTask: No model ${modelname} found`);
|
|
510
|
+
}
|
|
511
|
+
this.modelCache = { name: modelname, model };
|
|
512
|
+
return model;
|
|
513
|
+
}
|
|
514
|
+
async getDefaultQueueName(input) {
|
|
515
|
+
if (typeof input.model === "string") {
|
|
516
|
+
const model = await this.getModelForInput(input);
|
|
517
|
+
return model.provider;
|
|
518
|
+
}
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
async validateInput(input) {
|
|
522
|
+
const inputSchema = this.inputSchema();
|
|
523
|
+
if (typeof inputSchema === "boolean") {
|
|
524
|
+
if (inputSchema === false) {
|
|
525
|
+
throw new TaskConfigurationError(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
526
|
+
}
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
530
|
+
if (modelTaskProperties.length > 0) {
|
|
531
|
+
const taskModels = await getGlobalModelRepository().findModelsByTask(this.type);
|
|
532
|
+
for (const [key, propSchema] of modelTaskProperties) {
|
|
533
|
+
let requestedModels = Array.isArray(input[key]) ? input[key] : [input[key]];
|
|
534
|
+
for (const model of requestedModels) {
|
|
535
|
+
const foundModel = taskModels?.find((m) => m.name === model);
|
|
536
|
+
if (!foundModel) {
|
|
537
|
+
throw new TaskConfigurationError(`AiTask: Missing model for '${key}' named '${model}' for task '${this.type}'`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
const modelPlainProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema) === "model");
|
|
543
|
+
if (modelPlainProperties.length > 0) {
|
|
544
|
+
for (const [key, propSchema] of modelPlainProperties) {
|
|
545
|
+
let requestedModels = Array.isArray(input[key]) ? input[key] : [input[key]];
|
|
546
|
+
for (const model of requestedModels) {
|
|
547
|
+
const foundModel = await getGlobalModelRepository().findByName(model);
|
|
548
|
+
if (!foundModel) {
|
|
549
|
+
throw new TaskConfigurationError(`AiTask: Missing model for "${key}" named "${model}"`);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return super.validateInput(input);
|
|
555
|
+
}
|
|
556
|
+
async narrowInput(input) {
|
|
557
|
+
const inputSchema = this.inputSchema();
|
|
558
|
+
if (typeof inputSchema === "boolean") {
|
|
559
|
+
if (inputSchema === false) {
|
|
560
|
+
throw new TaskConfigurationError(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
561
|
+
}
|
|
562
|
+
return input;
|
|
563
|
+
}
|
|
564
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
565
|
+
if (modelTaskProperties.length > 0) {
|
|
566
|
+
const taskModels = await getGlobalModelRepository().findModelsByTask(this.type);
|
|
567
|
+
for (const [key, propSchema] of modelTaskProperties) {
|
|
568
|
+
let requestedModels = Array.isArray(input[key]) ? input[key] : [input[key]];
|
|
569
|
+
let usingModels = requestedModels.filter((model) => taskModels?.find((m) => m.name === model));
|
|
570
|
+
usingModels = usingModels.length > 1 ? usingModels : usingModels[0];
|
|
571
|
+
input[key] = usingModels;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return input;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
// src/task/base/AiTaskSchemas.ts
|
|
578
|
+
import {
|
|
579
|
+
FromSchemaDefaultOptions
|
|
580
|
+
} from "@workglow/util";
|
|
581
|
+
var TypedArrayType = null;
|
|
582
|
+
var TypedArraySchemaOptions = {
|
|
583
|
+
...FromSchemaDefaultOptions,
|
|
584
|
+
deserialize: [
|
|
585
|
+
{
|
|
586
|
+
pattern: { format: "TypedArray" },
|
|
587
|
+
output: TypedArrayType
|
|
588
|
+
}
|
|
589
|
+
]
|
|
590
|
+
};
|
|
591
|
+
var TypedArraySchema = (annotations = {}) => ({
|
|
592
|
+
oneOf: [
|
|
593
|
+
{
|
|
594
|
+
type: "array",
|
|
595
|
+
items: { type: "number", format: "Float64" },
|
|
596
|
+
title: "Float64Array",
|
|
597
|
+
description: "A 64-bit floating point array",
|
|
598
|
+
format: "Float64Array"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
type: "array",
|
|
602
|
+
items: { type: "number", format: "Float32" },
|
|
603
|
+
title: "Float32Array",
|
|
604
|
+
description: "A 32-bit floating point array",
|
|
605
|
+
format: "Float32Array"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
type: "array",
|
|
609
|
+
items: { type: "number", format: "Int32" },
|
|
610
|
+
title: "Int32Array",
|
|
611
|
+
description: "A 32-bit integer array",
|
|
612
|
+
format: "Int32Array"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
type: "array",
|
|
616
|
+
items: { type: "number", format: "Int16" },
|
|
617
|
+
title: "Int16Array",
|
|
618
|
+
description: "A 16-bit integer array",
|
|
619
|
+
format: "Int16Array"
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
type: "array",
|
|
623
|
+
items: { type: "number", format: "Int8" },
|
|
624
|
+
title: "Int8Array"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
type: "array",
|
|
628
|
+
items: { type: "number", format: "Uint8" },
|
|
629
|
+
title: "Uint8Array",
|
|
630
|
+
description: "A 8-bit unsigned integer array",
|
|
631
|
+
format: "Uint8Array"
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
type: "array",
|
|
635
|
+
items: { type: "number", format: "Uint16" },
|
|
636
|
+
title: "Uint16Array",
|
|
637
|
+
description: "A 16-bit unsigned integer array",
|
|
638
|
+
format: "Uint16Array"
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
type: "array",
|
|
642
|
+
items: { type: "number", format: "Uint32" },
|
|
643
|
+
title: "Uint32Array",
|
|
644
|
+
description: "A 32-bit unsigned integer array",
|
|
645
|
+
format: "Uint32Array"
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
type: "array",
|
|
649
|
+
items: { type: "number", format: "Uint8Clamped" },
|
|
650
|
+
title: "Uint8ClampedArray",
|
|
651
|
+
description: "A 8-bit unsigned integer array with values clamped to 0-255",
|
|
652
|
+
format: "Uint8ClampedArray"
|
|
653
|
+
}
|
|
654
|
+
],
|
|
655
|
+
format: "TypedArray",
|
|
656
|
+
...annotations
|
|
657
|
+
});
|
|
658
|
+
var TypeLanguage = (annotations = {}) => ({
|
|
659
|
+
type: "string",
|
|
660
|
+
title: "Language",
|
|
661
|
+
description: "The language to use",
|
|
662
|
+
maxLength: 2,
|
|
663
|
+
minLength: 2,
|
|
664
|
+
...annotations
|
|
665
|
+
});
|
|
666
|
+
function TypeModel(semantic = "model", options = {}) {
|
|
667
|
+
if (semantic !== "model" && !semantic.startsWith("model:")) {
|
|
668
|
+
throw new Error("Invalid semantic value");
|
|
669
|
+
}
|
|
670
|
+
const taskName = semantic.startsWith("model:") ? semantic.slice(6).replace(/Task$/, "").replaceAll(/[A-Z]/g, (char) => " " + char.toLowerCase()).trim() : null;
|
|
671
|
+
return {
|
|
672
|
+
title: "Model",
|
|
673
|
+
description: `The model ${taskName ? `for ${taskName} ` : "to use"}`,
|
|
674
|
+
...options,
|
|
675
|
+
format: semantic,
|
|
676
|
+
type: "string"
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
var TypeReplicateArray = (type, annotations = {}) => ({
|
|
680
|
+
oneOf: [type, { type: "array", items: type }],
|
|
681
|
+
title: type.title,
|
|
682
|
+
description: type.description,
|
|
683
|
+
...type.format ? { format: type.format } : {},
|
|
684
|
+
...annotations,
|
|
685
|
+
"x-replicate": true
|
|
686
|
+
});
|
|
687
|
+
// src/task/DocumentSplitterTask.ts
|
|
688
|
+
import {
|
|
689
|
+
CreateWorkflow,
|
|
690
|
+
Task,
|
|
691
|
+
TaskRegistry,
|
|
692
|
+
Workflow
|
|
693
|
+
} from "@workglow/task-graph";
|
|
694
|
+
var inputSchema = {
|
|
695
|
+
type: "object",
|
|
696
|
+
properties: {
|
|
697
|
+
parser: {
|
|
698
|
+
type: "string",
|
|
699
|
+
enum: ["txt", "md"],
|
|
700
|
+
title: "Document Kind",
|
|
701
|
+
description: "The kind of document (txt or md)"
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
required: ["parser"],
|
|
705
|
+
additionalProperties: false
|
|
706
|
+
};
|
|
707
|
+
var outputSchema = {
|
|
708
|
+
type: "object",
|
|
709
|
+
properties: {
|
|
710
|
+
texts: {
|
|
711
|
+
type: "array",
|
|
712
|
+
items: { type: "string" },
|
|
713
|
+
title: "Text Chunks",
|
|
714
|
+
description: "The text chunks of the document"
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
required: ["texts"],
|
|
718
|
+
additionalProperties: false
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
class DocumentSplitterTask extends Task {
|
|
722
|
+
static type = "DocumentSplitterTask";
|
|
723
|
+
static category = "Document";
|
|
724
|
+
static title = "Document Splitter";
|
|
725
|
+
static description = "Splits documents into text chunks for processing";
|
|
726
|
+
static inputSchema() {
|
|
727
|
+
return inputSchema;
|
|
728
|
+
}
|
|
729
|
+
static outputSchema() {
|
|
730
|
+
return outputSchema;
|
|
731
|
+
}
|
|
732
|
+
flattenFragmentsToTexts(item) {
|
|
733
|
+
if (item instanceof Document) {
|
|
734
|
+
const texts = [];
|
|
735
|
+
item.fragments.forEach((fragment) => {
|
|
736
|
+
texts.push(...this.flattenFragmentsToTexts(fragment));
|
|
737
|
+
});
|
|
738
|
+
return texts;
|
|
739
|
+
} else {
|
|
740
|
+
return [item.content];
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
async executeReactive() {
|
|
744
|
+
return { texts: this.flattenFragmentsToTexts(this.runInputData.file) };
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
TaskRegistry.registerTask(DocumentSplitterTask);
|
|
748
|
+
var DocumentSplitter = (input) => {
|
|
749
|
+
return new DocumentSplitterTask(input).run();
|
|
750
|
+
};
|
|
751
|
+
Workflow.prototype.DocumentSplitter = CreateWorkflow(DocumentSplitterTask);
|
|
752
|
+
// src/task/DownloadModelTask.ts
|
|
753
|
+
import { CreateWorkflow as CreateWorkflow2, TaskRegistry as TaskRegistry2, Workflow as Workflow2 } from "@workglow/task-graph";
|
|
754
|
+
var modelSchema = TypeReplicateArray(TypeModel("model"));
|
|
755
|
+
var DownloadModelInputSchema = {
|
|
756
|
+
type: "object",
|
|
757
|
+
properties: {
|
|
758
|
+
model: modelSchema
|
|
759
|
+
},
|
|
760
|
+
required: ["model"],
|
|
761
|
+
additionalProperties: false
|
|
762
|
+
};
|
|
763
|
+
var DownloadModelOutputSchema = {
|
|
764
|
+
type: "object",
|
|
765
|
+
properties: {
|
|
766
|
+
model: modelSchema
|
|
767
|
+
},
|
|
768
|
+
required: ["model"],
|
|
769
|
+
additionalProperties: false
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
class DownloadModelTask extends AiTask {
|
|
773
|
+
static type = "DownloadModelTask";
|
|
774
|
+
static category = "AI Text Model";
|
|
775
|
+
static title = "Download Model";
|
|
776
|
+
static description = "Downloads and caches AI models locally with progress tracking";
|
|
777
|
+
static inputSchema() {
|
|
778
|
+
return DownloadModelInputSchema;
|
|
779
|
+
}
|
|
780
|
+
static outputSchema() {
|
|
781
|
+
return DownloadModelOutputSchema;
|
|
782
|
+
}
|
|
783
|
+
static cacheable = false;
|
|
784
|
+
files = [];
|
|
785
|
+
constructor(input, config = {}) {
|
|
786
|
+
super(input, config);
|
|
787
|
+
this.on("progress", this.processProgress.bind(this));
|
|
788
|
+
this.on("start", () => {
|
|
789
|
+
this.files = [];
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
processProgress(progress, message = "", details) {
|
|
793
|
+
if (details?.file) {
|
|
794
|
+
const file = this.files.find((f) => f.file === details.file);
|
|
795
|
+
if (file) {
|
|
796
|
+
file.progress = details.progress;
|
|
797
|
+
} else {
|
|
798
|
+
this.files.push({ file: details.file, progress: details.progress });
|
|
799
|
+
}
|
|
800
|
+
this.progress = this.files.reduce((acc, f) => acc + f.progress, 0) / this.files.length;
|
|
801
|
+
} else {
|
|
802
|
+
this.progress = progress;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
TaskRegistry2.registerTask(DownloadModelTask);
|
|
807
|
+
var DownloadModel = (input, config) => {
|
|
808
|
+
return new DownloadModelTask(input, config).run();
|
|
809
|
+
};
|
|
810
|
+
Workflow2.prototype.DownloadModel = CreateWorkflow2(DownloadModelTask);
|
|
811
|
+
// src/task/TextEmbeddingTask.ts
|
|
812
|
+
import { CreateWorkflow as CreateWorkflow3, TaskRegistry as TaskRegistry3, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
813
|
+
var modelSchema2 = TypeReplicateArray(TypeModel("model:TextEmbeddingTask"));
|
|
814
|
+
var TextEmbeddingInputSchema = {
|
|
815
|
+
type: "object",
|
|
816
|
+
properties: {
|
|
817
|
+
text: TypeReplicateArray({
|
|
818
|
+
type: "string",
|
|
819
|
+
title: "Text",
|
|
820
|
+
description: "The text to embed"
|
|
821
|
+
}),
|
|
822
|
+
model: modelSchema2
|
|
823
|
+
},
|
|
824
|
+
required: ["text", "model"],
|
|
825
|
+
additionalProperties: false
|
|
826
|
+
};
|
|
827
|
+
var TextEmbeddingOutputSchema = {
|
|
828
|
+
type: "object",
|
|
829
|
+
properties: {
|
|
830
|
+
vector: TypeReplicateArray(TypedArraySchema({
|
|
831
|
+
title: "Vector",
|
|
832
|
+
description: "The vector embedding of the text"
|
|
833
|
+
}))
|
|
834
|
+
},
|
|
835
|
+
required: ["vector"],
|
|
836
|
+
additionalProperties: false
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
class TextEmbeddingTask extends AiTask {
|
|
840
|
+
static type = "TextEmbeddingTask";
|
|
841
|
+
static category = "AI Text Model";
|
|
842
|
+
static title = "Text Embedding";
|
|
843
|
+
static description = "Generates vector embeddings for text to capture semantic meaning";
|
|
844
|
+
static inputSchema() {
|
|
845
|
+
return TextEmbeddingInputSchema;
|
|
846
|
+
}
|
|
847
|
+
static outputSchema() {
|
|
848
|
+
return TextEmbeddingOutputSchema;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
TaskRegistry3.registerTask(TextEmbeddingTask);
|
|
852
|
+
var TextEmbedding = async (input, config) => {
|
|
853
|
+
return new TextEmbeddingTask(input, config).run();
|
|
854
|
+
};
|
|
855
|
+
Workflow3.prototype.TextEmbedding = CreateWorkflow3(TextEmbeddingTask);
|
|
856
|
+
// src/task/TextGenerationTask.ts
|
|
857
|
+
import { CreateWorkflow as CreateWorkflow4, TaskRegistry as TaskRegistry4, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
858
|
+
var generatedTextSchema = {
|
|
859
|
+
type: "string",
|
|
860
|
+
title: "Text",
|
|
861
|
+
description: "The generated text"
|
|
862
|
+
};
|
|
863
|
+
var modelSchema3 = TypeReplicateArray(TypeModel("model:TextGenerationTask"));
|
|
864
|
+
var TextGenerationInputSchema = {
|
|
865
|
+
type: "object",
|
|
866
|
+
properties: {
|
|
867
|
+
model: modelSchema3,
|
|
868
|
+
prompt: TypeReplicateArray({
|
|
869
|
+
type: "string",
|
|
870
|
+
title: "Prompt",
|
|
871
|
+
description: "The prompt to generate text from"
|
|
872
|
+
}),
|
|
873
|
+
maxTokens: {
|
|
874
|
+
type: "number",
|
|
875
|
+
title: "Max Tokens",
|
|
876
|
+
description: "The maximum number of tokens to generate",
|
|
877
|
+
minimum: 1,
|
|
878
|
+
maximum: 4096,
|
|
879
|
+
"x-ui-group": "Configuration"
|
|
880
|
+
},
|
|
881
|
+
temperature: {
|
|
882
|
+
type: "number",
|
|
883
|
+
title: "Temperature",
|
|
884
|
+
description: "The temperature to use for sampling",
|
|
885
|
+
minimum: 0,
|
|
886
|
+
maximum: 2,
|
|
887
|
+
"x-ui-group": "Configuration"
|
|
888
|
+
},
|
|
889
|
+
topP: {
|
|
890
|
+
type: "number",
|
|
891
|
+
title: "Top-p",
|
|
892
|
+
description: "The top-p value to use for sampling",
|
|
893
|
+
minimum: 0,
|
|
894
|
+
maximum: 1,
|
|
895
|
+
"x-ui-group": "Configuration"
|
|
896
|
+
},
|
|
897
|
+
frequencyPenalty: {
|
|
898
|
+
type: "number",
|
|
899
|
+
title: "Frequency Penalty",
|
|
900
|
+
description: "The frequency penalty to use",
|
|
901
|
+
minimum: -2,
|
|
902
|
+
maximum: 2,
|
|
903
|
+
"x-ui-group": "Configuration"
|
|
904
|
+
},
|
|
905
|
+
presencePenalty: {
|
|
906
|
+
type: "number",
|
|
907
|
+
title: "Presence Penalty",
|
|
908
|
+
description: "The presence penalty to use",
|
|
909
|
+
minimum: -2,
|
|
910
|
+
maximum: 2,
|
|
911
|
+
"x-ui-group": "Configuration"
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
required: ["model", "prompt"],
|
|
915
|
+
additionalProperties: false
|
|
916
|
+
};
|
|
917
|
+
var TextGenerationOutputSchema = {
|
|
918
|
+
type: "object",
|
|
919
|
+
properties: {
|
|
920
|
+
text: {
|
|
921
|
+
oneOf: [generatedTextSchema, { type: "array", items: generatedTextSchema }],
|
|
922
|
+
title: generatedTextSchema.title,
|
|
923
|
+
description: generatedTextSchema.description
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
required: ["text"],
|
|
927
|
+
additionalProperties: false
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
class TextGenerationTask extends AiTask {
|
|
931
|
+
static type = "TextGenerationTask";
|
|
932
|
+
static category = "AI Text Model";
|
|
933
|
+
static title = "Text Generation";
|
|
934
|
+
static description = "Generates text from a prompt using language models with configurable parameters";
|
|
935
|
+
static inputSchema() {
|
|
936
|
+
return TextGenerationInputSchema;
|
|
937
|
+
}
|
|
938
|
+
static outputSchema() {
|
|
939
|
+
return TextGenerationOutputSchema;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
TaskRegistry4.registerTask(TextGenerationTask);
|
|
943
|
+
var TextGeneration = (input, config) => {
|
|
944
|
+
return new TextGenerationTask(input, config).run();
|
|
945
|
+
};
|
|
946
|
+
Workflow4.prototype.TextGeneration = CreateWorkflow4(TextGenerationTask);
|
|
947
|
+
// src/task/TextQuestionAnswerTask.ts
|
|
948
|
+
import { CreateWorkflow as CreateWorkflow5, TaskRegistry as TaskRegistry5, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
949
|
+
var contextSchema = {
|
|
950
|
+
type: "string",
|
|
951
|
+
title: "Context",
|
|
952
|
+
description: "The context of the question"
|
|
953
|
+
};
|
|
954
|
+
var questionSchema = {
|
|
955
|
+
type: "string",
|
|
956
|
+
title: "Question",
|
|
957
|
+
description: "The question to answer"
|
|
958
|
+
};
|
|
959
|
+
var textSchema = {
|
|
960
|
+
type: "string",
|
|
961
|
+
title: "Text",
|
|
962
|
+
description: "The generated text"
|
|
963
|
+
};
|
|
964
|
+
var modelSchema4 = TypeReplicateArray(TypeModel("model:TextQuestionAnswerTask"));
|
|
965
|
+
var TextQuestionAnswerInputSchema = {
|
|
966
|
+
type: "object",
|
|
967
|
+
properties: {
|
|
968
|
+
context: TypeReplicateArray(contextSchema),
|
|
969
|
+
question: TypeReplicateArray(questionSchema),
|
|
970
|
+
model: modelSchema4
|
|
971
|
+
},
|
|
972
|
+
required: ["context", "question", "model"],
|
|
973
|
+
additionalProperties: false
|
|
974
|
+
};
|
|
975
|
+
var TextQuestionAnswerOutputSchema = {
|
|
976
|
+
type: "object",
|
|
977
|
+
properties: {
|
|
978
|
+
text: {
|
|
979
|
+
oneOf: [textSchema, { type: "array", items: textSchema }],
|
|
980
|
+
title: textSchema.title,
|
|
981
|
+
description: textSchema.description
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
required: ["text"],
|
|
985
|
+
additionalProperties: false
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
class TextQuestionAnswerTask extends AiTask {
|
|
989
|
+
static type = "TextQuestionAnswerTask";
|
|
990
|
+
static category = "AI Text Model";
|
|
991
|
+
static title = "Text Question Answer";
|
|
992
|
+
static description = "Answers questions based on provided context using language models";
|
|
993
|
+
static inputSchema() {
|
|
994
|
+
return TextQuestionAnswerInputSchema;
|
|
995
|
+
}
|
|
996
|
+
static outputSchema() {
|
|
997
|
+
return TextQuestionAnswerOutputSchema;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
TaskRegistry5.registerTask(TextQuestionAnswerTask);
|
|
1001
|
+
var TextQuestionAnswer = (input, config) => {
|
|
1002
|
+
return new TextQuestionAnswerTask(input, config).run();
|
|
1003
|
+
};
|
|
1004
|
+
Workflow5.prototype.TextQuestionAnswer = CreateWorkflow5(TextQuestionAnswerTask);
|
|
1005
|
+
// src/task/TextRewriterTask.ts
|
|
1006
|
+
import { CreateWorkflow as CreateWorkflow6, TaskRegistry as TaskRegistry6, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
1007
|
+
var modelSchema5 = TypeReplicateArray(TypeModel("model:TextRewriterTask"));
|
|
1008
|
+
var TextRewriterInputSchema = {
|
|
1009
|
+
type: "object",
|
|
1010
|
+
properties: {
|
|
1011
|
+
text: TypeReplicateArray({
|
|
1012
|
+
type: "string",
|
|
1013
|
+
title: "Text",
|
|
1014
|
+
description: "The text to rewrite"
|
|
1015
|
+
}),
|
|
1016
|
+
prompt: TypeReplicateArray({
|
|
1017
|
+
type: "string",
|
|
1018
|
+
title: "Prompt",
|
|
1019
|
+
description: "The prompt to direct the rewriting"
|
|
1020
|
+
}),
|
|
1021
|
+
model: modelSchema5
|
|
1022
|
+
},
|
|
1023
|
+
required: ["text", "prompt", "model"],
|
|
1024
|
+
additionalProperties: false
|
|
1025
|
+
};
|
|
1026
|
+
var TextRewriterOutputSchema = {
|
|
1027
|
+
type: "object",
|
|
1028
|
+
properties: {
|
|
1029
|
+
text: {
|
|
1030
|
+
type: "string",
|
|
1031
|
+
title: "Text",
|
|
1032
|
+
description: "The rewritten text"
|
|
1033
|
+
}
|
|
1034
|
+
},
|
|
1035
|
+
required: ["text"],
|
|
1036
|
+
additionalProperties: false
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
class TextRewriterTask extends AiTask {
|
|
1040
|
+
static type = "TextRewriterTask";
|
|
1041
|
+
static category = "AI Text Model";
|
|
1042
|
+
static title = "Text Rewriter";
|
|
1043
|
+
static description = "Rewrites text according to a given prompt using language models";
|
|
1044
|
+
static inputSchema() {
|
|
1045
|
+
return TextRewriterInputSchema;
|
|
1046
|
+
}
|
|
1047
|
+
static outputSchema() {
|
|
1048
|
+
return TextRewriterOutputSchema;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
TaskRegistry6.registerTask(TextRewriterTask);
|
|
1052
|
+
var TextRewriter = (input, config) => {
|
|
1053
|
+
return new TextRewriterTask(input, config).run();
|
|
1054
|
+
};
|
|
1055
|
+
Workflow6.prototype.TextRewriter = CreateWorkflow6(TextRewriterTask);
|
|
1056
|
+
// src/task/TextSummaryTask.ts
|
|
1057
|
+
import { CreateWorkflow as CreateWorkflow7, TaskRegistry as TaskRegistry7, Workflow as Workflow7 } from "@workglow/task-graph";
|
|
1058
|
+
var modelSchema6 = TypeReplicateArray(TypeModel("model:TextSummaryTask"));
|
|
1059
|
+
var TextSummaryInputSchema = {
|
|
1060
|
+
type: "object",
|
|
1061
|
+
properties: {
|
|
1062
|
+
text: TypeReplicateArray({
|
|
1063
|
+
type: "string",
|
|
1064
|
+
title: "Text",
|
|
1065
|
+
description: "The text to summarize"
|
|
1066
|
+
}),
|
|
1067
|
+
model: modelSchema6
|
|
1068
|
+
},
|
|
1069
|
+
required: ["text", "model"],
|
|
1070
|
+
additionalProperties: false
|
|
1071
|
+
};
|
|
1072
|
+
var TextSummaryOutputSchema = {
|
|
1073
|
+
type: "object",
|
|
1074
|
+
properties: {
|
|
1075
|
+
text: {
|
|
1076
|
+
type: "string",
|
|
1077
|
+
title: "Text",
|
|
1078
|
+
description: "The summarized text"
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1081
|
+
required: ["text"],
|
|
1082
|
+
additionalProperties: false
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
class TextSummaryTask extends AiTask {
|
|
1086
|
+
static type = "TextSummaryTask";
|
|
1087
|
+
static category = "AI Text Model";
|
|
1088
|
+
static title = "Text Summary";
|
|
1089
|
+
static description = "Summarizes text into a shorter form while preserving key information";
|
|
1090
|
+
static inputSchema() {
|
|
1091
|
+
return TextSummaryInputSchema;
|
|
1092
|
+
}
|
|
1093
|
+
static outputSchema() {
|
|
1094
|
+
return TextSummaryOutputSchema;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
TaskRegistry7.registerTask(TextSummaryTask);
|
|
1098
|
+
var TextSummary = async (input, config) => {
|
|
1099
|
+
return new TextSummaryTask(input, config).run();
|
|
1100
|
+
};
|
|
1101
|
+
Workflow7.prototype.TextSummary = CreateWorkflow7(TextSummaryTask);
|
|
1102
|
+
// src/task/TextTranslationTask.ts
|
|
1103
|
+
import { CreateWorkflow as CreateWorkflow8, TaskRegistry as TaskRegistry8, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
1104
|
+
var modelSchema7 = TypeReplicateArray(TypeModel("model:TextTranslationTask"));
|
|
1105
|
+
var translationTextSchema = {
|
|
1106
|
+
type: "string",
|
|
1107
|
+
title: "Text",
|
|
1108
|
+
description: "The translated text"
|
|
1109
|
+
};
|
|
1110
|
+
var TextTranslationInputSchema = {
|
|
1111
|
+
type: "object",
|
|
1112
|
+
properties: {
|
|
1113
|
+
text: TypeReplicateArray({
|
|
1114
|
+
type: "string",
|
|
1115
|
+
title: "Text",
|
|
1116
|
+
description: "The text to translate"
|
|
1117
|
+
}),
|
|
1118
|
+
source_lang: TypeReplicateArray(TypeLanguage({
|
|
1119
|
+
title: "Source Language",
|
|
1120
|
+
description: "The source language"
|
|
1121
|
+
})),
|
|
1122
|
+
target_lang: TypeReplicateArray(TypeLanguage({
|
|
1123
|
+
title: "Target Language",
|
|
1124
|
+
description: "The target language"
|
|
1125
|
+
})),
|
|
1126
|
+
model: modelSchema7
|
|
1127
|
+
},
|
|
1128
|
+
required: ["text", "source_lang", "target_lang", "model"],
|
|
1129
|
+
additionalProperties: false
|
|
1130
|
+
};
|
|
1131
|
+
var TextTranslationOutputSchema = {
|
|
1132
|
+
type: "object",
|
|
1133
|
+
properties: {
|
|
1134
|
+
text: {
|
|
1135
|
+
oneOf: [translationTextSchema, { type: "array", items: translationTextSchema }],
|
|
1136
|
+
title: translationTextSchema.title,
|
|
1137
|
+
description: translationTextSchema.description
|
|
1138
|
+
},
|
|
1139
|
+
target_lang: TypeLanguage({
|
|
1140
|
+
title: "Output Language",
|
|
1141
|
+
description: "The output language"
|
|
1142
|
+
})
|
|
1143
|
+
},
|
|
1144
|
+
required: ["text", "target_lang"],
|
|
1145
|
+
additionalProperties: false
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
class TextTranslationTask extends AiTask {
|
|
1149
|
+
static type = "TextTranslationTask";
|
|
1150
|
+
static category = "AI Text Model";
|
|
1151
|
+
static title = "Text Translation";
|
|
1152
|
+
static description = "Translates text from one language to another using language models";
|
|
1153
|
+
static inputSchema() {
|
|
1154
|
+
return TextTranslationInputSchema;
|
|
1155
|
+
}
|
|
1156
|
+
static outputSchema() {
|
|
1157
|
+
return TextTranslationOutputSchema;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
TaskRegistry8.registerTask(TextTranslationTask);
|
|
1161
|
+
var TextTranslation = (input, config) => {
|
|
1162
|
+
return new TextTranslationTask(input, config).run();
|
|
1163
|
+
};
|
|
1164
|
+
Workflow8.prototype.TextTranslation = CreateWorkflow8(TextTranslationTask);
|
|
1165
|
+
// src/task/VectorSimilarityTask.ts
|
|
1166
|
+
import {
|
|
1167
|
+
ArrayTask,
|
|
1168
|
+
CreateWorkflow as CreateWorkflow9,
|
|
1169
|
+
TaskError,
|
|
1170
|
+
TaskRegistry as TaskRegistry9,
|
|
1171
|
+
Workflow as Workflow9
|
|
1172
|
+
} from "@workglow/task-graph";
|
|
1173
|
+
var SimilarityFn = {
|
|
1174
|
+
COSINE: "cosine",
|
|
1175
|
+
JACCARD: "jaccard",
|
|
1176
|
+
HAMMING: "hamming"
|
|
1177
|
+
};
|
|
1178
|
+
var SimilarityInputSchema = {
|
|
1179
|
+
type: "object",
|
|
1180
|
+
properties: {
|
|
1181
|
+
query: TypedArraySchema({
|
|
1182
|
+
title: "Query",
|
|
1183
|
+
description: "Query vector to compare against"
|
|
1184
|
+
}),
|
|
1185
|
+
input: {
|
|
1186
|
+
type: "array",
|
|
1187
|
+
items: TypedArraySchema({
|
|
1188
|
+
title: "Input",
|
|
1189
|
+
description: "Array of vectors to compare against the query"
|
|
1190
|
+
})
|
|
1191
|
+
},
|
|
1192
|
+
topK: {
|
|
1193
|
+
type: "number",
|
|
1194
|
+
title: "Top K",
|
|
1195
|
+
description: "Number of top results to return",
|
|
1196
|
+
minimum: 1,
|
|
1197
|
+
default: 10
|
|
1198
|
+
},
|
|
1199
|
+
similarity: {
|
|
1200
|
+
type: "string",
|
|
1201
|
+
enum: Object.values(SimilarityFn),
|
|
1202
|
+
title: "Similarity \uD835\uDC53",
|
|
1203
|
+
description: "Similarity function to use for comparisons",
|
|
1204
|
+
default: SimilarityFn.COSINE
|
|
1205
|
+
}
|
|
1206
|
+
},
|
|
1207
|
+
required: ["query", "input", "similarity"],
|
|
1208
|
+
additionalProperties: false
|
|
1209
|
+
};
|
|
1210
|
+
var SimilarityOutputSchema = {
|
|
1211
|
+
type: "object",
|
|
1212
|
+
properties: {
|
|
1213
|
+
output: {
|
|
1214
|
+
type: "array",
|
|
1215
|
+
items: TypedArraySchema({
|
|
1216
|
+
title: "Output",
|
|
1217
|
+
description: "Ranked output vectors"
|
|
1218
|
+
})
|
|
1219
|
+
},
|
|
1220
|
+
score: {
|
|
1221
|
+
type: "array",
|
|
1222
|
+
items: {
|
|
1223
|
+
type: "number",
|
|
1224
|
+
title: "Score",
|
|
1225
|
+
description: "Similarity scores for each output vector"
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
required: ["output", "score"],
|
|
1230
|
+
additionalProperties: false
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
class VectorSimilarityTask extends ArrayTask {
|
|
1234
|
+
static type = "VectorSimilarityTask";
|
|
1235
|
+
static category = "Analysis";
|
|
1236
|
+
static title = "Vector Similarity";
|
|
1237
|
+
static description = "Compares vectors using similarity functions and returns top-K ranked results";
|
|
1238
|
+
static cacheable = true;
|
|
1239
|
+
static inputSchema() {
|
|
1240
|
+
return SimilarityInputSchema;
|
|
1241
|
+
}
|
|
1242
|
+
static outputSchema() {
|
|
1243
|
+
return SimilarityOutputSchema;
|
|
1244
|
+
}
|
|
1245
|
+
async executeReactive({ query, input, similarity, topK }, oldOutput) {
|
|
1246
|
+
let similarities = [];
|
|
1247
|
+
const fns = { cosine };
|
|
1248
|
+
const fnName = similarity;
|
|
1249
|
+
const fn = fns[fnName];
|
|
1250
|
+
for (const embedding of input) {
|
|
1251
|
+
similarities.push({
|
|
1252
|
+
similarity: fn(embedding, query),
|
|
1253
|
+
embedding
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
similarities = similarities.sort((a, b) => b.similarity - a.similarity).slice(0, topK);
|
|
1257
|
+
const outputs = similarities.map((s) => s.embedding);
|
|
1258
|
+
const scores = similarities.map((s) => s.similarity);
|
|
1259
|
+
return {
|
|
1260
|
+
output: outputs,
|
|
1261
|
+
score: scores
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
TaskRegistry9.registerTask(VectorSimilarityTask);
|
|
1266
|
+
var Similarity = (input, config) => {
|
|
1267
|
+
return new VectorSimilarityTask(input, config).run();
|
|
1268
|
+
};
|
|
1269
|
+
Workflow9.prototype.Similarity = CreateWorkflow9(VectorSimilarityTask);
|
|
1270
|
+
function inner(arr1, arr2) {
|
|
1271
|
+
return 1 - arr1.reduce((acc, val, i) => acc + val * arr2[i], 0);
|
|
1272
|
+
}
|
|
1273
|
+
function magnitude(arr) {
|
|
1274
|
+
return Math.sqrt(arr.reduce((acc, val) => acc + val * val, 0));
|
|
1275
|
+
}
|
|
1276
|
+
function cosine(arr1, arr2) {
|
|
1277
|
+
const dotProduct = inner(arr1, arr2);
|
|
1278
|
+
const magnitude1 = magnitude(arr1);
|
|
1279
|
+
const magnitude2 = magnitude(arr2);
|
|
1280
|
+
return 1 - dotProduct / (magnitude1 * magnitude2);
|
|
1281
|
+
}
|
|
1282
|
+
function normalize(vector) {
|
|
1283
|
+
const mag = magnitude(vector);
|
|
1284
|
+
if (mag === 0) {
|
|
1285
|
+
throw new TaskError("Cannot normalize a zero vector.");
|
|
1286
|
+
}
|
|
1287
|
+
const normalized = vector.map((val) => Number(val) / mag);
|
|
1288
|
+
if (vector instanceof Float64Array) {
|
|
1289
|
+
return new Float64Array(normalized);
|
|
1290
|
+
}
|
|
1291
|
+
if (vector instanceof Float32Array) {
|
|
1292
|
+
return new Float32Array(normalized);
|
|
1293
|
+
}
|
|
1294
|
+
return new Float32Array(normalized);
|
|
1295
|
+
}
|
|
1296
|
+
// src/model/storage/IndexedDbModelRepository.ts
|
|
1297
|
+
import { IndexedDbTabularRepository } from "@workglow/storage";
|
|
1298
|
+
class IndexedDbModelRepository extends ModelRepository {
|
|
1299
|
+
modelTabularRepository;
|
|
1300
|
+
task2ModelTabularRepository;
|
|
1301
|
+
type = "IndexedDbModelRepository";
|
|
1302
|
+
constructor(tableModels = "models", tableTask2Models = "task2models") {
|
|
1303
|
+
super();
|
|
1304
|
+
this.modelTabularRepository = new IndexedDbTabularRepository(tableModels, ModelSchema, ModelPrimaryKeyNames);
|
|
1305
|
+
this.task2ModelTabularRepository = new IndexedDbTabularRepository(tableTask2Models, Task2ModelSchema, Task2ModelPrimaryKeyNames, ["model"]);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
export {
|
|
1309
|
+
setGlobalModelRepository,
|
|
1310
|
+
setAiProviderRegistry,
|
|
1311
|
+
normalize,
|
|
1312
|
+
magnitude,
|
|
1313
|
+
inner,
|
|
1314
|
+
getGlobalModelRepository,
|
|
1315
|
+
getAiProviderRegistry,
|
|
1316
|
+
VectorSimilarityTask,
|
|
1317
|
+
TypedArraySchema,
|
|
1318
|
+
TypeReplicateArray,
|
|
1319
|
+
TypeModel,
|
|
1320
|
+
TypeLanguage,
|
|
1321
|
+
TextTranslationTask,
|
|
1322
|
+
TextTranslationOutputSchema,
|
|
1323
|
+
TextTranslationInputSchema,
|
|
1324
|
+
TextTranslation,
|
|
1325
|
+
TextSummaryTask,
|
|
1326
|
+
TextSummaryOutputSchema,
|
|
1327
|
+
TextSummaryInputSchema,
|
|
1328
|
+
TextSummary,
|
|
1329
|
+
TextRewriterTask,
|
|
1330
|
+
TextRewriterOutputSchema,
|
|
1331
|
+
TextRewriterInputSchema,
|
|
1332
|
+
TextRewriter,
|
|
1333
|
+
TextQuestionAnswerTask,
|
|
1334
|
+
TextQuestionAnswerOutputSchema,
|
|
1335
|
+
TextQuestionAnswerInputSchema,
|
|
1336
|
+
TextQuestionAnswer,
|
|
1337
|
+
TextGenerationTask,
|
|
1338
|
+
TextGenerationOutputSchema,
|
|
1339
|
+
TextGenerationInputSchema,
|
|
1340
|
+
TextGeneration,
|
|
1341
|
+
TextFragment,
|
|
1342
|
+
TextEmbeddingTask,
|
|
1343
|
+
TextEmbeddingOutputSchema,
|
|
1344
|
+
TextEmbeddingInputSchema,
|
|
1345
|
+
TextEmbedding,
|
|
1346
|
+
Task2ModelSchema,
|
|
1347
|
+
Task2ModelPrimaryKeyNames,
|
|
1348
|
+
TableFragment,
|
|
1349
|
+
SimilarityFn,
|
|
1350
|
+
Similarity,
|
|
1351
|
+
ModelSchema,
|
|
1352
|
+
ModelRepository,
|
|
1353
|
+
ModelPrimaryKeyNames,
|
|
1354
|
+
IndexedDbModelRepository,
|
|
1355
|
+
InMemoryModelRepository,
|
|
1356
|
+
ImageFragment,
|
|
1357
|
+
DownloadModelTask,
|
|
1358
|
+
DownloadModel,
|
|
1359
|
+
DocumentSplitterTask,
|
|
1360
|
+
DocumentSplitter,
|
|
1361
|
+
DocumentSection,
|
|
1362
|
+
DocumentConverterText,
|
|
1363
|
+
DocumentConverterMarkdown,
|
|
1364
|
+
DocumentBaseFragment,
|
|
1365
|
+
Document,
|
|
1366
|
+
AiTask,
|
|
1367
|
+
AiProviderRegistry,
|
|
1368
|
+
AiJob
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1371
|
+
//# debugId=CB10B0DB935086A564756E2164756E21
|