feat: configure embedding servers and transcript agents

This commit is contained in:
yiling
2026-12-04 18:54:29 +08:00
parent 72a7f68c92
commit 553269012c
57 changed files with 1686 additions and 271 deletions
+11 -4
View File
@@ -211,10 +211,14 @@ describe('Workflow E2E - agentEmbeddingMedia', () => {
])(
'indexes an entire video with %s and %s',
async (embeddingProvider, fullSpriteState) => {
vi.stubEnv('EMBEDDING_PROVIDER', embeddingProvider)
const useSavedUrl =
embeddingProvider === 'gemma-embedding-2-openai' &&
fullSpriteState === 'available full sprite'
const endpoint = 'https://embedding.example.com/v1/embeddings'
vi.stubEnv('EMBEDDING_PROVIDER', useSavedUrl ? undefined : embeddingProvider)
vi.stubEnv('GEMMA_EMBEDDING_OPENAI_BASE_URL', undefined)
if (embeddingProvider === 'gemma-embedding-2-openai') {
const endpoint = 'https://embedding.example.com/v1/embeddings'
vi.stubEnv('GEMMA_EMBEDDING_OPENAI_BASE_URL', endpoint)
if (!useSavedUrl) vi.stubEnv('GEMMA_EMBEDDING_OPENAI_BASE_URL', endpoint)
const fetch = globalThis.fetch
vi.spyOn(globalThis, 'fetch').mockImplementation((input, init) =>
input === endpoint
@@ -226,7 +230,10 @@ describe('Workflow E2E - agentEmbeddingMedia', () => {
}
// 1. Seed Database
const team = await prisma.team.create({
data: { name: 'E2E Video Embedding Team' },
data: {
name: 'E2E Video Embedding Team',
settings: useSavedUrl ? { embeddingServer: { url: endpoint } } : undefined,
},
})
const project = await prisma.project.create({
+26 -1
View File
@@ -12,7 +12,7 @@ import {
import { s3Service } from '@shumai/core/src/s3/s3'
import { transcriptService } from '@shumai/core/src/transcript/transcript'
import { transcodeService } from '@shumai/core/src/transcode/transcode'
import { prisma } from '@shumai/db'
import { prisma, UserType } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { initTranscodeWorkflows } from '@shumai/transcode'
import { TaskQueueAgent, TaskQueueArchive, workflowService } from '@shumai/workflow-core'
@@ -142,6 +142,20 @@ describe('Transcribe video workflow', () => {
async function createVideo(name: string, originalKey = 'video/unavailable-original.mkv') {
const team = await prisma.team.create({ data: { name: 'Transcription E2E' } })
await prisma.agent.create({
data: {
type: 'transcription',
config: { provider: '', model: '' },
team: { connect: { id: team.id } },
user: {
create: {
name: 'Transcript Agent',
email: `${team.id}@transcripts.test`,
type: UserType.agent,
},
},
},
})
const project = await prisma.project.create({ data: { name: 'Videos', teamId: team.id } })
const fullProxy = { key: `video/${name}`, resolution: '480p', width: 64, height: 64 }
await Promise.all(
@@ -262,6 +276,17 @@ describe('Transcribe video workflow', () => {
reason: 'tooLarge',
})
expect(await prisma.assetTranscript.count({ where: { assetId } })).toBe(0)
const comments = await prisma.assetComment.findMany({
where: { assetId },
include: { creator: true },
})
expect(comments).toHaveLength(1)
expect(comments[0]).toMatchObject({
transcriptionTaskId: task.id,
isInternal: true,
message: 'Transcription failed. Audio exceeds the embedding server upload limit.',
creator: { name: 'Transcript Agent' },
})
await vi.waitFor(async () =>
expect(await s3Service.listObjects(bucket, 'temp/transcripts/')).toEqual([]),
)