mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 07:34:25 +00:00
Configure embedding servers and add a Transcript Agent (#561)
* feat: configure embedding servers and transcript agents * fix(agents): guide Transcript Agent setup * fix(agents): require a configured embedding server URL * docs: consolidate embedding and transcript changelog entry * fix(webui): stabilize transcript menu interactions * test(e2e): verify transcript scroll interruption by position * test(webui): check transcript following without frame timing races
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { prisma, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||
import { prisma, UserType, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { transcriptionErrors } from '@shumai/dtos'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
@@ -8,6 +8,7 @@ describe('TranscriptService', () => {
|
||||
setupTestDbHooks()
|
||||
let assetId: string
|
||||
let projectId: string
|
||||
let agentId: string
|
||||
const model = 'whisper-tiny'
|
||||
const segments = [{ startMs: 125, endMs: 1425, text: 'Original segment' }]
|
||||
const media: PrismaJson.MediaInfo = {
|
||||
@@ -24,7 +25,23 @@ describe('TranscriptService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.stubEnv('EMBEDDING_PROVIDER', 'gemma-embedding-2-openai')
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', undefined)
|
||||
const team = await prisma.team.create({ data: { name: 'Transcript test' } })
|
||||
const agent = await prisma.agent.create({
|
||||
data: {
|
||||
type: 'transcription',
|
||||
team: { connect: { id: team.id } },
|
||||
config: { provider: '', model: '' },
|
||||
user: {
|
||||
create: {
|
||||
name: 'Transcript Agent',
|
||||
email: 'transcript-agent@example.test',
|
||||
type: UserType.agent,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
agentId = agent.id
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'Transcript test', teamId: team.id },
|
||||
})
|
||||
@@ -138,6 +155,18 @@ describe('TranscriptService', () => {
|
||||
expect(await prisma.workflowTask.count({ where: { assetId } })).toBe(0)
|
||||
})
|
||||
|
||||
it('requires an enabled Transcript Agent before contacting the provider or queuing', async () => {
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', 'false')
|
||||
await expect(transcriptService.isGenerationEnabled()).resolves.toBe(false)
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', undefined)
|
||||
await prisma.agent.update({ where: { id: agentId }, data: { enabled: false } })
|
||||
await expect(transcriptService.generate(assetId, null)).rejects.toMatchObject({ status: 503 })
|
||||
await prisma.agent.delete({ where: { id: agentId } })
|
||||
await expect(transcriptService.listLanguages()).rejects.toMatchObject({ status: 503 })
|
||||
expect(fetch).not.toHaveBeenCalled()
|
||||
expect(await prisma.workflowTask.count({ where: { assetId } })).toBe(0)
|
||||
})
|
||||
|
||||
it('serializes requests for an asset and uses its project and workflow type', async () => {
|
||||
const results = await Promise.all([
|
||||
transcriptService.generate(assetId, 'en'),
|
||||
|
||||
Reference in New Issue
Block a user