@workglow/ai 0.0.110 → 0.0.111

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
@@ -420,7 +420,7 @@ class AiProvider {
420
420
  }
421
421
  }
422
422
  // src/task/index.ts
423
- import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
423
+ import { TaskRegistry } from "@workglow/task-graph";
424
424
 
425
425
  // src/task/BackgroundRemovalTask.ts
426
426
  import { CreateWorkflow, Workflow } from "@workglow/task-graph";
@@ -5261,8 +5261,78 @@ var textRewriter = (input, config) => {
5261
5261
  };
5262
5262
  Workflow37.prototype.textRewriter = CreateWorkflow37(TextRewriterTask);
5263
5263
 
5264
+ // src/task/TextTranslationTask.ts
5265
+ import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
5266
+ var modelSchema27 = TypeModel("model:TextTranslationTask");
5267
+ var translationTextSchema = TypeSingleOrArray({
5268
+ type: "string",
5269
+ title: "Text",
5270
+ description: "The translated text",
5271
+ "x-stream": "replace"
5272
+ });
5273
+ var TextTranslationInputSchema = {
5274
+ type: "object",
5275
+ properties: {
5276
+ text: TypeSingleOrArray({
5277
+ type: "string",
5278
+ title: "Text",
5279
+ description: "The text to translate"
5280
+ }),
5281
+ source_lang: TypeLanguage({
5282
+ title: "Source Language",
5283
+ description: "The source language",
5284
+ minLength: 2,
5285
+ maxLength: 2
5286
+ }),
5287
+ target_lang: TypeLanguage({
5288
+ title: "Target Language",
5289
+ description: "The target language",
5290
+ minLength: 2,
5291
+ maxLength: 2
5292
+ }),
5293
+ model: modelSchema27
5294
+ },
5295
+ required: ["text", "source_lang", "target_lang", "model"],
5296
+ additionalProperties: false
5297
+ };
5298
+ var TextTranslationOutputSchema = {
5299
+ type: "object",
5300
+ properties: {
5301
+ text: translationTextSchema,
5302
+ target_lang: TypeLanguage({
5303
+ title: "Output Language",
5304
+ description: "The output language",
5305
+ minLength: 2,
5306
+ maxLength: 2
5307
+ })
5308
+ },
5309
+ required: ["text", "target_lang"],
5310
+ additionalProperties: false
5311
+ };
5312
+
5313
+ class TextTranslationTask extends StreamingAiTask {
5314
+ static type = "TextTranslationTask";
5315
+ static category = "AI Text Model";
5316
+ static title = "Text Translation";
5317
+ static description = "Translates text from one language to another using language models";
5318
+ static inputSchema() {
5319
+ return TextTranslationInputSchema;
5320
+ }
5321
+ static outputSchema() {
5322
+ return TextTranslationOutputSchema;
5323
+ }
5324
+ }
5325
+ var textTranslation = (input, config) => {
5326
+ return new TextTranslationTask({}, config).run(input);
5327
+ };
5328
+ Workflow38.prototype.textTranslation = CreateWorkflow38(TextTranslationTask);
5329
+
5264
5330
  // src/task/ToolCallingTask.ts
5265
- import { CreateWorkflow as CreateWorkflow38, TaskRegistry, Workflow as Workflow38 } from "@workglow/task-graph";
5331
+ import {
5332
+ CreateWorkflow as CreateWorkflow39,
5333
+ getTaskConstructors,
5334
+ Workflow as Workflow39
5335
+ } from "@workglow/task-graph";
5266
5336
  import { getLogger } from "@workglow/util";
5267
5337
  function buildToolDescription(tool) {
5268
5338
  let desc = tool.description;
@@ -5291,11 +5361,12 @@ function filterValidToolCalls(toolCalls, allowedTools) {
5291
5361
  }
5292
5362
  return filtered;
5293
5363
  }
5294
- function taskTypesToTools(taskNames) {
5364
+ function taskTypesToTools(taskNames, registry) {
5365
+ const constructors = getTaskConstructors(registry);
5295
5366
  return taskNames.map((name) => {
5296
- const ctor = TaskRegistry.all.get(name);
5367
+ const ctor = constructors.get(name);
5297
5368
  if (!ctor) {
5298
- throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in TaskRegistry`);
5369
+ throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
5299
5370
  }
5300
5371
  return {
5301
5372
  name: ctor.type,
@@ -5334,11 +5405,11 @@ var ToolDefinitionSchema = {
5334
5405
  required: ["name", "description", "inputSchema"],
5335
5406
  additionalProperties: false
5336
5407
  };
5337
- var modelSchema27 = TypeModel("model:ToolCallingTask");
5408
+ var modelSchema28 = TypeModel("model:ToolCallingTask");
5338
5409
  var ToolCallingInputSchema = {
5339
5410
  type: "object",
5340
5411
  properties: {
5341
- model: modelSchema27,
5412
+ model: modelSchema28,
5342
5413
  prompt: TypeSingleOrArray({
5343
5414
  type: "string",
5344
5415
  title: "Prompt",
@@ -5351,9 +5422,15 @@ var ToolCallingInputSchema = {
5351
5422
  },
5352
5423
  tools: {
5353
5424
  type: "array",
5425
+ format: "tasks",
5354
5426
  title: "Tools",
5355
5427
  description: "Tool definitions available for the model to call",
5356
- items: ToolDefinitionSchema
5428
+ items: {
5429
+ oneOf: [
5430
+ { type: "string", format: "tasks", description: "Task type name" },
5431
+ ToolDefinitionSchema
5432
+ ]
5433
+ }
5357
5434
  },
5358
5435
  toolChoice: {
5359
5436
  type: "string",
@@ -5416,73 +5493,7 @@ class ToolCallingTask extends StreamingAiTask {
5416
5493
  var toolCalling = (input, config) => {
5417
5494
  return new ToolCallingTask({}, config).run(input);
5418
5495
  };
5419
- Workflow38.prototype.toolCalling = CreateWorkflow38(ToolCallingTask);
5420
-
5421
- // src/task/TextTranslationTask.ts
5422
- import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
5423
- var modelSchema28 = TypeModel("model:TextTranslationTask");
5424
- var translationTextSchema = TypeSingleOrArray({
5425
- type: "string",
5426
- title: "Text",
5427
- description: "The translated text",
5428
- "x-stream": "replace"
5429
- });
5430
- var TextTranslationInputSchema = {
5431
- type: "object",
5432
- properties: {
5433
- text: TypeSingleOrArray({
5434
- type: "string",
5435
- title: "Text",
5436
- description: "The text to translate"
5437
- }),
5438
- source_lang: TypeLanguage({
5439
- title: "Source Language",
5440
- description: "The source language",
5441
- minLength: 2,
5442
- maxLength: 2
5443
- }),
5444
- target_lang: TypeLanguage({
5445
- title: "Target Language",
5446
- description: "The target language",
5447
- minLength: 2,
5448
- maxLength: 2
5449
- }),
5450
- model: modelSchema28
5451
- },
5452
- required: ["text", "source_lang", "target_lang", "model"],
5453
- additionalProperties: false
5454
- };
5455
- var TextTranslationOutputSchema = {
5456
- type: "object",
5457
- properties: {
5458
- text: translationTextSchema,
5459
- target_lang: TypeLanguage({
5460
- title: "Output Language",
5461
- description: "The output language",
5462
- minLength: 2,
5463
- maxLength: 2
5464
- })
5465
- },
5466
- required: ["text", "target_lang"],
5467
- additionalProperties: false
5468
- };
5469
-
5470
- class TextTranslationTask extends StreamingAiTask {
5471
- static type = "TextTranslationTask";
5472
- static category = "AI Text Model";
5473
- static title = "Text Translation";
5474
- static description = "Translates text from one language to another using language models";
5475
- static inputSchema() {
5476
- return TextTranslationInputSchema;
5477
- }
5478
- static outputSchema() {
5479
- return TextTranslationOutputSchema;
5480
- }
5481
- }
5482
- var textTranslation = (input, config) => {
5483
- return new TextTranslationTask({}, config).run(input);
5484
- };
5485
- Workflow39.prototype.textTranslation = CreateWorkflow39(TextTranslationTask);
5496
+ Workflow39.prototype.toolCalling = CreateWorkflow39(ToolCallingTask);
5486
5497
 
5487
5498
  // src/task/TopicSegmenterTask.ts
5488
5499
  import {
@@ -6148,7 +6159,7 @@ var registerAiTasks = () => {
6148
6159
  VectorQuantizeTask,
6149
6160
  VectorSimilarityTask
6150
6161
  ];
6151
- tasks.map(TaskRegistry2.registerTask);
6162
+ tasks.map(TaskRegistry.registerTask);
6152
6163
  return tasks;
6153
6164
  };
6154
6165
  export {
@@ -6217,6 +6228,7 @@ export {
6217
6228
  TypeBoundingBox,
6218
6229
  TypeAudioInput,
6219
6230
  TopicSegmenterTask,
6231
+ ToolDefinitionSchema,
6220
6232
  ToolCallingTask,
6221
6233
  ToolCallingOutputSchema,
6222
6234
  ToolCallingInputSchema,
@@ -6322,4 +6334,4 @@ export {
6322
6334
  AiJob
6323
6335
  };
6324
6336
 
6325
- //# debugId=E73E8DF34D71240E64756E2164756E21
6337
+ //# debugId=0AADE5DC48AE458464756E2164756E21