Skip to content

Commit

Permalink
fix: fix some things that should have been caught in last pr
Browse files Browse the repository at this point in the history
  • Loading branch information
sroussey committed Jan 31, 2025
1 parent 581de0a commit a533671
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/ai/src/task/TextTranslationTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export class TextTranslationTask extends JobQueueLlmTask {
declare defaults: Partial<TextTranslationTaskInput>;
static readonly type = "TextTranslationTask";
static readonly category = "Text Model";
async validateItem(valueType: string, item: any) {
if (valueType == "language") {
return typeof item == "string" && item.length == 2;
}
return super.validateItem(valueType, item);
}
}
TaskRegistry.registerTask(TextTranslationTask);

Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/task/DebugLogTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ export class DebugLogTask extends OutputTask {
this.runOutputData.output = this.runInputData.message;
return this.runOutputData;
}

async validateItem(valueType: string, item: any) {
if (valueType == "log_level") {
return log_levels.includes(item);
}
return super.validateItem(valueType, item);
}
}

TaskRegistry.registerTask(DebugLogTask);

export const DebugLog = (input: DebugLogTaskInput) => {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/task/base/ArrayTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ export function arrayTaskFactory<
const { subtasks, ...result } = super.toDependencyJSON();
return result;
}

async validateItem(valueType: string, item: any) {
return true; // let children validate
}
}

TaskRegistry.registerTask(ArrayTask);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/task/base/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ export abstract class TaskBase {
*/
async validateItem(valueType: string, item: any) {
switch (valueType) {
case "any":
return true;
case "number":
return typeof item === "bigint" || typeof item === "number";
case "text":
Expand Down

0 comments on commit a533671

Please sign in to comment.