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