Files
worker/src/hatchet/workflows/process-voice-experience.ts
2026-05-05 12:05:55 +07:00

41 lines
1.2 KiB
TypeScript

import { analyzeVoiceExperience } from '../../jobs/analyze-voice-experience.js';
import { markVoiceExperienceFailed } from '../../jobs/mark-voice-experience-failed.js';
import { transcribeVoiceExperience } from '../../jobs/transcribe-voice-experience.js';
import { hatchet } from '../hatchet-client.js';
import { workflowNames } from '../workflow-names.js';
export type ProcessVoiceExperienceInput = {
experienceId: string;
};
type ProcessVoiceExperienceOutput = {
transcribe_voice_experience: {
transcript: string;
};
analyze_voice_experience_with_ontology: {
tags: string[];
};
};
export const processVoiceExperienceWorkflow = hatchet.workflow<
ProcessVoiceExperienceInput,
ProcessVoiceExperienceOutput
>({
name: workflowNames.processVoiceExperience,
});
const transcribeTask = processVoiceExperienceWorkflow.task({
name: 'transcribe_voice_experience',
fn: async (input) => transcribeVoiceExperience(input.experienceId),
});
processVoiceExperienceWorkflow.task({
name: 'analyze_voice_experience_with_ontology',
parents: [transcribeTask],
fn: async (input) => analyzeVoiceExperience(input.experienceId),
});
processVoiceExperienceWorkflow.onFailure({
fn: async (input) => markVoiceExperienceFailed(input.experienceId),
});