mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
feat: configure embedding servers and transcript agents
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import { LOCAL_EMBEDDING_PROVIDER } from '@shumai/core/src/search/embedding-server'
|
||||
import type { WorkflowTask } from '@shumai/db'
|
||||
import {
|
||||
ApplicationFailure,
|
||||
@@ -56,7 +57,7 @@ export async function agentEmbeddingMedia(task: WorkflowTask): Promise<void> {
|
||||
}
|
||||
|
||||
const { asset, chunkDuration, chunkOverlap, embeddingProvider, existingEmbeddings } = context
|
||||
const isGemmaProvider = embeddingProvider === 'gemma-embedding-2-openai'
|
||||
const isGemmaProvider = embeddingProvider === LOCAL_EMBEDDING_PROVIDER
|
||||
|
||||
const existing = existingEmbeddings || []
|
||||
|
||||
@@ -130,6 +131,7 @@ export async function agentEmbeddingMedia(task: WorkflowTask): Promise<void> {
|
||||
if (!alreadyEmbedded) {
|
||||
const result = await generateImageEmbeddingActivity({
|
||||
teamId: task.teamId,
|
||||
provider: embeddingProvider,
|
||||
assetKey: embeddingKey,
|
||||
mediaType: embeddingMediaType || 'image/jpeg',
|
||||
})
|
||||
@@ -195,6 +197,7 @@ export async function agentEmbeddingMedia(task: WorkflowTask): Promise<void> {
|
||||
// Step B: Generate embedding on agent worker
|
||||
const chunkResult = await generateVideoChunkEmbeddingActivity({
|
||||
teamId: task.teamId,
|
||||
provider: embeddingProvider,
|
||||
chunkKey: chunk.chunkKey,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import type { WorkflowTask } from '@shumai/db'
|
||||
import { ApplicationFailure } from '@shumai/workflow-core'
|
||||
import { ApplicationFailure, isDbosWorkflowCancelledError } from '@shumai/workflow-core'
|
||||
import { deleteS3ObjectActivity } from '../activities/ai'
|
||||
import {
|
||||
extractTranscriptAudioActivity,
|
||||
saveTranscriptActivity,
|
||||
transcribeAudioActivity,
|
||||
reportTranscriptionFailureActivity,
|
||||
} from '../activities/transcription'
|
||||
|
||||
export async function transcribeVideoWorkflow(task: WorkflowTask): Promise<void> {
|
||||
@@ -19,10 +20,11 @@ export async function transcribeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
|
||||
const taskId = task.id
|
||||
const assetId = task.assetId
|
||||
const teamId = task.teamId ?? undefined
|
||||
const audioKey = `temp/transcripts/${taskId}.wav`
|
||||
try {
|
||||
await extractTranscriptAudioActivity({ assetId, taskId, audioKey })
|
||||
const transcript = await transcribeAudioActivity({ taskId, audioKey, ...request })
|
||||
await extractTranscriptAudioActivity({ assetId, taskId, audioKey, teamId })
|
||||
const transcript = await transcribeAudioActivity({ taskId, audioKey, teamId, ...request })
|
||||
if (request.language && transcript.language && request.language !== transcript.language) {
|
||||
throw ApplicationFailure.create({
|
||||
message: 'Transcription returned an unexpected language',
|
||||
@@ -40,6 +42,18 @@ export async function transcribeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
text: segment.text,
|
||||
})),
|
||||
})
|
||||
} catch (error) {
|
||||
if (!isDbosWorkflowCancelledError(error)) {
|
||||
try {
|
||||
await reportTranscriptionFailureActivity(
|
||||
taskId,
|
||||
error instanceof Error ? error.message : undefined,
|
||||
)
|
||||
} catch (commentError) {
|
||||
logger.error({ err: commentError, taskId }, 'Failed to post transcript failure comment')
|
||||
}
|
||||
}
|
||||
throw error
|
||||
} finally {
|
||||
try {
|
||||
await deleteS3ObjectActivity({ key: audioKey })
|
||||
|
||||
Reference in New Issue
Block a user