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:
@@ -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({
|
||||
|
||||
@@ -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([]),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user