mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
feat(core): allow retry transcription (#11416)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
claimAudioTranscriptionMutation,
|
claimAudioTranscriptionMutation,
|
||||||
getAudioTranscriptionQuery,
|
getAudioTranscriptionQuery,
|
||||||
|
retryAudioTranscriptionMutation,
|
||||||
submitAudioTranscriptionMutation,
|
submitAudioTranscriptionMutation,
|
||||||
} from '@affine/graphql';
|
} from '@affine/graphql';
|
||||||
import { Entity } from '@toeverything/infra';
|
import { Entity } from '@toeverything/infra';
|
||||||
@@ -55,6 +56,24 @@ export class AudioTranscriptionJobStore extends Entity<{
|
|||||||
return response.submitAudioTranscription;
|
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) => {
|
getAudioTranscription = async (blobId: string, jobId?: string) => {
|
||||||
const graphqlService = this.graphqlService;
|
const graphqlService = this.graphqlService;
|
||||||
if (!graphqlService) {
|
if (!graphqlService) {
|
||||||
|
|||||||
@@ -146,6 +146,11 @@ export class AudioTranscriptionJob extends Entity<{
|
|||||||
if (!job) {
|
if (!job) {
|
||||||
logger.debug('No existing job found, submitting new transcription job');
|
logger.debug('No existing job found, submitting new transcription job');
|
||||||
job = await this.store.submitAudioTranscription();
|
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 {
|
} else {
|
||||||
logger.debug('Found existing job', {
|
logger.debug('Found existing job', {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user