mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
feat(core): allow retry transcription (#11416)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
claimAudioTranscriptionMutation,
|
||||
getAudioTranscriptionQuery,
|
||||
retryAudioTranscriptionMutation,
|
||||
submitAudioTranscriptionMutation,
|
||||
} from '@affine/graphql';
|
||||
import { Entity } from '@toeverything/infra';
|
||||
@@ -55,6 +56,24 @@ export class AudioTranscriptionJobStore extends Entity<{
|
||||
return response.submitAudioTranscription;
|
||||
};
|
||||
|
||||
retryAudioTranscription = async (jobId: string) => {
|
||||
const graphqlService = this.graphqlService;
|
||||
if (!graphqlService) {
|
||||
throw new Error('No graphql service available');
|
||||
}
|
||||
const response = await graphqlService.gql({
|
||||
query: retryAudioTranscriptionMutation,
|
||||
variables: {
|
||||
jobId,
|
||||
workspaceId: this.currentWorkspaceId,
|
||||
},
|
||||
});
|
||||
if (!response.retryAudioTranscription) {
|
||||
throw new Error('Failed to retry audio transcription');
|
||||
}
|
||||
return response.retryAudioTranscription;
|
||||
};
|
||||
|
||||
getAudioTranscription = async (blobId: string, jobId?: string) => {
|
||||
const graphqlService = this.graphqlService;
|
||||
if (!graphqlService) {
|
||||
|
||||
@@ -146,6 +146,11 @@ export class AudioTranscriptionJob extends Entity<{
|
||||
if (!job) {
|
||||
logger.debug('No existing job found, submitting new transcription job');
|
||||
job = await this.store.submitAudioTranscription();
|
||||
} else if (job.status === AiJobStatus.failed) {
|
||||
logger.debug('Found existing failed job, retrying', {
|
||||
jobId: job.id,
|
||||
});
|
||||
job = await this.store.retryAudioTranscription(job.id);
|
||||
} else {
|
||||
logger.debug('Found existing job', {
|
||||
jobId: job.id,
|
||||
|
||||
Reference in New Issue
Block a user