@workglow/ai 0.0.65 → 0.0.67

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/browser.js CHANGED
@@ -21,6 +21,9 @@ class ModelRepository {
21
21
  this.modelTabularRepository = modelTabularRepository;
22
22
  }
23
23
  events = new EventEmitter;
24
+ async setupDatabase() {
25
+ await this.modelTabularRepository.setupDatabase?.();
26
+ }
24
27
  on(name, fn) {
25
28
  this.events.on(name, fn);
26
29
  }
@@ -813,9 +816,86 @@ var DownloadModel = (input, config) => {
813
816
  return new DownloadModelTask(input, config).run();
814
817
  };
815
818
  Workflow2.prototype.DownloadModel = CreateWorkflow2(DownloadModelTask);
816
- // src/task/TextEmbeddingTask.ts
819
+ // src/task/TextClassifierTask.ts
817
820
  import { CreateWorkflow as CreateWorkflow3, TaskRegistry as TaskRegistry3, Workflow as Workflow3 } from "@workglow/task-graph";
818
- var modelSchema2 = TypeReplicateArray(TypeModel("model:TextEmbeddingTask"));
821
+ var modelSchema2 = TypeReplicateArray(TypeModel("model:TextClassifierTask"));
822
+ var TextClassifierInputSchema = {
823
+ type: "object",
824
+ properties: {
825
+ text: TypeReplicateArray({
826
+ type: "string",
827
+ title: "Text",
828
+ description: "The text to classify"
829
+ }),
830
+ maxCategories: {
831
+ oneOf: [
832
+ {
833
+ type: "number",
834
+ minimum: 1,
835
+ maximum: 1000
836
+ },
837
+ {
838
+ type: "null"
839
+ }
840
+ ],
841
+ title: "Max Categories",
842
+ description: "The maximum number of categories to return"
843
+ },
844
+ model: modelSchema2
845
+ },
846
+ required: ["text", "model"],
847
+ additionalProperties: false
848
+ };
849
+ var TextClassifierOutputSchema = {
850
+ type: "object",
851
+ properties: {
852
+ categories: {
853
+ type: "array",
854
+ items: {
855
+ type: "object",
856
+ properties: {
857
+ label: {
858
+ type: "string",
859
+ title: "Label",
860
+ description: "The name of the category"
861
+ },
862
+ score: {
863
+ type: "number",
864
+ title: "Score",
865
+ description: "The confidence score for this category"
866
+ }
867
+ },
868
+ required: ["label", "score"],
869
+ additionalProperties: false
870
+ },
871
+ title: "Categories",
872
+ description: "The classification categories with their scores"
873
+ }
874
+ },
875
+ required: ["categories"],
876
+ additionalProperties: false
877
+ };
878
+
879
+ class TextClassifierTask extends AiTask {
880
+ static type = "TextClassifierTask";
881
+ static category = "AI Text Model";
882
+ static title = "Text Classifier";
883
+ static description = "Classifies text into predefined categories using language models";
884
+ static inputSchema() {
885
+ return TextClassifierInputSchema;
886
+ }
887
+ static outputSchema() {
888
+ return TextClassifierOutputSchema;
889
+ }
890
+ }
891
+ TaskRegistry3.registerTask(TextClassifierTask);
892
+ var TextClassifier = (input, config) => {
893
+ return new TextClassifierTask(input, config).run();
894
+ };
895
+ Workflow3.prototype.TextClassifier = CreateWorkflow3(TextClassifierTask);
896
+ // src/task/TextEmbeddingTask.ts
897
+ import { CreateWorkflow as CreateWorkflow4, TaskRegistry as TaskRegistry4, Workflow as Workflow4 } from "@workglow/task-graph";
898
+ var modelSchema3 = TypeReplicateArray(TypeModel("model:TextEmbeddingTask"));
819
899
  var TextEmbeddingInputSchema = {
820
900
  type: "object",
821
901
  properties: {
@@ -824,7 +904,7 @@ var TextEmbeddingInputSchema = {
824
904
  title: "Text",
825
905
  description: "The text to embed"
826
906
  }),
827
- model: modelSchema2
907
+ model: modelSchema3
828
908
  },
829
909
  required: ["text", "model"],
830
910
  additionalProperties: false
@@ -853,23 +933,23 @@ class TextEmbeddingTask extends AiTask {
853
933
  return TextEmbeddingOutputSchema;
854
934
  }
855
935
  }
856
- TaskRegistry3.registerTask(TextEmbeddingTask);
936
+ TaskRegistry4.registerTask(TextEmbeddingTask);
857
937
  var TextEmbedding = async (input, config) => {
858
938
  return new TextEmbeddingTask(input, config).run();
859
939
  };
860
- Workflow3.prototype.TextEmbedding = CreateWorkflow3(TextEmbeddingTask);
940
+ Workflow4.prototype.TextEmbedding = CreateWorkflow4(TextEmbeddingTask);
861
941
  // src/task/TextGenerationTask.ts
862
- import { CreateWorkflow as CreateWorkflow4, TaskRegistry as TaskRegistry4, Workflow as Workflow4 } from "@workglow/task-graph";
942
+ import { CreateWorkflow as CreateWorkflow5, TaskRegistry as TaskRegistry5, Workflow as Workflow5 } from "@workglow/task-graph";
863
943
  var generatedTextSchema = {
864
944
  type: "string",
865
945
  title: "Text",
866
946
  description: "The generated text"
867
947
  };
868
- var modelSchema3 = TypeReplicateArray(TypeModel("model:TextGenerationTask"));
948
+ var modelSchema4 = TypeReplicateArray(TypeModel("model:TextGenerationTask"));
869
949
  var TextGenerationInputSchema = {
870
950
  type: "object",
871
951
  properties: {
872
- model: modelSchema3,
952
+ model: modelSchema4,
873
953
  prompt: TypeReplicateArray({
874
954
  type: "string",
875
955
  title: "Prompt",
@@ -944,13 +1024,90 @@ class TextGenerationTask extends AiTask {
944
1024
  return TextGenerationOutputSchema;
945
1025
  }
946
1026
  }
947
- TaskRegistry4.registerTask(TextGenerationTask);
1027
+ TaskRegistry5.registerTask(TextGenerationTask);
948
1028
  var TextGeneration = (input, config) => {
949
1029
  return new TextGenerationTask(input, config).run();
950
1030
  };
951
- Workflow4.prototype.TextGeneration = CreateWorkflow4(TextGenerationTask);
1031
+ Workflow5.prototype.TextGeneration = CreateWorkflow5(TextGenerationTask);
1032
+ // src/task/TextLanguageDetectionTask.ts
1033
+ import { CreateWorkflow as CreateWorkflow6, TaskRegistry as TaskRegistry6, Workflow as Workflow6 } from "@workglow/task-graph";
1034
+ var modelSchema5 = TypeReplicateArray(TypeModel("model:TextLanguageDetectionTask"));
1035
+ var TextLanguageDetectionInputSchema = {
1036
+ type: "object",
1037
+ properties: {
1038
+ text: TypeReplicateArray({
1039
+ type: "string",
1040
+ title: "Text",
1041
+ description: "The text to detect the language of"
1042
+ }),
1043
+ maxLanguages: {
1044
+ oneOf: [
1045
+ {
1046
+ type: "number",
1047
+ minimum: 1,
1048
+ maximum: 1000
1049
+ },
1050
+ {
1051
+ type: "null"
1052
+ }
1053
+ ],
1054
+ title: "Max Languages",
1055
+ description: "The maximum number of languages to return"
1056
+ },
1057
+ model: modelSchema5
1058
+ },
1059
+ required: ["text", "model"],
1060
+ additionalProperties: false
1061
+ };
1062
+ var TextLanguageDetectionOutputSchema = {
1063
+ type: "object",
1064
+ properties: {
1065
+ languages: {
1066
+ type: "array",
1067
+ items: {
1068
+ type: "object",
1069
+ properties: {
1070
+ language: {
1071
+ type: "string",
1072
+ title: "Language",
1073
+ description: "The language"
1074
+ },
1075
+ score: {
1076
+ type: "number",
1077
+ title: "Score",
1078
+ description: "The confidence score for this language"
1079
+ }
1080
+ },
1081
+ required: ["language", "score"],
1082
+ additionalProperties: false
1083
+ },
1084
+ title: "Languages",
1085
+ description: "The languages with their scores"
1086
+ }
1087
+ },
1088
+ required: ["languages"],
1089
+ additionalProperties: false
1090
+ };
1091
+
1092
+ class TextLanguageDetectionTask extends AiTask {
1093
+ static type = "TextLanguageDetectionTask";
1094
+ static category = "AI Text Model";
1095
+ static title = "Language Detection";
1096
+ static description = "Detects the language of text using language models";
1097
+ static inputSchema() {
1098
+ return TextLanguageDetectionInputSchema;
1099
+ }
1100
+ static outputSchema() {
1101
+ return TextLanguageDetectionOutputSchema;
1102
+ }
1103
+ }
1104
+ TaskRegistry6.registerTask(TextLanguageDetectionTask);
1105
+ var TextLanguageDetection = (input, config) => {
1106
+ return new TextLanguageDetectionTask(input, config).run();
1107
+ };
1108
+ Workflow6.prototype.TextLanguageDetection = CreateWorkflow6(TextLanguageDetectionTask);
952
1109
  // src/task/TextQuestionAnswerTask.ts
953
- import { CreateWorkflow as CreateWorkflow5, TaskRegistry as TaskRegistry5, Workflow as Workflow5 } from "@workglow/task-graph";
1110
+ import { CreateWorkflow as CreateWorkflow7, TaskRegistry as TaskRegistry7, Workflow as Workflow7 } from "@workglow/task-graph";
954
1111
  var contextSchema = {
955
1112
  type: "string",
956
1113
  title: "Context",
@@ -966,13 +1123,13 @@ var textSchema = {
966
1123
  title: "Text",
967
1124
  description: "The generated text"
968
1125
  };
969
- var modelSchema4 = TypeReplicateArray(TypeModel("model:TextQuestionAnswerTask"));
1126
+ var modelSchema6 = TypeReplicateArray(TypeModel("model:TextQuestionAnswerTask"));
970
1127
  var TextQuestionAnswerInputSchema = {
971
1128
  type: "object",
972
1129
  properties: {
973
1130
  context: TypeReplicateArray(contextSchema),
974
1131
  question: TypeReplicateArray(questionSchema),
975
- model: modelSchema4
1132
+ model: modelSchema6
976
1133
  },
977
1134
  required: ["context", "question", "model"],
978
1135
  additionalProperties: false
@@ -1002,14 +1159,14 @@ class TextQuestionAnswerTask extends AiTask {
1002
1159
  return TextQuestionAnswerOutputSchema;
1003
1160
  }
1004
1161
  }
1005
- TaskRegistry5.registerTask(TextQuestionAnswerTask);
1162
+ TaskRegistry7.registerTask(TextQuestionAnswerTask);
1006
1163
  var TextQuestionAnswer = (input, config) => {
1007
1164
  return new TextQuestionAnswerTask(input, config).run();
1008
1165
  };
1009
- Workflow5.prototype.TextQuestionAnswer = CreateWorkflow5(TextQuestionAnswerTask);
1166
+ Workflow7.prototype.TextQuestionAnswer = CreateWorkflow7(TextQuestionAnswerTask);
1010
1167
  // src/task/TextRewriterTask.ts
1011
- import { CreateWorkflow as CreateWorkflow6, TaskRegistry as TaskRegistry6, Workflow as Workflow6 } from "@workglow/task-graph";
1012
- var modelSchema5 = TypeReplicateArray(TypeModel("model:TextRewriterTask"));
1168
+ import { CreateWorkflow as CreateWorkflow8, TaskRegistry as TaskRegistry8, Workflow as Workflow8 } from "@workglow/task-graph";
1169
+ var modelSchema7 = TypeReplicateArray(TypeModel("model:TextRewriterTask"));
1013
1170
  var TextRewriterInputSchema = {
1014
1171
  type: "object",
1015
1172
  properties: {
@@ -1023,7 +1180,7 @@ var TextRewriterInputSchema = {
1023
1180
  title: "Prompt",
1024
1181
  description: "The prompt to direct the rewriting"
1025
1182
  }),
1026
- model: modelSchema5
1183
+ model: modelSchema7
1027
1184
  },
1028
1185
  required: ["text", "prompt", "model"],
1029
1186
  additionalProperties: false
@@ -1053,14 +1210,14 @@ class TextRewriterTask extends AiTask {
1053
1210
  return TextRewriterOutputSchema;
1054
1211
  }
1055
1212
  }
1056
- TaskRegistry6.registerTask(TextRewriterTask);
1213
+ TaskRegistry8.registerTask(TextRewriterTask);
1057
1214
  var TextRewriter = (input, config) => {
1058
1215
  return new TextRewriterTask(input, config).run();
1059
1216
  };
1060
- Workflow6.prototype.TextRewriter = CreateWorkflow6(TextRewriterTask);
1217
+ Workflow8.prototype.TextRewriter = CreateWorkflow8(TextRewriterTask);
1061
1218
  // src/task/TextSummaryTask.ts
1062
- import { CreateWorkflow as CreateWorkflow7, TaskRegistry as TaskRegistry7, Workflow as Workflow7 } from "@workglow/task-graph";
1063
- var modelSchema6 = TypeReplicateArray(TypeModel("model:TextSummaryTask"));
1219
+ import { CreateWorkflow as CreateWorkflow9, TaskRegistry as TaskRegistry9, Workflow as Workflow9 } from "@workglow/task-graph";
1220
+ var modelSchema8 = TypeReplicateArray(TypeModel("model:TextSummaryTask"));
1064
1221
  var TextSummaryInputSchema = {
1065
1222
  type: "object",
1066
1223
  properties: {
@@ -1069,7 +1226,7 @@ var TextSummaryInputSchema = {
1069
1226
  title: "Text",
1070
1227
  description: "The text to summarize"
1071
1228
  }),
1072
- model: modelSchema6
1229
+ model: modelSchema8
1073
1230
  },
1074
1231
  required: ["text", "model"],
1075
1232
  additionalProperties: false
@@ -1099,14 +1256,14 @@ class TextSummaryTask extends AiTask {
1099
1256
  return TextSummaryOutputSchema;
1100
1257
  }
1101
1258
  }
1102
- TaskRegistry7.registerTask(TextSummaryTask);
1259
+ TaskRegistry9.registerTask(TextSummaryTask);
1103
1260
  var TextSummary = async (input, config) => {
1104
1261
  return new TextSummaryTask(input, config).run();
1105
1262
  };
1106
- Workflow7.prototype.TextSummary = CreateWorkflow7(TextSummaryTask);
1263
+ Workflow9.prototype.TextSummary = CreateWorkflow9(TextSummaryTask);
1107
1264
  // src/task/TextTranslationTask.ts
1108
- import { CreateWorkflow as CreateWorkflow8, TaskRegistry as TaskRegistry8, Workflow as Workflow8 } from "@workglow/task-graph";
1109
- var modelSchema7 = TypeReplicateArray(TypeModel("model:TextTranslationTask"));
1265
+ import { CreateWorkflow as CreateWorkflow10, TaskRegistry as TaskRegistry10, Workflow as Workflow10 } from "@workglow/task-graph";
1266
+ var modelSchema9 = TypeReplicateArray(TypeModel("model:TextTranslationTask"));
1110
1267
  var translationTextSchema = {
1111
1268
  type: "string",
1112
1269
  title: "Text",
@@ -1132,7 +1289,7 @@ var TextTranslationInputSchema = {
1132
1289
  minLength: 2,
1133
1290
  maxLength: 2
1134
1291
  })),
1135
- model: modelSchema7
1292
+ model: modelSchema9
1136
1293
  },
1137
1294
  required: ["text", "source_lang", "target_lang", "model"],
1138
1295
  additionalProperties: false
@@ -1168,18 +1325,56 @@ class TextTranslationTask extends AiTask {
1168
1325
  return TextTranslationOutputSchema;
1169
1326
  }
1170
1327
  }
1171
- TaskRegistry8.registerTask(TextTranslationTask);
1328
+ TaskRegistry10.registerTask(TextTranslationTask);
1172
1329
  var TextTranslation = (input, config) => {
1173
1330
  return new TextTranslationTask(input, config).run();
1174
1331
  };
1175
- Workflow8.prototype.TextTranslation = CreateWorkflow8(TextTranslationTask);
1332
+ Workflow10.prototype.TextTranslation = CreateWorkflow10(TextTranslationTask);
1333
+ // src/task/UnloadModelTask.ts
1334
+ import { CreateWorkflow as CreateWorkflow11, TaskRegistry as TaskRegistry11, Workflow as Workflow11 } from "@workglow/task-graph";
1335
+ var modelSchema10 = TypeReplicateArray(TypeModel("model"));
1336
+ var UnloadModelInputSchema = {
1337
+ type: "object",
1338
+ properties: {
1339
+ model: modelSchema10
1340
+ },
1341
+ required: ["model"],
1342
+ additionalProperties: false
1343
+ };
1344
+ var UnloadModelOutputSchema = {
1345
+ type: "object",
1346
+ properties: {
1347
+ model: modelSchema10
1348
+ },
1349
+ required: ["model"],
1350
+ additionalProperties: false
1351
+ };
1352
+
1353
+ class UnloadModelTask extends AiTask {
1354
+ static type = "UnloadModelTask";
1355
+ static category = "Hidden";
1356
+ static title = "Unload Model";
1357
+ static description = "Unloads and clears cached AI models from memory and storage";
1358
+ static inputSchema() {
1359
+ return UnloadModelInputSchema;
1360
+ }
1361
+ static outputSchema() {
1362
+ return UnloadModelOutputSchema;
1363
+ }
1364
+ static cacheable = false;
1365
+ }
1366
+ TaskRegistry11.registerTask(UnloadModelTask);
1367
+ var UnloadModel = (input, config) => {
1368
+ return new UnloadModelTask(input, config).run();
1369
+ };
1370
+ Workflow11.prototype.UnloadModel = CreateWorkflow11(UnloadModelTask);
1176
1371
  // src/task/VectorSimilarityTask.ts
1177
1372
  import {
1178
1373
  ArrayTask,
1179
- CreateWorkflow as CreateWorkflow9,
1374
+ CreateWorkflow as CreateWorkflow12,
1180
1375
  TaskError,
1181
- TaskRegistry as TaskRegistry9,
1182
- Workflow as Workflow9
1376
+ TaskRegistry as TaskRegistry12,
1377
+ Workflow as Workflow12
1183
1378
  } from "@workglow/task-graph";
1184
1379
  var SimilarityFn = {
1185
1380
  COSINE: "cosine",
@@ -1273,11 +1468,11 @@ class VectorSimilarityTask extends ArrayTask {
1273
1468
  };
1274
1469
  }
1275
1470
  }
1276
- TaskRegistry9.registerTask(VectorSimilarityTask);
1471
+ TaskRegistry12.registerTask(VectorSimilarityTask);
1277
1472
  var Similarity = (input, config) => {
1278
1473
  return new VectorSimilarityTask(input, config).run();
1279
1474
  };
1280
- Workflow9.prototype.Similarity = CreateWorkflow9(VectorSimilarityTask);
1475
+ Workflow12.prototype.Similarity = CreateWorkflow12(VectorSimilarityTask);
1281
1476
  function inner(arr1, arr2) {
1282
1477
  return 1 - arr1.reduce((acc, val, i) => acc + val * arr2[i], 0);
1283
1478
  }
@@ -1313,6 +1508,8 @@ export {
1313
1508
  getGlobalModelRepository,
1314
1509
  getAiProviderRegistry,
1315
1510
  VectorSimilarityTask,
1511
+ UnloadModelTask,
1512
+ UnloadModel,
1316
1513
  TypedArraySchema,
1317
1514
  TypeReplicateArray,
1318
1515
  TypeModelByDetail,
@@ -1335,6 +1532,10 @@ export {
1335
1532
  TextQuestionAnswerOutputSchema,
1336
1533
  TextQuestionAnswerInputSchema,
1337
1534
  TextQuestionAnswer,
1535
+ TextLanguageDetectionTask,
1536
+ TextLanguageDetectionOutputSchema,
1537
+ TextLanguageDetectionInputSchema,
1538
+ TextLanguageDetection,
1338
1539
  TextGenerationTask,
1339
1540
  TextGenerationOutputSchema,
1340
1541
  TextGenerationInputSchema,
@@ -1344,6 +1545,10 @@ export {
1344
1545
  TextEmbeddingOutputSchema,
1345
1546
  TextEmbeddingInputSchema,
1346
1547
  TextEmbedding,
1548
+ TextClassifierTask,
1549
+ TextClassifierOutputSchema,
1550
+ TextClassifierInputSchema,
1551
+ TextClassifier,
1347
1552
  TableFragment,
1348
1553
  SimilarityFn,
1349
1554
  Similarity,
@@ -1367,4 +1572,4 @@ export {
1367
1572
  AiJob
1368
1573
  };
1369
1574
 
1370
- //# debugId=3ACBB3EC1C7457F064756E2164756E21
1575
+ //# debugId=7179DF21BC09BC6364756E2164756E21