Initial worker service
This commit is contained in:
40
src/hatchet/workflows/process-voice-experience.ts
Normal file
40
src/hatchet/workflows/process-voice-experience.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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),
|
||||
});
|
||||
Reference in New Issue
Block a user