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:
@@ -11,6 +11,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- **sessions**: See total tokens and estimated cost in the session logs footer, with a breakdown of input, output, and cached tokens.
|
||||
- **projects**: Middle-click or Command/Ctrl-click a project to open it in a new tab. Use **Open in new tab** in a file or folder's context menu to keep your current view open.
|
||||
- **video**: Update your local embedding server to v0.1.3 to generate video transcripts. Choose a language or detect it automatically, then open the transcript in the video player to switch languages, follow playback, search the text, jump to a segment, or edit its text.
|
||||
- **integrations**: Set and test an embedding server URL in team settings. A URL set through environment variables appears read-only.
|
||||
- **video**: Enable the Transcript Agent to generate transcripts and get an internal comment on the video if a job fails. The updated embedding and full Docker Compose files enable the agent automatically. For an existing deployment, create and enable one Transcript Agent under **Team Settings → Agents**, or add this line to the Shumai service’s `environment` block in your Compose file.
|
||||
|
||||
```yaml
|
||||
ENABLE_TRANSCRIPTION_AGENT: 'true'
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ apps/web/e2e/
|
||||
| Owner creates a project with a cover image | `tests/project/create-project.spec.ts` |
|
||||
| Owner opens project cards in new tabs with middle-click and modifier-click | `tests/project/open-in-new-tab.spec.ts` |
|
||||
| Owner opens a folder card and a file row in new tabs from the context menu | `tests/project/open-in-new-tab.spec.ts` |
|
||||
| Owner generates a transcript from an archived video's context menu, sees progress in card and list metadata across a refresh, and reuses the project status across folders | `tests/project/generate-transcripts.spec.ts` |
|
||||
| Owner sees the transcript action only when available, generates a transcript from an archived video's context menu, sees progress in card and list metadata across a refresh, and reuses the project status across folders | `tests/project/generate-transcripts.spec.ts` |
|
||||
| Owner uploads a file or an unsupported file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
||||
| Owner deletes a file, finds it in recently deleted, and restores it | `tests/project/delete-restore.spec.ts` |
|
||||
| Owner deletes a folder and still sees its contents preview and countdown in recently deleted | `tests/project/delete-restore.spec.ts` |
|
||||
|
||||
@@ -16,6 +16,7 @@ test('starts a transcript for an archived video and tracks it in the file metada
|
||||
let submissions = 0
|
||||
let rejectSubmission = true
|
||||
let statusRequests = 0
|
||||
let transcriptionEnabled = false
|
||||
page.on('request', (request) => {
|
||||
if (new URL(request.url()).pathname === statusPath) {
|
||||
expect(request.method()).toBe('GET')
|
||||
@@ -25,7 +26,7 @@ test('starts a transcript for an archived video and tracks it in the file metada
|
||||
})
|
||||
await page.route('**/api/signup-info', async (route) => {
|
||||
const response = await route.fetch()
|
||||
await route.fulfill({ json: { ...(await response.json()), transcriptionEnabled: true } })
|
||||
await route.fulfill({ json: { ...(await response.json()), transcriptionEnabled } })
|
||||
})
|
||||
await page.route('**/api/transcription/languages', (route) =>
|
||||
route.fulfill({
|
||||
@@ -61,12 +62,17 @@ test('starts a transcript for an archived video and tracks it in the file metada
|
||||
)
|
||||
.toMatchObject({ status: 'processed', media: { proxyType: 'video' } })
|
||||
await prisma.asset.update({ where: { id: fileId }, data: { status: 'processing' } })
|
||||
await page.goto(projectPath)
|
||||
const action = page.getByRole('menuitem', { name: 'Generate Transcripts' })
|
||||
await fileCard(page, fileName).click({ button: 'right' })
|
||||
await expect(page.getByRole('menu')).toBeVisible()
|
||||
await expect(action).toHaveCount(0)
|
||||
transcriptionEnabled = true
|
||||
const [signupInfo] = await Promise.all([
|
||||
page.waitForResponse('**/api/signup-info'),
|
||||
page.goto(projectPath),
|
||||
])
|
||||
expect(await signupInfo.json()).toMatchObject({ transcriptionEnabled: true })
|
||||
const action = page.getByRole('menuitem', { name: 'Generate Transcripts' })
|
||||
await fileCard(page, fileName).click({ button: 'right' })
|
||||
await expect(action).toBeDisabled()
|
||||
await prisma.asset.update({ where: { id: fileId }, data: { status: 'archived' } })
|
||||
|
||||
@@ -99,7 +99,7 @@ async function run() {
|
||||
// Start services
|
||||
await metadataService.syncSystemFields().catch(console.error)
|
||||
await migrateLegacyAgentAvatars().catch(console.error)
|
||||
await agentService.ensureSystemEmbeddingAgents().catch(console.error)
|
||||
await agentService.ensureSystemAgents().catch(console.error)
|
||||
assetService.startCleanupJob()
|
||||
notificationJobService.start()
|
||||
autoArchiveJobService.start()
|
||||
|
||||
@@ -50,6 +50,7 @@ services:
|
||||
EMBEDDING_PROVIDER: gemma-embedding-2-openai
|
||||
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
|
||||
ENABLE_EMBEDDING_AGENT: 'true'
|
||||
ENABLE_TRANSCRIPTION_AGENT: 'true'
|
||||
CONCURRENCY_AGENT: 1
|
||||
|
||||
depends_on:
|
||||
|
||||
@@ -60,6 +60,7 @@ services:
|
||||
EMBEDDING_PROVIDER: gemma-embedding-2-openai
|
||||
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
|
||||
ENABLE_EMBEDDING_AGENT: 'true'
|
||||
ENABLE_TRANSCRIPTION_AGENT: 'true'
|
||||
CONCURRENCY_AGENT: 1
|
||||
|
||||
# 3D Turntable Renderer Configuration
|
||||
|
||||
@@ -50,6 +50,7 @@ services:
|
||||
EMBEDDING_PROVIDER: gemma-embedding-2-openai
|
||||
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
|
||||
ENABLE_EMBEDDING_AGENT: 'true'
|
||||
ENABLE_TRANSCRIPTION_AGENT: 'true'
|
||||
CONCURRENCY_AGENT: 1
|
||||
|
||||
depends_on:
|
||||
|
||||
@@ -60,6 +60,7 @@ services:
|
||||
EMBEDDING_PROVIDER: gemma-embedding-2-openai
|
||||
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
|
||||
ENABLE_EMBEDDING_AGENT: 'true'
|
||||
ENABLE_TRANSCRIPTION_AGENT: 'true'
|
||||
CONCURRENCY_AGENT: 1
|
||||
|
||||
# 3D Turntable Renderer Configuration
|
||||
|
||||
@@ -99,13 +99,14 @@ Configures background worker execution, concurrency limits, and worker identity
|
||||
|
||||
## Embedding Config
|
||||
|
||||
| Variable | Description | Example / Default |
|
||||
| :-------------------------------- | :------------------------------------------------------------------------------------------------------------ | :-------------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | Multimodal embedding provider. Options: `gemini-embedding-2`, `gemma-embedding-2-openai`. | `gemini-embedding-2` (default) |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | Base URL of the OpenAI-compatible LiteRT-LM embedding server. | `http://embedding-server:9379/v1` |
|
||||
| `ENABLE_EMBEDDING_AGENT` | When set to `true`, automatically provisions and enables the system embedding agent for all teams on startup. | `false` (default) |
|
||||
| `EMBEDDING_CHUNK_DURATION` | The duration in seconds for each video chunk when generating video embeddings. | `60.0` (default) |
|
||||
| `EMBEDDING_CHUNK_OVERLAP` | The duration in seconds to overlap video chunks when generating video embeddings. | `5.0` (default) |
|
||||
| Variable | Description | Example / Default |
|
||||
| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | Multimodal embedding provider. Options: `gemini-embedding-2`, `gemma-embedding-2-openai`. | `gemini-embedding-2` (default) |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | Base URL of the OpenAI-compatible LiteRT-LM embedding server. | `http://embedding-server:9379/v1` |
|
||||
| `ENABLE_EMBEDDING_AGENT` | When set to `true`, automatically provisions and enables the system embedding agent for all teams on startup. | `false` (default) |
|
||||
| `ENABLE_TRANSCRIPTION_AGENT` | Set to `true` to provision and enable the Transcript Agent, or `false` to disable it. Either value makes it read-only in team settings. | Unset. Manage the agent in team settings. |
|
||||
| `EMBEDDING_CHUNK_DURATION` | The duration in seconds for each video chunk when generating video embeddings. | `60.0` (default) |
|
||||
| `EMBEDDING_CHUNK_OVERLAP` | The duration in seconds to overlap video chunks when generating video embeddings. | `5.0` (default) |
|
||||
|
||||
## Sandbox Config
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ For video assets, Shumai breaks videos into standardized segments and extracts k
|
||||
>
|
||||
> If you change your embedding provider (for example, switching from Google Gemini's 1536-dimensional embeddings to EmbeddingGemma's 768-dimensional embeddings, or vice versa), **all existing vector embeddings in your database become invalid**.
|
||||
>
|
||||
> To protect production databases from accidental corruption and search failures, **Shumai intentionally does not provide a WebUI toggle to change the embedding provider**. The provider can only be configured by an administrator via environment variables (`EMBEDDING_PROVIDER` and `GEMMA_EMBEDDING_OPENAI_BASE_URL`).
|
||||
> Saving an embedding server URL in Integrations selects EmbeddingGemma when `EMBEDDING_PROVIDER` is unset. Regenerate your embeddings after switching providers.
|
||||
|
||||
---
|
||||
|
||||
@@ -103,6 +103,7 @@ services:
|
||||
EMBEDDING_PROVIDER: gemma-embedding-2-openai
|
||||
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
|
||||
ENABLE_EMBEDDING_AGENT: 'true'
|
||||
ENABLE_TRANSCRIPTION_AGENT: 'true'
|
||||
CONCURRENCY_AGENT: 1
|
||||
depends_on:
|
||||
- embedding-server
|
||||
@@ -111,14 +112,23 @@ services:
|
||||
> [!NOTE]
|
||||
> Since Shumai communicates with `embedding-server` over Docker's internal network, `embedding-server` does not need to expose any ports to the host machine.
|
||||
|
||||
### Configure in Shumai
|
||||
|
||||
Open **Team Settings → Integrations → Embedding Server**. Enter the URL as reached from Shumai, select **Test Connection**, and save. For Docker Compose, use the internal service address, such as `http://embedding-server:9379/v1`. Clear the field and save to remove the setting.
|
||||
|
||||
`EMBEDDING_PROVIDER` takes precedence over automatic provider selection. When `GEMMA_EMBEDDING_OPENAI_BASE_URL` is set, that URL takes precedence and the field is read-only. The embedding server accepts unauthenticated requests. [Embedding server source](https://github.com/shumaiOne/embedding-server/blob/main/serve.py)
|
||||
|
||||
Enable the **Embedding Agent** for semantic search. Enable the **Transcript Agent** for video transcription and internal comments on failed jobs. Both agents are available in **Team Settings → Agents**.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
| Variable | Required | Description | Default |
|
||||
| :-------------------------------- | :---------- | :---------------------------------------------------------------------------------------------------------------------------- | :------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | Yes | Set to `gemma-embedding-2-openai` to use the local LiteRT-LM server. | `gemini-embedding-2` |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | Yes | HTTP base URL of the embedding server (e.g. `http://embedding-server:9379/v1`). | `http://localhost:9379/v1` |
|
||||
| `ENABLE_EMBEDDING_AGENT` | No | Automatically provisions and enables the system embedding agent for all teams on startup. | `false` |
|
||||
| `CONCURRENCY_AGENT` | Recommended | Maximum concurrent AI tasks executed by workers. **Set to `1`** when running `embedding-server` to prevent high memory usage. | `5` |
|
||||
| Variable | Required | Description | Default |
|
||||
| :-------------------------------- | :------------ | :----------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | For env setup | Set to `gemma-embedding-2-openai` to use the local LiteRT-LM server. | `gemini-embedding-2` when no integration URL is saved |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | No | Overrides the saved embedding server URL and makes the integration read-only. | `http://localhost:9379/v1` when the local provider is selected without a URL |
|
||||
| `ENABLE_EMBEDDING_AGENT` | No | Automatically provisions and enables the system embedding agent for all teams on startup. | `false` |
|
||||
| `ENABLE_TRANSCRIPTION_AGENT` | No | Set to `true` to create or enable the Transcript Agent, or `false` to disable it. Either value makes it read-only in Settings. | Unset. Manage the agent in Settings. |
|
||||
| `CONCURRENCY_AGENT` | Recommended | Maximum concurrent AI tasks executed by workers. **Set to `1`** when running `embedding-server` to prevent high memory usage. | `5` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -99,13 +99,14 @@ Shumai 支持配置可选的**归档存储**(冷存储)层级(`local` NAS/
|
||||
|
||||
## 向量模型配置
|
||||
|
||||
| 变量 | 说明 | 示例 / 默认值 |
|
||||
| :-------------------------------- | :------------------------------------------------------------------------------- | :-------------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | 多模态向量模型服务商。可选值:`gemini-embedding-2`、`gemma-embedding-2-openai`。 | `gemini-embedding-2`(默认) |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | 兼容 OpenAI 协议的 LiteRT-LM 向量模型服务 Base URL。 | `http://embedding-server:9379/v1` |
|
||||
| `ENABLE_EMBEDDING_AGENT` | 设为 `true` 时,在启动时自动为所有团队置备并启用系统向量智能体。 | `false`(默认) |
|
||||
| `EMBEDDING_CHUNK_DURATION` | 生成视频向量时每个视频切片的时长(单位:秒)。 | `60.0`(默认) |
|
||||
| `EMBEDDING_CHUNK_OVERLAP` | 生成视频向量时各个视频切片的重叠时长(单位:秒)。 | `5.0`(默认) |
|
||||
| 变量 | 说明 | 示例 / 默认值 |
|
||||
| :-------------------------------- | :-------------------------------------------------------------------------------------------- | :-------------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | 多模态向量模型服务商。可选值:`gemini-embedding-2`、`gemma-embedding-2-openai`。 | `gemini-embedding-2`(默认) |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | 兼容 OpenAI 协议的 LiteRT-LM 向量模型服务 Base URL。 | `http://embedding-server:9379/v1` |
|
||||
| `ENABLE_TRANSCRIPTION_AGENT` | 设置为 `true` 时自动创建并启用转录智能体,设置为 `false` 时停用。两种情况下团队设置均为只读。 | 未设置时可在团队设置中管理。 |
|
||||
| `ENABLE_EMBEDDING_AGENT` | 设为 `true` 时,在启动时自动为所有团队置备并启用系统向量智能体。 | `false`(默认) |
|
||||
| `EMBEDDING_CHUNK_DURATION` | 生成视频向量时每个视频切片的时长(单位:秒)。 | `60.0`(默认) |
|
||||
| `EMBEDDING_CHUNK_OVERLAP` | 生成视频向量时各个视频切片的重叠时长(单位:秒)。 | `5.0`(默认) |
|
||||
|
||||
## 沙箱配置
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ Shumai 支持通过 [shumaiOne/embedding-server](https://github.com/shumaiOne/em
|
||||
>
|
||||
> 若更换向量服务提供商(例如从 Google Gemini 的 1536 维向量切换到 EmbeddingGemma 的 768 维向量,反之亦然),**数据库中现存的所有向量嵌入数据将全部失效**。
|
||||
>
|
||||
> 为保护生产数据库免受误操作损坏及搜索失效,**Shumai 刻意未在 Web 界面中提供切换 Embedding 提供商的开关**。该配置仅能由管理员通过环境变量(`EMBEDDING_PROVIDER` 和 `GEMMA_EMBEDDING_OPENAI_BASE_URL`)进行配置。
|
||||
> 未设置 `EMBEDDING_PROVIDER` 时,在集成页面保存向量模型服务地址会启用 EmbeddingGemma。切换向量模型服务后,请重新生成向量。
|
||||
|
||||
---
|
||||
|
||||
@@ -103,6 +103,7 @@ services:
|
||||
EMBEDDING_PROVIDER: gemma-embedding-2-openai
|
||||
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
|
||||
ENABLE_EMBEDDING_AGENT: 'true'
|
||||
ENABLE_TRANSCRIPTION_AGENT: 'true'
|
||||
CONCURRENCY_AGENT: 1
|
||||
depends_on:
|
||||
- embedding-server
|
||||
@@ -111,14 +112,23 @@ services:
|
||||
> [!NOTE]
|
||||
> 由于 Shumai 与 `embedding-server` 在 Docker 内部网络中通信,`embedding-server` 无需向宿主机映射暴露端口。
|
||||
|
||||
### 在 Shumai 中配置
|
||||
|
||||
打开 **团队设置 → 集成 → 向量模型服务**。输入 Shumai 可以访问的服务地址,选择 **测试连接**,然后保存。使用 Docker Compose 时,可填写内部服务地址,例如 `http://embedding-server:9379/v1`。清空地址并保存即可移除配置。
|
||||
|
||||
已设置的 `EMBEDDING_PROVIDER` 优先于自动选择。设置 `GEMMA_EMBEDDING_OPENAI_BASE_URL` 后,环境变量中的地址优先生效,集成页面的地址字段为只读。向量模型服务接受未经身份验证的请求。[向量模型服务源码](https://github.com/shumaiOne/embedding-server/blob/main/serve.py)
|
||||
|
||||
在 **团队设置 → 智能体** 中启用 **嵌入智能体** 后可使用语义搜索。启用 **转录智能体** 后可生成视频转录,转录失败时会在视频中发布内部评论。
|
||||
|
||||
### 环境变量
|
||||
|
||||
| 变量 | 必填 | 说明 | 默认值 |
|
||||
| :-------------------------------- | :------- | :------------------------------------------------------------------------------------------------ | :------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | 是 | 设置为 `gemma-embedding-2-openai` 以使用本地 LiteRT-LM 服务。 | `gemini-embedding-2` |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | 是 | 向量模型服务的 HTTP 基础地址(例如 `http://embedding-server:9379/v1`)。 | `http://localhost:9379/v1` |
|
||||
| `ENABLE_EMBEDDING_AGENT` | 否 | 启动时自动为所有团队初始化并启用系统级向量嵌入智能体。 | `false` |
|
||||
| `CONCURRENCY_AGENT` | 推荐配置 | Worker 执行 AI 任务的最大并发数。运行 `embedding-server` 时**务必设为 `1`**,以防止内存开销过大。 | `5` |
|
||||
| 变量 | 必填 | 说明 | 默认值 |
|
||||
| :-------------------------------- | :----------------- | :------------------------------------------------------------------------------------------------ | :---------------------------------------------------------- |
|
||||
| `EMBEDDING_PROVIDER` | 环境变量配置时需要 | 设置为 `gemma-embedding-2-openai` 以使用本地 LiteRT-LM 服务。 | 未保存服务地址时为 `gemini-embedding-2` |
|
||||
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | 否 | 覆盖集成页面保存的服务地址,并将地址字段设为只读。 | 选择本地模型服务且未配置地址时为 `http://localhost:9379/v1` |
|
||||
| `ENABLE_EMBEDDING_AGENT` | 否 | 启动时自动为所有团队初始化并启用系统级向量嵌入智能体。 | `false` |
|
||||
| `ENABLE_TRANSCRIPTION_AGENT` | 否 | `true` 会创建或启用转录智能体,`false` 会停用它。两种情况下设置页面均为只读。 | 未设置时可在设置页面管理。 |
|
||||
| `CONCURRENCY_AGENT` | 推荐配置 | Worker 执行 AI 任务的最大并发数。运行 `embedding-server` 时**务必设为 `1`**,以防止内存开销过大。 | `5` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { GoogleGenAI } from '@google/genai'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import {
|
||||
embeddingServerService,
|
||||
LOCAL_EMBEDDING_PROVIDER,
|
||||
} from '@shumai/core/src/search/embedding-server'
|
||||
import { textEmbeddingService } from '@shumai/core/src/search/text-embedding'
|
||||
import { prisma, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||
import {
|
||||
@@ -59,19 +63,13 @@ interface OpenAiEmbeddingItem {
|
||||
}
|
||||
}
|
||||
|
||||
async function callGemmaEmbeddingServer(input: string | OpenAiEmbeddingItem[]): Promise<{
|
||||
async function callGemmaEmbeddingServer(
|
||||
endpoint: string,
|
||||
input: OpenAiEmbeddingItem[],
|
||||
): Promise<{
|
||||
embedding: number[]
|
||||
usage: Usage
|
||||
}> {
|
||||
const rawBaseUrl = process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL || 'http://localhost:9379/v1'
|
||||
|
||||
const normalized = rawBaseUrl.replace(/\/+$/, '')
|
||||
const endpoint = normalized.endsWith('/embeddings')
|
||||
? normalized
|
||||
: normalized.endsWith('/v1')
|
||||
? `${normalized}/embeddings`
|
||||
: `${normalized}/v1/embeddings`
|
||||
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -89,8 +87,12 @@ async function callGemmaEmbeddingServer(input: string | OpenAiEmbeddingItem[]):
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- response json shape is dynamic from external endpoint
|
||||
const json: any = await response.json()
|
||||
const json = (await response.json()) as {
|
||||
model?: string
|
||||
data?: Array<{ embedding?: number[] }>
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- OpenAI response field
|
||||
usage?: { prompt_tokens?: number }
|
||||
}
|
||||
const embedding = json.data?.[0]?.embedding
|
||||
if (!embedding || !Array.isArray(embedding)) {
|
||||
throw ApplicationFailure.create({
|
||||
@@ -102,7 +104,7 @@ async function callGemmaEmbeddingServer(input: string | OpenAiEmbeddingItem[]):
|
||||
return {
|
||||
embedding,
|
||||
usage: {
|
||||
model: json.model || 'gemma-embedding-2-openai',
|
||||
model: json.model || LOCAL_EMBEDDING_PROVIDER,
|
||||
inputTokens: json.usage?.prompt_tokens ?? 0,
|
||||
outputTokens: 0,
|
||||
},
|
||||
@@ -119,8 +121,8 @@ export const generateTextEmbeddingActivity = defineStep(
|
||||
embedding: number[]
|
||||
usage: Usage
|
||||
}> {
|
||||
const provider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
|
||||
if (provider !== 'gemma-embedding-2-openai' && !process.env.GEMINI_API_KEY) {
|
||||
const { provider } = await embeddingServerService.resolveRuntimeConfig(params.teamId)
|
||||
if (provider !== LOCAL_EMBEDDING_PROVIDER && !process.env.GEMINI_API_KEY) {
|
||||
throw ApplicationFailure.create({
|
||||
message: 'GEMINI_API_KEY environment variable is not configured',
|
||||
nonRetryable: true,
|
||||
@@ -129,6 +131,7 @@ export const generateTextEmbeddingActivity = defineStep(
|
||||
|
||||
try {
|
||||
const result = await textEmbeddingService.generateEmbedding(params.text, {
|
||||
provider,
|
||||
teamId: params.teamId,
|
||||
skipCache: true,
|
||||
})
|
||||
@@ -193,7 +196,9 @@ export const getEmbeddingContextActivity = defineStep(
|
||||
|
||||
const parsedOverlap = parseFloat(process.env.EMBEDDING_CHUNK_OVERLAP || '')
|
||||
const chunkOverlap = Number.isFinite(parsedOverlap) && parsedOverlap >= 0 ? parsedOverlap : 5.0
|
||||
const embeddingProvider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
|
||||
const { provider: embeddingProvider } = await embeddingServerService.resolveRuntimeConfig(
|
||||
params.teamId,
|
||||
)
|
||||
|
||||
const existingEmbeddings = await prisma.$queryRaw<ExistingAssetEmbeddingInfo[]>`
|
||||
SELECT
|
||||
@@ -290,6 +295,7 @@ export const saveAssetEmbeddingsActivity = defineStep(
|
||||
|
||||
export interface GenerateImageEmbeddingParams {
|
||||
teamId: string
|
||||
provider?: string
|
||||
assetKey: string
|
||||
mediaType: string
|
||||
}
|
||||
@@ -299,20 +305,23 @@ export const generateImageEmbeddingActivity = defineStep(
|
||||
embedding: number[]
|
||||
usage: Usage
|
||||
}> {
|
||||
const provider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
|
||||
const { provider, embeddingEndpoint } = await embeddingServerService.resolveRuntimeConfig(
|
||||
params.teamId,
|
||||
params.provider,
|
||||
)
|
||||
const { buffer: data } = await s3Service.getObject(
|
||||
process.env.S3_BUCKET || 'shumai',
|
||||
params.assetKey,
|
||||
)
|
||||
|
||||
if (provider === 'gemma-embedding-2-openai') {
|
||||
if (provider === LOCAL_EMBEDDING_PROVIDER) {
|
||||
let imgData = data
|
||||
let mimeType = params.mediaType || 'image/jpeg'
|
||||
if (mimeType !== 'image/jpeg' && mimeType !== 'image/png') {
|
||||
imgData = await sharp(data).jpeg().toBuffer()
|
||||
mimeType = 'image/jpeg'
|
||||
}
|
||||
return callGemmaEmbeddingServer([
|
||||
return callGemmaEmbeddingServer(embeddingEndpoint, [
|
||||
{
|
||||
type: 'image_url',
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
@@ -383,6 +392,7 @@ export function getGemmaEmbeddingTargetFrameCount(width?: number, height?: numbe
|
||||
|
||||
export interface GenerateVideoChunkEmbeddingParams {
|
||||
teamId: string
|
||||
provider?: string
|
||||
chunkKey: string
|
||||
}
|
||||
|
||||
@@ -393,8 +403,11 @@ export const generateVideoChunkEmbeddingActivity = defineStep(
|
||||
embedding: number[]
|
||||
usage: Usage
|
||||
}> {
|
||||
const provider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
|
||||
const isGemma = provider === 'gemma-embedding-2-openai' || params.chunkKey.endsWith('.tar')
|
||||
const { provider, embeddingEndpoint } = await embeddingServerService.resolveRuntimeConfig(
|
||||
params.teamId,
|
||||
params.provider,
|
||||
)
|
||||
const isGemma = provider === LOCAL_EMBEDDING_PROVIDER || params.chunkKey.endsWith('.tar')
|
||||
|
||||
if (isGemma) {
|
||||
const { buffer: data } = await s3Service.getObject(
|
||||
@@ -467,7 +480,7 @@ export const generateVideoChunkEmbeddingActivity = defineStep(
|
||||
}),
|
||||
)
|
||||
|
||||
return await callGemmaEmbeddingServer(input)
|
||||
return await callGemmaEmbeddingServer(embeddingEndpoint, input)
|
||||
}
|
||||
|
||||
const apiKey = process.env.GEMINI_API_KEY
|
||||
|
||||
@@ -54,12 +54,14 @@ export const extractTranscriptAudioActivity = defineStep(
|
||||
assetId,
|
||||
taskId,
|
||||
audioKey,
|
||||
teamId,
|
||||
}: {
|
||||
assetId: string
|
||||
taskId: string
|
||||
audioKey: string
|
||||
teamId?: string
|
||||
}): Promise<void> {
|
||||
if (!isLocalTranscriptionEnabled()) {
|
||||
if (!(await isLocalTranscriptionEnabled(teamId))) {
|
||||
throw ApplicationFailure.create({
|
||||
message: 'Local transcription is disabled',
|
||||
nonRetryable: true,
|
||||
@@ -131,11 +133,13 @@ export const extractTranscriptAudioActivity = defineStep(
|
||||
)
|
||||
|
||||
export const transcribeAudioActivity = defineStep(async function transcribeAudioActivity({
|
||||
teamId,
|
||||
taskId,
|
||||
audioKey,
|
||||
language,
|
||||
model,
|
||||
}: {
|
||||
teamId?: string
|
||||
taskId: string
|
||||
audioKey: string
|
||||
language: string | null
|
||||
@@ -145,6 +149,7 @@ export const transcribeAudioActivity = defineStep(async function transcribeAudio
|
||||
try {
|
||||
const path = await ensureLocalMediaFile(audioKey, join(directory, 'audio.wav'))
|
||||
return await transcribeLocalAudio({
|
||||
teamId,
|
||||
audio: Bun.file(path),
|
||||
language,
|
||||
model,
|
||||
@@ -179,3 +184,39 @@ export const saveTranscriptActivity = defineStep(async function saveTranscriptAc
|
||||
throw ApplicationFailure.create({ message: 'Video is no longer available', nonRetryable: true })
|
||||
}
|
||||
})
|
||||
|
||||
export const reportTranscriptionFailureActivity = defineStep(
|
||||
async function reportTranscriptionFailureActivity(taskId: string, reason: string | undefined) {
|
||||
if (getLocalTaskAbortSignal(taskId)?.aborted) return
|
||||
|
||||
const task = await prisma.workflowTask.findUnique({
|
||||
where: { id: taskId, type: 'ai_transcription', status: 'processing' },
|
||||
select: { assetId: true, teamId: true },
|
||||
})
|
||||
if (!task?.teamId) return
|
||||
|
||||
const asset = await prisma.asset.findFirst({
|
||||
where: { id: task.assetId, isDeleted: false, project: { teamId: task.teamId } },
|
||||
select: { id: true },
|
||||
})
|
||||
if (!asset) return
|
||||
|
||||
const agent = await transcriptService.findEnabledAgent(task.teamId)
|
||||
if (!agent || getLocalTaskAbortSignal(taskId)?.aborted) return
|
||||
|
||||
const detail = Object.values(transcriptionErrors).find((message) => message === reason)
|
||||
await prisma.assetComment.upsert({
|
||||
where: { transcriptionTaskId: taskId },
|
||||
update: {},
|
||||
create: {
|
||||
assetId: asset.id,
|
||||
creatorId: agent.id,
|
||||
transcriptionTaskId: taskId,
|
||||
isInternal: true,
|
||||
message: detail
|
||||
? `Transcription failed. ${detail}.`
|
||||
: 'Transcription failed. Try generating the transcript again.',
|
||||
},
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -71,6 +71,36 @@ describe('Agent API', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it.each(['true', 'false'])(
|
||||
'protects the Transcript Agent when ENABLE_TRANSCRIPTION_AGENT=%s',
|
||||
async (value) => {
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', value)
|
||||
try {
|
||||
vi.mocked(agentService.getAgent).mockResolvedValue({
|
||||
id: 'transcript1',
|
||||
teamId: 'team1',
|
||||
type: 'transcription',
|
||||
} as Awaited<ReturnType<typeof agentService.getAgent>>)
|
||||
const payload = JSON.stringify({ type: 'transcription', name: 'Transcript Agent' })
|
||||
const headers = { 'Content-Type': 'application/json' }
|
||||
for (const [path, method, body] of [
|
||||
['/teams/team1/agents', 'POST', payload],
|
||||
['/agents/transcript1', 'PUT', payload],
|
||||
['/agents/transcript1/permission', 'PATCH', JSON.stringify({ permission: 'editor' })],
|
||||
['/agents/transcript1', 'DELETE', undefined],
|
||||
] as const) {
|
||||
expect((await app.request(path, { method, headers, body })).status).toBe(403)
|
||||
}
|
||||
expect(agentService.createAgent).not.toHaveBeenCalled()
|
||||
expect(agentService.updateAgent).not.toHaveBeenCalled()
|
||||
expect(agentService.updateAgentPermission).not.toHaveBeenCalled()
|
||||
expect(agentService.deleteAgent).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
vi.unstubAllEnvs()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
describe('GET /teams/:teamId/agents', () => {
|
||||
it('returns list of agents', async () => {
|
||||
const mockAgents = [
|
||||
|
||||
+15
-24
@@ -1,5 +1,6 @@
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { agentService } from '@shumai/core/src/agent/agent'
|
||||
import { getSystemAgentSetting } from '@shumai/core/src/agent/system-agents'
|
||||
import { agentSessionService } from '@shumai/core/src/agent/session-service'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import {
|
||||
@@ -68,13 +69,10 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
id: teamId,
|
||||
})
|
||||
|
||||
const isEmbeddingManagedByEnv =
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
|
||||
|
||||
if (req.type === 'embedding' && isEmbeddingManagedByEnv) {
|
||||
const managedSetting = getSystemAgentSetting(req.type)
|
||||
if (managedSetting) {
|
||||
throw new HTTPException(403, {
|
||||
message: 'Embedding agent is managed by environment configuration and cannot be created',
|
||||
message: `${managedSetting.name} is managed by environment configuration and cannot be created`,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -108,14 +106,13 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
id: agentId,
|
||||
})
|
||||
|
||||
const isEmbeddingManagedByEnv =
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
|
||||
|
||||
const existingAgent = await agentService.getAgent({ agentId })
|
||||
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
|
||||
const managedSetting =
|
||||
(existingAgent && getSystemAgentSetting(existingAgent.type)) ??
|
||||
getSystemAgentSetting(req.type)
|
||||
if (managedSetting) {
|
||||
throw new HTTPException(403, {
|
||||
message: 'Embedding agent is managed by environment configuration and cannot be modified',
|
||||
message: `${managedSetting.name} is managed by environment configuration and cannot be modified`,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -150,14 +147,11 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
id: agentId,
|
||||
})
|
||||
|
||||
const isEmbeddingManagedByEnv =
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
|
||||
|
||||
const existingAgent = await agentService.getAgent({ agentId })
|
||||
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
|
||||
const managedSetting = existingAgent && getSystemAgentSetting(existingAgent.type)
|
||||
if (managedSetting) {
|
||||
throw new HTTPException(403, {
|
||||
message: 'Embedding agent is managed by environment configuration and cannot be modified',
|
||||
message: `${managedSetting.name} is managed by environment configuration and cannot be modified`,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -186,14 +180,11 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
id: agentId,
|
||||
})
|
||||
|
||||
const isEmbeddingManagedByEnv =
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
|
||||
|
||||
const existingAgent = await agentService.getAgent({ agentId })
|
||||
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
|
||||
const managedSetting = existingAgent && getSystemAgentSetting(existingAgent.type)
|
||||
if (managedSetting) {
|
||||
throw new HTTPException(403, {
|
||||
message: 'Embedding agent is managed by environment configuration and cannot be deleted',
|
||||
message: `${managedSetting.name} is managed by environment configuration and cannot be deleted`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { Hono } from 'hono'
|
||||
import authnRoute from './authn'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
import { transcriptService } from '@shumai/core/src/transcript/transcript'
|
||||
|
||||
describe('authn api', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -17,7 +18,7 @@ describe('authn api', () => {
|
||||
})
|
||||
|
||||
it('GET /signup-info', async () => {
|
||||
vi.stubEnv('EMBEDDING_PROVIDER', 'gemini-embedding-2')
|
||||
vi.spyOn(transcriptService, 'isGenerationEnabled').mockResolvedValue(false)
|
||||
mockGetSignupInfo.mockResolvedValue({
|
||||
initialized: true,
|
||||
demoMode: false,
|
||||
@@ -35,8 +36,8 @@ describe('authn api', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('advertises transcription with the local embedding provider', async () => {
|
||||
vi.stubEnv('EMBEDDING_PROVIDER', 'gemma-embedding-2-openai')
|
||||
it('advertises transcription when generation is enabled', async () => {
|
||||
vi.spyOn(transcriptService, 'isGenerationEnabled').mockResolvedValue(true)
|
||||
mockGetSignupInfo.mockResolvedValue({ initialized: true, demoMode: false })
|
||||
|
||||
const res = await new Hono().route('/', authnRoute).request('/signup-info')
|
||||
|
||||
@@ -4,7 +4,7 @@ import { userService } from '@shumai/core/src/user/user'
|
||||
import { auth } from '@shumai/core/src/auth/auth'
|
||||
import { createGuestToken } from '@shumai/core/src/auth/guest-token'
|
||||
import { isArchiveStorageEnabled } from '@shumai/core/src/s3/archive-storage'
|
||||
import { isLocalTranscriptionEnabled } from '@shumai/core/src/transcript/local-transcription'
|
||||
import { transcriptService } from '@shumai/core/src/transcript/transcript'
|
||||
import { z } from 'zod'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { ulid } from 'ulid'
|
||||
@@ -25,7 +25,7 @@ const route = app
|
||||
initialized: info.initialized,
|
||||
demoMode: info.demoMode,
|
||||
archiveStorageEnabled: isArchiveStorageEnabled(),
|
||||
transcriptionEnabled: isLocalTranscriptionEnabled(),
|
||||
transcriptionEnabled: await transcriptService.isGenerationEnabled(),
|
||||
})
|
||||
})
|
||||
.get('/me', async (c) => {
|
||||
|
||||
@@ -6,6 +6,8 @@ import { authMiddleware } from './middleware/auth'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
import { userMetadataService } from '@shumai/core/src/user-metadata/user-metadata'
|
||||
import { authzService, ResourceType, Permission } from '@shumai/core/src/authz/authz'
|
||||
import { embeddingServerService } from '@shumai/core/src/search/embedding-server'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
|
||||
vi.mock('@shumai/core/src/authz/authz', () => ({
|
||||
authzService: {
|
||||
@@ -112,6 +114,73 @@ describe('team api', () => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('lets team members view the effective embedding server settings', async () => {
|
||||
vi.spyOn(embeddingServerService, 'getSettings').mockResolvedValue({
|
||||
url: 'http://embedding:9379/v1',
|
||||
isEnvConfigured: true,
|
||||
})
|
||||
const response = await app.request('/teams/t1/embedding-server-settings')
|
||||
expect(await response.json()).toEqual({
|
||||
url: 'http://embedding:9379/v1',
|
||||
isEnvConfigured: true,
|
||||
})
|
||||
expect(authzService.hasPermission).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ id: 't1', permission: Permission.Read }),
|
||||
)
|
||||
})
|
||||
|
||||
it('lets admins save and test embedding server settings', async () => {
|
||||
vi.mocked(authzService.hasPermission).mockClear()
|
||||
const url = 'http://embedding:9379/v1'
|
||||
const settings = { url, isEnvConfigured: false }
|
||||
const save = vi.spyOn(embeddingServerService, 'updateSettings').mockResolvedValue(settings)
|
||||
const test = vi.spyOn(embeddingServerService, 'testConnection').mockResolvedValue({ ok: true })
|
||||
const body = JSON.stringify({ url })
|
||||
const headers = { 'Content-Type': 'application/json' }
|
||||
const saved = await app.request('/teams/t1/embedding-server-settings', {
|
||||
method: 'PUT',
|
||||
headers,
|
||||
body,
|
||||
})
|
||||
expect(await saved.json()).toEqual(settings)
|
||||
const tested = await app.request('/teams/t1/embedding-server-settings/test', {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body,
|
||||
})
|
||||
expect(await tested.json()).toEqual({ ok: true })
|
||||
expect(save).toHaveBeenCalledWith('t1', url)
|
||||
expect(test).toHaveBeenCalledWith('t1', url)
|
||||
expect(authzService.hasPermission).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
expect.objectContaining({ permission: Permission.Admin }),
|
||||
)
|
||||
expect(authzService.hasPermission).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
expect.objectContaining({ permission: Permission.Admin }),
|
||||
)
|
||||
})
|
||||
|
||||
it('rejects embedding settings writes and connection tests without admin permission', async () => {
|
||||
const save = vi.spyOn(embeddingServerService, 'updateSettings')
|
||||
const test = vi.spyOn(embeddingServerService, 'testConnection')
|
||||
vi.mocked(authzService.hasPermission).mockRejectedValue(new HTTPException(403))
|
||||
for (const [method, suffix] of [
|
||||
['PUT', ''],
|
||||
['POST', '/test'],
|
||||
]) {
|
||||
const denied = await app.request(`/teams/t1/embedding-server-settings${suffix}`, {
|
||||
method,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ url: 'http://embedding:9379/v1' }),
|
||||
})
|
||||
expect(denied.status).toBe(403)
|
||||
}
|
||||
expect(save).not.toHaveBeenCalled()
|
||||
expect(test).not.toHaveBeenCalled()
|
||||
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
|
||||
})
|
||||
|
||||
it('POST /teams returns 404 without creating a team or writing an audit entry', async () => {
|
||||
const createTeam = vi.spyOn(teamService, 'createTeam').mockResolvedValue({
|
||||
id: 't1',
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
updateRunnerRequestSchema,
|
||||
updateTurntableSettingsRequestSchema,
|
||||
updateGotenbergSettingsRequestSchema,
|
||||
updateEmbeddingServerSettingsRequestSchema,
|
||||
updateMeRequestSchema,
|
||||
updateTeamMemberRoleRequestSchema,
|
||||
createApiTokenRequestSchema,
|
||||
@@ -31,6 +32,7 @@ import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { workflowTaskService } from '@shumai/core/src/workflowTask/workflowTask'
|
||||
import { turntableService } from '@shumai/core/src/turntable/turntable'
|
||||
import { gotenbergService } from '@shumai/core/src/gotenberg/gotenberg'
|
||||
import { embeddingServerService } from '@shumai/core/src/search/embedding-server'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
@@ -405,6 +407,46 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
return c.json(res)
|
||||
},
|
||||
)
|
||||
.get('/teams/:teamId/embedding-server-settings', async (c) => {
|
||||
const teamId = c.req.param('teamId')
|
||||
await authzService.hasPermission({
|
||||
user: c.get('user'),
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
return c.json(await embeddingServerService.getSettings(teamId))
|
||||
})
|
||||
.put(
|
||||
'/teams/:teamId/embedding-server-settings',
|
||||
zValidator('json', updateEmbeddingServerSettingsRequestSchema),
|
||||
async (c) => {
|
||||
const teamId = c.req.param('teamId')
|
||||
await authzService.hasPermission({
|
||||
user: c.get('user'),
|
||||
permission: Permission.Admin,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
const { url } = c.req.valid('json')
|
||||
return c.json(await embeddingServerService.updateSettings(teamId, url))
|
||||
},
|
||||
)
|
||||
.post(
|
||||
'/teams/:teamId/embedding-server-settings/test',
|
||||
zValidator('json', updateEmbeddingServerSettingsRequestSchema.partial()),
|
||||
async (c) => {
|
||||
const teamId = c.req.param('teamId')
|
||||
await authzService.hasPermission({
|
||||
user: c.get('user'),
|
||||
permission: Permission.Admin,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
const { url } = c.req.valid('json')
|
||||
return c.json(await embeddingServerService.testConnection(teamId, url))
|
||||
},
|
||||
)
|
||||
.get('/teams/:teamId/user-metadata', async (c) => {
|
||||
const user = c.get('user')
|
||||
const teamId = c.req.param('teamId')
|
||||
|
||||
@@ -1040,6 +1040,61 @@ describe('AgentService', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('Transcript Agent', () => {
|
||||
test('allows one Transcript Agent per team, including when it is disabled', async () => {
|
||||
const svc = new AgentService()
|
||||
const team = await prisma.team.create({ data: { name: 'Transcript agent team' } })
|
||||
const params = {
|
||||
teamId: team.id,
|
||||
type: 'transcription' as const,
|
||||
name: 'Transcript Agent',
|
||||
avatar: 'custom-transcript-avatar',
|
||||
enabled: false,
|
||||
thinkingLevel: 'off' as const,
|
||||
}
|
||||
|
||||
await expect(svc.createAgent(params)).resolves.toMatchObject({
|
||||
enabled: false,
|
||||
providerId: null,
|
||||
})
|
||||
await expect(svc.createAgent(params)).rejects.toThrow('already exists for this team')
|
||||
expect(await prisma.agent.count({ where: { teamId: team.id, type: 'transcription' } })).toBe(
|
||||
1,
|
||||
)
|
||||
})
|
||||
|
||||
test('provisions and toggles the same read-only agent from the environment', async () => {
|
||||
const svc = new AgentService()
|
||||
const team = await prisma.team.create({ data: { name: 'Managed transcript agent team' } })
|
||||
try {
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', 'false')
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
expect(
|
||||
await prisma.agent.count({ where: { teamId: team.id, type: 'transcription' } }),
|
||||
).toBe(0)
|
||||
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', 'true')
|
||||
await svc.ensureSystemAgents()
|
||||
const [agent] = await svc.listAgents({ teamId: team.id })
|
||||
expect(await svc.toAgentInfo(agent)).toMatchObject({ enabled: true, readOnly: true })
|
||||
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', 'false')
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
const [disabled] = await svc.listAgents({ teamId: team.id })
|
||||
expect(await svc.toAgentInfo(disabled)).toMatchObject({
|
||||
id: agent.id,
|
||||
enabled: false,
|
||||
readOnly: true,
|
||||
})
|
||||
|
||||
vi.stubEnv('ENABLE_TRANSCRIPTION_AGENT', undefined)
|
||||
expect(await svc.toAgentInfo(disabled)).toMatchObject({ enabled: false, readOnly: false })
|
||||
} finally {
|
||||
vi.unstubAllEnvs()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('ensureEmbeddingAgent', () => {
|
||||
test('creates embedding agent when ENABLE_EMBEDDING_AGENT is true', async () => {
|
||||
const db = prisma
|
||||
@@ -1048,7 +1103,7 @@ describe('AgentService', () => {
|
||||
|
||||
process.env.ENABLE_EMBEDDING_AGENT = 'true'
|
||||
try {
|
||||
await svc.ensureEmbeddingAgentForTeam(team.id)
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
const agent = await db.agent.findFirst({
|
||||
where: { teamId: team.id, type: 'embedding' },
|
||||
include: { user: true, skills: { include: { skill: true } }, mcpServers: true },
|
||||
@@ -1063,7 +1118,7 @@ describe('AgentService', () => {
|
||||
expect(info.readOnly).toBe(true)
|
||||
|
||||
// Ensure idempotency
|
||||
await svc.ensureEmbeddingAgentForTeam(team.id)
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
const count = await db.agent.count({
|
||||
where: { teamId: team.id, type: 'embedding' },
|
||||
})
|
||||
@@ -1093,7 +1148,7 @@ describe('AgentService', () => {
|
||||
|
||||
process.env.ENABLE_EMBEDDING_AGENT = 'true'
|
||||
try {
|
||||
await svc.ensureEmbeddingAgentForTeam(team.id)
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
const agent = await db.agent.findFirst({
|
||||
where: { teamId: team.id, type: 'embedding' },
|
||||
include: { user: true, skills: { include: { skill: true } }, mcpServers: true },
|
||||
@@ -1113,7 +1168,7 @@ describe('AgentService', () => {
|
||||
const team = await db.team.create({ data: { name: 'Team No Agent' } })
|
||||
|
||||
delete process.env.ENABLE_EMBEDDING_AGENT
|
||||
await svc.ensureEmbeddingAgentForTeam(team.id)
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
const agent = await db.agent.findFirst({
|
||||
where: { teamId: team.id, type: 'embedding' },
|
||||
})
|
||||
@@ -1127,7 +1182,7 @@ describe('AgentService', () => {
|
||||
|
||||
process.env.ENABLE_EMBEDDING_AGENT = 'false'
|
||||
try {
|
||||
await svc.ensureEmbeddingAgentForTeam(team.id)
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
const agent = await db.agent.findFirst({
|
||||
where: { teamId: team.id, type: 'embedding' },
|
||||
})
|
||||
@@ -1157,7 +1212,7 @@ describe('AgentService', () => {
|
||||
|
||||
process.env.ENABLE_EMBEDDING_AGENT = 'false'
|
||||
try {
|
||||
await svc.ensureEmbeddingAgentForTeam(team.id)
|
||||
await svc.ensureSystemAgentsForTeam(team.id)
|
||||
const agent = await db.agent.findFirst({
|
||||
where: { teamId: team.id, type: 'embedding' },
|
||||
include: { user: true, skills: { include: { skill: true } }, mcpServers: true },
|
||||
@@ -1172,7 +1227,7 @@ describe('AgentService', () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('ensureSystemEmbeddingAgents updates all teams when ENABLE_EMBEDDING_AGENT is false', async () => {
|
||||
test('ensureSystemAgents updates all teams when ENABLE_EMBEDDING_AGENT is false', async () => {
|
||||
const db = prisma
|
||||
const svc = new AgentService()
|
||||
const { team: team1 } = await setupTestData(db)
|
||||
@@ -1194,7 +1249,7 @@ describe('AgentService', () => {
|
||||
|
||||
process.env.ENABLE_EMBEDDING_AGENT = 'false'
|
||||
try {
|
||||
await svc.ensureSystemEmbeddingAgents()
|
||||
await svc.ensureSystemAgents()
|
||||
|
||||
const a1 = await db.agent.findFirst({ where: { teamId: team1.id, type: 'embedding' } })
|
||||
const a2 = await db.agent.findFirst({ where: { teamId: team2.id, type: 'embedding' } })
|
||||
|
||||
@@ -22,6 +22,7 @@ import AdmZip from 'adm-zip'
|
||||
import { getAllowedAgentRoles } from './permissions'
|
||||
import { getPresetAvatarBuffer, getPresetAvatarStorageKey, isPresetAvatarId } from './presets'
|
||||
import { agentSessionService } from './session-service'
|
||||
import { getSystemAgentSetting } from './system-agents'
|
||||
|
||||
const agentInclude = {
|
||||
user: true,
|
||||
@@ -58,7 +59,27 @@ function extractS3Key(urlOrKey?: string | null): string | null | undefined {
|
||||
export class AgentService {
|
||||
private skillContentCache = new Map<string, string>()
|
||||
|
||||
constructor(private readonly prismaClient: typeof prisma = prisma) {}
|
||||
constructor(private readonly prismaClient: typeof prisma | Prisma.TransactionClient = prisma) {}
|
||||
|
||||
private inTransaction<T>(work: (tx: Prisma.TransactionClient) => Promise<T>): Promise<T> {
|
||||
const db = this.prismaClient
|
||||
return '$transaction' in db ? db.$transaction(work) : work(db)
|
||||
}
|
||||
|
||||
private async requireUniqueAgentType(
|
||||
tx: Prisma.TransactionClient,
|
||||
teamId: string,
|
||||
type: AgentType,
|
||||
agentId?: string,
|
||||
): Promise<void> {
|
||||
if (type === 'chat') return
|
||||
|
||||
await tx.$queryRaw`SELECT id FROM teams WHERE id = ${teamId} FOR UPDATE`
|
||||
const existing = await tx.agent.findFirst({
|
||||
where: { type, teamId, id: agentId ? { not: agentId } : undefined },
|
||||
})
|
||||
if (existing) throw new Error(`Agent of type ${type} already exists for this team`)
|
||||
}
|
||||
|
||||
async getSkillContent(skillId: string): Promise<string> {
|
||||
const skill = await this.prismaClient.skill.findUnique({
|
||||
@@ -150,18 +171,6 @@ export class AgentService {
|
||||
deniedTools,
|
||||
} = params
|
||||
|
||||
if (type === 'embedding' || type === 'autofill') {
|
||||
const existing = await this.prismaClient.agent.findFirst({
|
||||
where: {
|
||||
type,
|
||||
teamId,
|
||||
},
|
||||
})
|
||||
if (existing) {
|
||||
throw new Error(`Agent of type ${type} already exists for this team`)
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'chat' || type === 'autofill') {
|
||||
if (!providerId || !modelId) {
|
||||
throw new Error('providerId and modelId are required for chat/autofill agents')
|
||||
@@ -192,11 +201,12 @@ export class AgentService {
|
||||
imageKey = extractS3Key(avatar)
|
||||
}
|
||||
|
||||
return this.prismaClient.$transaction(async (tx) => {
|
||||
return this.inTransaction(async (tx) => {
|
||||
const team = await tx.team.findUnique({
|
||||
where: { id: teamId },
|
||||
})
|
||||
if (!team) throw new Error('team not found')
|
||||
await this.requireUniqueAgentType(tx, teamId, type)
|
||||
|
||||
if (runnerId) {
|
||||
const runner = await tx.runner.findFirst({
|
||||
@@ -298,19 +308,6 @@ export class AgentService {
|
||||
|
||||
if (!agent) throw new Error('agent not found')
|
||||
|
||||
if (type === 'embedding' || type === 'autofill') {
|
||||
const existing = await this.prismaClient.agent.findFirst({
|
||||
where: {
|
||||
type,
|
||||
id: { not: agentId },
|
||||
teamId: agent.teamId,
|
||||
},
|
||||
})
|
||||
if (existing) {
|
||||
throw new Error(`Agent of type ${type} already exists for this team`)
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'chat' || type === 'autofill') {
|
||||
if (!providerId || !modelId) {
|
||||
throw new Error('providerId and modelId are required for chat/autofill agents')
|
||||
@@ -364,7 +361,9 @@ export class AgentService {
|
||||
avatarPreset: newAvatarPreset,
|
||||
}
|
||||
|
||||
return this.prismaClient.$transaction(async (tx) => {
|
||||
return this.inTransaction(async (tx) => {
|
||||
await this.requireUniqueAgentType(tx, agent.teamId, type, agentId)
|
||||
|
||||
await tx.user.update({
|
||||
where: { id: agentId },
|
||||
data: {
|
||||
@@ -476,10 +475,7 @@ export class AgentService {
|
||||
*/
|
||||
async toAgentInfo(agent: AgentInfoSource): Promise<AgentInfo> {
|
||||
const config = agent.config as unknown as PrismaJson.AgentConfig
|
||||
const isManagedByEnv =
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
|
||||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
|
||||
const isReadOnly = agent.type === 'embedding' && isManagedByEnv
|
||||
const isReadOnly = getSystemAgentSetting(agent.type) !== undefined
|
||||
|
||||
return {
|
||||
id: agent.id,
|
||||
@@ -652,57 +648,43 @@ export class AgentService {
|
||||
)
|
||||
}
|
||||
|
||||
async ensureSystemEmbeddingAgents(): Promise<void> {
|
||||
const envVal = process.env.ENABLE_EMBEDDING_AGENT
|
||||
if (envVal !== 'true' && envVal !== 'false') {
|
||||
return
|
||||
}
|
||||
async ensureSystemAgents(): Promise<void> {
|
||||
if (!getSystemAgentSetting('embedding') && !getSystemAgentSetting('transcription')) return
|
||||
|
||||
const teams = await this.prismaClient.team.findMany({
|
||||
orderBy: { id: 'desc' },
|
||||
select: { id: true },
|
||||
})
|
||||
|
||||
for (const team of teams) {
|
||||
await this.ensureEmbeddingAgentForTeam(team.id)
|
||||
await this.ensureSystemAgentsForTeam(team.id)
|
||||
}
|
||||
}
|
||||
|
||||
async ensureEmbeddingAgentForTeam(teamId: string): Promise<void> {
|
||||
const envVal = process.env.ENABLE_EMBEDDING_AGENT
|
||||
if (envVal !== 'true' && envVal !== 'false') {
|
||||
return
|
||||
}
|
||||
async ensureSystemAgentsForTeam(teamId: string): Promise<void> {
|
||||
for (const type of ['embedding', 'transcription'] as const) {
|
||||
const setting = getSystemAgentSetting(type)
|
||||
if (!setting) continue
|
||||
|
||||
const existing = await this.prismaClient.agent.findFirst({
|
||||
where: {
|
||||
teamId,
|
||||
type: 'embedding',
|
||||
},
|
||||
})
|
||||
await this.inTransaction(async (tx) => {
|
||||
await tx.$queryRaw`SELECT id FROM teams WHERE id = ${teamId} FOR UPDATE`
|
||||
const existing = await tx.agent.findFirst({
|
||||
where: { teamId, type },
|
||||
})
|
||||
|
||||
if (envVal === 'true') {
|
||||
if (!existing) {
|
||||
await this.createAgent({
|
||||
teamId,
|
||||
name: 'embedding-agent',
|
||||
type: 'embedding',
|
||||
avatar: 'avatar-1',
|
||||
thinkingLevel: 'off',
|
||||
enabled: true,
|
||||
})
|
||||
} else if (!existing.enabled) {
|
||||
await this.prismaClient.agent.update({
|
||||
where: { id: existing.id },
|
||||
data: { enabled: true },
|
||||
})
|
||||
}
|
||||
} else if (envVal === 'false') {
|
||||
if (existing && existing.enabled) {
|
||||
await this.prismaClient.agent.update({
|
||||
where: { id: existing.id },
|
||||
data: { enabled: false },
|
||||
})
|
||||
}
|
||||
if (existing && existing.enabled !== setting.enabled) {
|
||||
await tx.agent.update({ where: { id: existing.id }, data: { enabled: setting.enabled } })
|
||||
} else if (!existing && setting.enabled) {
|
||||
await new AgentService(tx).createAgent({
|
||||
teamId,
|
||||
name: type === 'embedding' ? 'embedding-agent' : setting.name,
|
||||
type,
|
||||
avatar: 'avatar-1',
|
||||
thinkingLevel: 'off',
|
||||
enabled: true,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { AgentType } from '@shumai/dtos'
|
||||
|
||||
const systemAgentSettings = {
|
||||
embedding: { envKey: 'ENABLE_EMBEDDING_AGENT', name: 'Embedding agent' },
|
||||
transcription: { envKey: 'ENABLE_TRANSCRIPTION_AGENT', name: 'Transcript Agent' },
|
||||
} as const
|
||||
|
||||
export function getSystemAgentSetting(type: AgentType) {
|
||||
if (type !== 'embedding' && type !== 'transcription') return undefined
|
||||
|
||||
const { envKey, name } = systemAgentSettings[type]
|
||||
const value = process.env[envKey]
|
||||
if (value !== 'true' && value !== 'false') return undefined
|
||||
|
||||
return { name, enabled: value === 'true' }
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { prisma } from '@shumai/db'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
|
||||
export interface IntegrationEnvKeys {
|
||||
url: string[]
|
||||
@@ -12,6 +13,7 @@ export interface IntegrationDefinition<TKey extends keyof PrismaJson.Settings> {
|
||||
name: string
|
||||
settingsKey: TKey
|
||||
envKeys: IntegrationEnvKeys
|
||||
requireSettingsRead?: boolean
|
||||
}
|
||||
|
||||
export interface ResolvedIntegrationConfig {
|
||||
@@ -45,7 +47,7 @@ function getFirstEnvValue(keys?: string[]): string | undefined {
|
||||
|
||||
export async function resolveIntegrationConfig<TKey extends keyof PrismaJson.Settings>(
|
||||
def: IntegrationDefinition<TKey>,
|
||||
teamId?: string,
|
||||
teamId?: string | null,
|
||||
): Promise<ResolvedIntegrationConfig> {
|
||||
const envUrl = getFirstEnvValue(def.envKeys.url)
|
||||
const envUsername = getFirstEnvValue(def.envKeys.username)
|
||||
@@ -60,12 +62,13 @@ export async function resolveIntegrationConfig<TKey extends keyof PrismaJson.Set
|
||||
}
|
||||
}
|
||||
|
||||
if (teamId) {
|
||||
if (teamId || teamId === null) {
|
||||
try {
|
||||
const team = await prisma.team.findUnique({
|
||||
where: { id: teamId },
|
||||
select: { settings: true },
|
||||
})
|
||||
// Instance-wide consumers use the single team when they have no team ID.
|
||||
const team =
|
||||
teamId === null
|
||||
? await prisma.team.findFirst({ orderBy: { id: 'desc' }, select: { settings: true } })
|
||||
: await prisma.team.findUnique({ where: { id: teamId }, select: { settings: true } })
|
||||
const teamSettings = team?.settings as PrismaJson.Settings | null
|
||||
const serviceSettings = teamSettings?.[def.settingsKey] as
|
||||
{ url?: string; username?: string; password?: string } | undefined
|
||||
@@ -79,6 +82,7 @@ export async function resolveIntegrationConfig<TKey extends keyof PrismaJson.Set
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (def.requireSettingsRead) throw err
|
||||
logger.error({ err, teamId }, `Failed to load team ${def.name} settings`)
|
||||
}
|
||||
}
|
||||
@@ -108,9 +112,9 @@ export async function updateIntegrationSettings<TKey extends keyof PrismaJson.Se
|
||||
): Promise<IntegrationSettingsResponse> {
|
||||
const currentConfig = await resolveIntegrationConfig(def, teamId)
|
||||
if (currentConfig.isEnv) {
|
||||
throw new Error(
|
||||
`${def.name} settings are configured via environment variables and cannot be edited`,
|
||||
)
|
||||
throw new HTTPException(400, {
|
||||
message: `${def.name} settings are configured via environment variables and cannot be edited`,
|
||||
})
|
||||
}
|
||||
|
||||
const team = await prisma.team.findUnique({
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { embeddingServerService } from './embedding-server'
|
||||
|
||||
describe('Embedding server settings', () => {
|
||||
setupTestDbHooks()
|
||||
let teamId: string
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.stubEnv('EMBEDDING_PROVIDER', undefined)
|
||||
vi.stubEnv('GEMMA_EMBEDDING_OPENAI_BASE_URL', undefined)
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'Embedding integration', settings: { appearance: { hideAgent: true } } },
|
||||
})
|
||||
teamId = team.id
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs()
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('saves and clears the local URL, preserving other settings', async () => {
|
||||
await expect(
|
||||
embeddingServerService.updateSettings(teamId, ' http://embedding:9379/ '),
|
||||
).resolves.toEqual({
|
||||
url: 'http://embedding:9379',
|
||||
isEnvConfigured: false,
|
||||
})
|
||||
await expect(embeddingServerService.resolveRuntimeConfig(teamId)).resolves.toEqual({
|
||||
provider: 'gemma-embedding-2-openai',
|
||||
embeddingEndpoint: 'http://embedding:9379/v1/embeddings',
|
||||
transcriptionEndpoint: 'http://embedding:9379/v1/audio/transcriptions',
|
||||
})
|
||||
await expect(embeddingServerService.resolveRuntimeConfig()).resolves.toMatchObject({
|
||||
provider: 'gemma-embedding-2-openai',
|
||||
})
|
||||
await embeddingServerService.updateSettings(teamId, ' ')
|
||||
await expect(embeddingServerService.getSettings(teamId)).resolves.toMatchObject({
|
||||
url: undefined,
|
||||
isEnvConfigured: false,
|
||||
})
|
||||
await expect(embeddingServerService.resolveRuntimeConfig(teamId)).resolves.toMatchObject({
|
||||
provider: 'gemini-embedding-2',
|
||||
})
|
||||
const team = await prisma.team.findUniqueOrThrow({ where: { id: teamId } })
|
||||
expect(team.settings).toEqual({ appearance: { hideAgent: true } })
|
||||
})
|
||||
|
||||
it('keeps Compose environment configuration read-only and tests its effective URL', async () => {
|
||||
await embeddingServerService.updateSettings(teamId, 'https://saved.example/v1')
|
||||
vi.stubEnv('GEMMA_EMBEDDING_OPENAI_BASE_URL', 'http://embedding-server:9379/v1/')
|
||||
vi.stubEnv('EMBEDDING_PROVIDER', 'gemma-embedding-2-openai')
|
||||
const fetch = vi
|
||||
.spyOn(globalThis, 'fetch')
|
||||
.mockResolvedValue(Response.json({ data: [{ id: 'embeddinggemma-2' }] }))
|
||||
await expect(embeddingServerService.getSettings(teamId)).resolves.toEqual({
|
||||
url: 'http://embedding-server:9379/v1',
|
||||
isEnvConfigured: true,
|
||||
})
|
||||
await expect(embeddingServerService.resolveRuntimeConfig(teamId)).resolves.toEqual({
|
||||
provider: 'gemma-embedding-2-openai',
|
||||
embeddingEndpoint: 'http://embedding-server:9379/v1/embeddings',
|
||||
transcriptionEndpoint: 'http://embedding-server:9379/v1/audio/transcriptions',
|
||||
})
|
||||
await expect(embeddingServerService.updateSettings(teamId, '')).rejects.toMatchObject({
|
||||
status: 400,
|
||||
})
|
||||
await expect(
|
||||
embeddingServerService.testConnection(teamId, 'https://draft.example'),
|
||||
).resolves.toEqual({ ok: true })
|
||||
expect(fetch).toHaveBeenCalledExactlyOnceWith(
|
||||
'http://embedding-server:9379/v1/models',
|
||||
expect.objectContaining({ redirect: 'error' }),
|
||||
)
|
||||
vi.stubEnv('GEMMA_EMBEDDING_OPENAI_BASE_URL', undefined)
|
||||
await expect(embeddingServerService.getSettings(teamId)).resolves.toMatchObject({
|
||||
url: 'https://saved.example/v1',
|
||||
})
|
||||
})
|
||||
|
||||
it('respects explicit provider selection and accepts a full embedding endpoint', async () => {
|
||||
await embeddingServerService.updateSettings(
|
||||
teamId,
|
||||
'https://embedding.example/custom/v1/embeddings/',
|
||||
)
|
||||
vi.stubEnv('EMBEDDING_PROVIDER', 'gemini-embedding-2')
|
||||
await expect(embeddingServerService.resolveRuntimeConfig(teamId)).resolves.toEqual({
|
||||
provider: 'gemini-embedding-2',
|
||||
embeddingEndpoint: 'https://embedding.example/custom/v1/embeddings',
|
||||
transcriptionEndpoint: 'https://embedding.example/custom/v1/audio/transcriptions',
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
'file:///tmp/server',
|
||||
'https://user:pass@embedding.example',
|
||||
'https://example.test?token=x',
|
||||
'embedding:9379',
|
||||
])('rejects an invalid server URL (%s)', async (url) => {
|
||||
await expect(embeddingServerService.updateSettings(teamId, url)).rejects.toMatchObject({
|
||||
status: 400,
|
||||
})
|
||||
await expect(embeddingServerService.testConnection(teamId, url)).rejects.toMatchObject({
|
||||
status: 400,
|
||||
})
|
||||
})
|
||||
|
||||
it('tests an unsaved URL without changing settings and detects an incompatible endpoint', async () => {
|
||||
const fetch = vi
|
||||
.spyOn(globalThis, 'fetch')
|
||||
.mockResolvedValue(Response.json({ data: [{ id: 'another-model' }] }))
|
||||
await expect(
|
||||
embeddingServerService.testConnection(teamId, 'https://draft.example'),
|
||||
).resolves.toMatchObject({ ok: false })
|
||||
expect(fetch).toHaveBeenCalledWith('https://draft.example/v1/models', expect.any(Object))
|
||||
await expect(embeddingServerService.getSettings(teamId)).resolves.toMatchObject({
|
||||
url: undefined,
|
||||
})
|
||||
})
|
||||
|
||||
it('reports unreachable and HTTP failure responses', async () => {
|
||||
const fetch = vi
|
||||
.spyOn(globalThis, 'fetch')
|
||||
.mockRejectedValueOnce(new Error('socket error'))
|
||||
.mockResolvedValueOnce(new Response(null, { status: 401 }))
|
||||
await expect(embeddingServerService.testConnection(teamId)).resolves.toMatchObject({
|
||||
ok: false,
|
||||
})
|
||||
expect(fetch).not.toHaveBeenCalled()
|
||||
await expect(
|
||||
embeddingServerService.testConnection(teamId, 'https://draft.example'),
|
||||
).resolves.toMatchObject({ ok: false })
|
||||
await expect(
|
||||
embeddingServerService.testConnection(teamId, 'https://draft.example'),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
error: expect.stringContaining('401'),
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,97 @@
|
||||
import {
|
||||
resolveIntegrationConfig,
|
||||
updateIntegrationSettings,
|
||||
type IntegrationDefinition,
|
||||
} from '@shumai/core/src/integrations/helper'
|
||||
import {
|
||||
updateEmbeddingServerSettingsRequestSchema,
|
||||
type EmbeddingServerSettingsResponse,
|
||||
} from '@shumai/dtos'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
import { z } from 'zod'
|
||||
|
||||
const integration: IntegrationDefinition<'embeddingServer'> = {
|
||||
name: 'Embedding server',
|
||||
settingsKey: 'embeddingServer',
|
||||
envKeys: { url: ['GEMMA_EMBEDDING_OPENAI_BASE_URL'] },
|
||||
requireSettingsRead: true,
|
||||
}
|
||||
|
||||
export const LOCAL_EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
|
||||
const defaultLocalBaseUrl = 'http://localhost:9379/v1'
|
||||
|
||||
function getOpenAiBaseUrl(url: string): string {
|
||||
const baseUrl = url.replace(/\/embeddings$/, '')
|
||||
return baseUrl.endsWith('/v1') ? baseUrl : `${baseUrl}/v1`
|
||||
}
|
||||
|
||||
function getEmbeddingEndpoint(url: string): string {
|
||||
return url.endsWith('/embeddings') ? url : `${getOpenAiBaseUrl(url)}/embeddings`
|
||||
}
|
||||
|
||||
const modelListSchema = z.object({
|
||||
data: z.array(z.object({ id: z.string() })),
|
||||
})
|
||||
|
||||
export class EmbeddingServerService {
|
||||
async resolveRuntimeConfig(teamId?: string, providerOverride?: string) {
|
||||
const { url, isEnv } = await resolveIntegrationConfig(integration, teamId ?? null)
|
||||
const provider =
|
||||
providerOverride ||
|
||||
process.env.EMBEDDING_PROVIDER ||
|
||||
(url && !isEnv ? LOCAL_EMBEDDING_PROVIDER : 'gemini-embedding-2')
|
||||
const localUrl = url || defaultLocalBaseUrl
|
||||
return {
|
||||
provider,
|
||||
embeddingEndpoint: getEmbeddingEndpoint(localUrl),
|
||||
transcriptionEndpoint: `${getOpenAiBaseUrl(localUrl)}/audio/transcriptions`,
|
||||
}
|
||||
}
|
||||
|
||||
async getSettings(teamId: string): Promise<EmbeddingServerSettingsResponse> {
|
||||
const { url, isEnv } = await resolveIntegrationConfig(integration, teamId)
|
||||
return { url, isEnvConfigured: isEnv }
|
||||
}
|
||||
|
||||
async updateSettings(teamId: string, url: string): Promise<EmbeddingServerSettingsResponse> {
|
||||
const { url: validUrl } = this.validateUrl(url)
|
||||
const settings = await updateIntegrationSettings(integration, teamId, { url: validUrl })
|
||||
return { url: settings.url, isEnvConfigured: settings.isEnvConfigured }
|
||||
}
|
||||
|
||||
async testConnection(teamId: string, url?: string): Promise<{ ok: boolean; error?: string }> {
|
||||
const config = await resolveIntegrationConfig(integration, teamId)
|
||||
const target = config.isEnv || url === undefined ? config.url : this.validateUrl(url).url
|
||||
if (!target) return { ok: false, error: 'Server URL is required' }
|
||||
|
||||
const endpoint = getEmbeddingEndpoint(target.replace(/\/+$/, ''))
|
||||
try {
|
||||
const response = await fetch(endpoint.replace(/\/embeddings$/, '/models'), {
|
||||
redirect: 'error',
|
||||
signal: AbortSignal.timeout(5000),
|
||||
})
|
||||
if (!response.ok) {
|
||||
await response.body?.cancel()
|
||||
return { ok: false, error: `Server returned HTTP ${response.status}` }
|
||||
}
|
||||
|
||||
const models = modelListSchema.safeParse(await response.json().catch(() => undefined))
|
||||
if (!models.success || !models.data.data.some(({ id }) => id === 'embeddinggemma-2')) {
|
||||
return { ok: false, error: 'Server does not advertise the embeddinggemma-2 model' }
|
||||
}
|
||||
return { ok: true }
|
||||
} catch {
|
||||
return { ok: false, error: 'Could not reach the embedding server' }
|
||||
}
|
||||
}
|
||||
|
||||
private validateUrl(url: string) {
|
||||
const result = updateEmbeddingServerSettingsRequestSchema.safeParse({ url })
|
||||
if (!result.success) {
|
||||
throw new HTTPException(400, { message: result.error.issues[0]?.message })
|
||||
}
|
||||
return result.data
|
||||
}
|
||||
}
|
||||
|
||||
export const embeddingServerService = new EmbeddingServerService()
|
||||
@@ -1,10 +0,0 @@
|
||||
export function getGemmaOpenAiBaseUrl(): string {
|
||||
const baseUrl = process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL || 'http://localhost:9379/v1'
|
||||
const url = baseUrl.replace(/\/+$/, '').replace(/\/embeddings$/, '')
|
||||
return url.endsWith('/v1') ? url : `${url}/v1`
|
||||
}
|
||||
|
||||
export function getGemmaEmbeddingEndpoint(): string {
|
||||
const baseUrl = process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL?.replace(/\/+$/, '')
|
||||
return baseUrl?.endsWith('/embeddings') ? baseUrl : `${getGemmaOpenAiBaseUrl()}/embeddings`
|
||||
}
|
||||
@@ -4,19 +4,26 @@ import { LruTtlCache } from '@shumai/core/src/cache/lru-ttl-cache'
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
import sharp from 'sharp'
|
||||
import { getGemmaEmbeddingEndpoint } from './gemma-embedding-endpoint'
|
||||
import { embeddingServerService, LOCAL_EMBEDDING_PROVIDER } from './embedding-server'
|
||||
|
||||
export function getImageEmbeddingDimensions(): 768 | 1536 {
|
||||
return process.env.EMBEDDING_PROVIDER === 'gemma-embedding-2-openai' ? 768 : 1536
|
||||
export function getImageEmbeddingDimensions(provider: string): 768 | 1536 {
|
||||
return provider === LOCAL_EMBEDDING_PROVIDER ? 768 : 1536
|
||||
}
|
||||
|
||||
export class ImageEmbeddingService {
|
||||
private readonly cache = new LruTtlCache<string, number[]>(100)
|
||||
|
||||
async generateEmbedding(image: string, teamId: string): Promise<number[]> {
|
||||
const dimensions = getImageEmbeddingDimensions()
|
||||
const { provider, embeddingEndpoint } =
|
||||
await embeddingServerService.resolveRuntimeConfig(teamId)
|
||||
const dimensions = getImageEmbeddingDimensions(provider)
|
||||
const digest = createHash('sha256').update(image).digest('hex')
|
||||
const cacheKey = `${teamId}:${dimensions}:${digest}`
|
||||
const cacheKey = JSON.stringify([
|
||||
teamId,
|
||||
dimensions,
|
||||
dimensions === 768 ? embeddingEndpoint : null,
|
||||
digest,
|
||||
])
|
||||
const cached = this.cache.get(cacheKey)
|
||||
if (cached) return cached
|
||||
|
||||
@@ -37,7 +44,7 @@ export class ImageEmbeddingService {
|
||||
const signal = AbortSignal.timeout(15000)
|
||||
embedding =
|
||||
dimensions === 768
|
||||
? await this.embedWithGemma(image, signal)
|
||||
? await this.embedWithGemma(embeddingEndpoint, image, signal)
|
||||
: await this.embedWithGemini(image, signal)
|
||||
if (
|
||||
!embedding ||
|
||||
@@ -73,8 +80,8 @@ export class ImageEmbeddingService {
|
||||
return response.embeddings?.[0]?.values
|
||||
}
|
||||
|
||||
private async embedWithGemma(image: string, signal: AbortSignal) {
|
||||
const response = await fetch(getGemmaEmbeddingEndpoint(), {
|
||||
private async embedWithGemma(endpoint: string, image: string, signal: AbortSignal) {
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
|
||||
@@ -9,6 +9,7 @@ import { PaginatedData, decodeCursor, encodeCursor, PageInfo } from '@shumai/cor
|
||||
import { generateSearchNgrams } from '@shumai/core/src/utils/ngram'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
import { getImageEmbeddingDimensions, imageEmbeddingService } from './image-embedding'
|
||||
import { embeddingServerService } from './embedding-server'
|
||||
import { SqlQueryBuilder } from './sql-query-builder'
|
||||
import { TextEmbeddingService, textEmbeddingService } from './text-embedding'
|
||||
|
||||
@@ -266,7 +267,7 @@ export class SearchService {
|
||||
if (!project) throw new HTTPException(404, { message: 'Project folder not found.' })
|
||||
|
||||
await this.requireEmbeddingAgent(project.teamId)
|
||||
const dimensions = getImageEmbeddingDimensions()
|
||||
let dimensions: 768 | 1536
|
||||
let vector: string
|
||||
let excludeAssetId: string | undefined
|
||||
if (req.sourceAssetId) {
|
||||
@@ -274,6 +275,8 @@ export class SearchService {
|
||||
throw new HTTPException(400, { message: 'Find similar requires the project root folder.' })
|
||||
}
|
||||
|
||||
const { provider } = await embeddingServerService.resolveRuntimeConfig(project.teamId)
|
||||
dimensions = getImageEmbeddingDimensions(provider)
|
||||
const column = dimensions === 768 ? Prisma.sql`embedding_768` : Prisma.sql`embedding`
|
||||
const [source] = await this.prismaClient.$queryRaw<
|
||||
{ vector: string | null; excludeAssetId: string }[]
|
||||
@@ -302,9 +305,9 @@ export class SearchService {
|
||||
vector = source.vector
|
||||
excludeAssetId = source.excludeAssetId
|
||||
} else if (req.image) {
|
||||
vector = JSON.stringify(
|
||||
await imageEmbeddingService.generateEmbedding(req.image, project.teamId),
|
||||
)
|
||||
const embedding = await imageEmbeddingService.generateEmbedding(req.image, project.teamId)
|
||||
dimensions = embedding.length === 768 ? 768 : 1536
|
||||
vector = JSON.stringify(embedding)
|
||||
} else {
|
||||
throw new HTTPException(400, { message: 'Provide a search image or source asset.' })
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GoogleGenAI } from '@google/genai'
|
||||
import { LruTtlCache } from '@shumai/core/src/cache/lru-ttl-cache'
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import { getGemmaEmbeddingEndpoint } from './gemma-embedding-endpoint'
|
||||
import { embeddingServerService, LOCAL_EMBEDDING_PROVIDER } from './embedding-server'
|
||||
|
||||
export interface TextEmbeddingUsage {
|
||||
model: string
|
||||
@@ -46,12 +46,19 @@ export class TextEmbeddingService {
|
||||
throw new Error('Text to embed must not be empty')
|
||||
}
|
||||
|
||||
const provider = options?.provider || process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
|
||||
const model =
|
||||
options?.model ||
|
||||
(provider === 'gemma-embedding-2-openai' ? 'embeddinggemma-2' : 'gemini-embedding-2')
|
||||
const { provider, embeddingEndpoint } = await embeddingServerService.resolveRuntimeConfig(
|
||||
options?.teamId,
|
||||
options?.provider,
|
||||
)
|
||||
const isLocal = provider === LOCAL_EMBEDDING_PROVIDER
|
||||
const model = options?.model || (isLocal ? 'embeddinggemma-2' : 'gemini-embedding-2')
|
||||
|
||||
const cacheKey = `${provider}:${model}:${trimmedText}`
|
||||
const cacheKey = JSON.stringify([
|
||||
provider,
|
||||
isLocal ? embeddingEndpoint : null,
|
||||
model,
|
||||
trimmedText,
|
||||
])
|
||||
if (!options?.skipCache) {
|
||||
const cachedVector = this.cache.get(cacheKey)
|
||||
if (cachedVector) {
|
||||
@@ -67,8 +74,8 @@ export class TextEmbeddingService {
|
||||
const signal = options?.signal ?? AbortSignal.timeout(15000)
|
||||
|
||||
let result: TextEmbeddingResult
|
||||
if (provider === 'gemma-embedding-2-openai') {
|
||||
result = await this.callGemmaEmbeddingServer(trimmedText, model, signal)
|
||||
if (isLocal) {
|
||||
result = await this.callGemmaEmbeddingServer(embeddingEndpoint, trimmedText, model, signal)
|
||||
} else {
|
||||
result = await this.callGeminiEmbedding(trimmedText, model, signal)
|
||||
}
|
||||
@@ -140,11 +147,12 @@ export class TextEmbeddingService {
|
||||
}
|
||||
|
||||
private async callGemmaEmbeddingServer(
|
||||
endpoint: string,
|
||||
text: string,
|
||||
model: string,
|
||||
signal: AbortSignal,
|
||||
): Promise<TextEmbeddingResult> {
|
||||
const response = await fetch(getGemmaEmbeddingEndpoint(), {
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
|
||||
@@ -368,6 +368,8 @@ describe('TeamService', () => {
|
||||
const settings = await teamService.getSettings(team.id)
|
||||
expect(settings).toEqual({
|
||||
semanticSearchEnabled: false,
|
||||
transcriptionAgentManagedByEnv: false,
|
||||
embeddingServer: { url: undefined, isEnvConfigured: false },
|
||||
transcode: {
|
||||
videoStrategy: 'best_match',
|
||||
videoResolutions: ['480p', '720p', '1080p', '1440p', '2160p'],
|
||||
@@ -404,6 +406,8 @@ describe('TeamService', () => {
|
||||
expect(newSettings).toEqual({
|
||||
theme: 'dark',
|
||||
semanticSearchEnabled: false,
|
||||
transcriptionAgentManagedByEnv: false,
|
||||
embeddingServer: { url: undefined, isEnvConfigured: false },
|
||||
transcode: {
|
||||
videoStrategy: 'best_match',
|
||||
videoResolutions: ['480p', '720p', '1080p', '1440p', '2160p'],
|
||||
@@ -449,6 +453,8 @@ describe('TeamService', () => {
|
||||
const finalSettings = await teamService.getSettings(team.id)
|
||||
expect(finalSettings).toEqual({
|
||||
theme: 'dark',
|
||||
transcriptionAgentManagedByEnv: false,
|
||||
embeddingServer: { url: undefined, isEnvConfigured: false },
|
||||
transcode: {
|
||||
videoStrategy: 'multi',
|
||||
videoResolutions: ['720p', '1080p'],
|
||||
|
||||
@@ -7,8 +7,10 @@ import { getAvatarUrl } from '@shumai/core/src/user/avatar'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
import { getAllowedAgentRoles } from '@shumai/core/src/agent/permissions'
|
||||
import { AgentService, agentService } from '@shumai/core/src/agent/agent'
|
||||
import { getSystemAgentSetting } from '@shumai/core/src/agent/system-agents'
|
||||
import { turntableService } from '@shumai/core/src/turntable/turntable'
|
||||
import { gotenbergService } from '@shumai/core/src/gotenberg/gotenberg'
|
||||
import { embeddingServerService } from '@shumai/core/src/search/embedding-server'
|
||||
import {
|
||||
getArchiveStorageConfig,
|
||||
isArchiveStorageEnabled,
|
||||
@@ -50,7 +52,7 @@ export class TeamService {
|
||||
},
|
||||
})
|
||||
await providerService.initBuiltinProviders(team.id)
|
||||
await agentService.ensureEmbeddingAgentForTeam(team.id)
|
||||
await agentService.ensureSystemAgentsForTeam(team.id)
|
||||
}
|
||||
|
||||
return team
|
||||
@@ -94,8 +96,7 @@ export class TeamService {
|
||||
// but the TransactionClient is compatible with the methods we use.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await new ProviderService(tx as any).initBuiltinProviders(team.id)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await new AgentService(tx as any).ensureEmbeddingAgentForTeam(team.id)
|
||||
await new AgentService(tx).ensureSystemAgentsForTeam(team.id)
|
||||
|
||||
return this.toTeamInfo(updatedTeam)
|
||||
})
|
||||
@@ -359,6 +360,8 @@ export class TeamService {
|
||||
|
||||
settings.turntable = await turntableService.getSettings(teamId)
|
||||
settings.gotenberg = await gotenbergService.getSettings(teamId)
|
||||
settings.embeddingServer = await embeddingServerService.getSettings(teamId)
|
||||
settings.transcriptionAgentManagedByEnv = getSystemAgentSetting('transcription') !== undefined
|
||||
|
||||
const archiveConfig = getArchiveStorageConfig()
|
||||
if (!archiveConfig.enabled) {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import { getGemmaOpenAiBaseUrl } from '@shumai/core/src/search/gemma-embedding-endpoint'
|
||||
import {
|
||||
embeddingServerService,
|
||||
LOCAL_EMBEDDING_PROVIDER,
|
||||
} from '@shumai/core/src/search/embedding-server'
|
||||
import { transcriptLanguageCodeSchema, transcriptLanguagesSchema } from '@shumai/dtos'
|
||||
import { z } from 'zod'
|
||||
|
||||
const transcriptEndpoint = () => `${getGemmaOpenAiBaseUrl()}/audio/transcriptions`
|
||||
|
||||
export function isLocalTranscriptionEnabled(): boolean {
|
||||
return process.env.EMBEDDING_PROVIDER === 'gemma-embedding-2-openai'
|
||||
export async function isLocalTranscriptionEnabled(teamId?: string): Promise<boolean> {
|
||||
const { provider } = await embeddingServerService.resolveRuntimeConfig(teamId)
|
||||
return provider === LOCAL_EMBEDDING_PROVIDER
|
||||
}
|
||||
|
||||
export async function listLocalTranscriptionLanguages() {
|
||||
const response = await fetch(`${transcriptEndpoint()}/languages`, {
|
||||
export async function listLocalTranscriptionLanguages(teamId?: string) {
|
||||
const { transcriptionEndpoint } = await embeddingServerService.resolveRuntimeConfig(teamId)
|
||||
const response = await fetch(`${transcriptionEndpoint}/languages`, {
|
||||
signal: AbortSignal.timeout(5_000),
|
||||
})
|
||||
if (!response.ok) throw new Error(`Transcription languages endpoint returned ${response.status}`)
|
||||
@@ -34,11 +37,13 @@ export class LocalTranscriptionError extends Error {
|
||||
}
|
||||
|
||||
export async function transcribeLocalAudio({
|
||||
teamId,
|
||||
audio,
|
||||
language,
|
||||
model,
|
||||
signal,
|
||||
}: {
|
||||
teamId?: string
|
||||
audio: Blob
|
||||
language: string | null
|
||||
model: string
|
||||
@@ -51,7 +56,8 @@ export async function transcribeLocalAudio({
|
||||
if (language) form.set('language', language)
|
||||
|
||||
const timeout = AbortSignal.timeout(90 * 60 * 1000)
|
||||
const response = await fetch(transcriptEndpoint(), {
|
||||
const { transcriptionEndpoint } = await embeddingServerService.resolveRuntimeConfig(teamId)
|
||||
const response = await fetch(transcriptionEndpoint, {
|
||||
method: 'POST',
|
||||
body: form,
|
||||
redirect: 'error',
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import { getSystemAgentSetting } from '@shumai/core/src/agent/system-agents'
|
||||
import {
|
||||
notifyWorkflowTaskCreated,
|
||||
prisma,
|
||||
@@ -27,10 +28,30 @@ const segmentSelection = { id: true, startMs: true, endMs: true, text: true } as
|
||||
type Segment = { startMs: number; endMs: number; text: string }
|
||||
|
||||
export class TranscriptService {
|
||||
async findEnabledAgent(teamId?: string): Promise<{ id: string } | null> {
|
||||
if (getSystemAgentSetting('transcription')?.enabled === false) return null
|
||||
|
||||
return prisma.agent.findFirst({
|
||||
where: { teamId, type: 'transcription', enabled: true },
|
||||
orderBy: { id: 'desc' },
|
||||
select: { id: true },
|
||||
})
|
||||
}
|
||||
|
||||
async isGenerationEnabled(teamId?: string): Promise<boolean> {
|
||||
return Boolean(
|
||||
(await this.findEnabledAgent(teamId)) && (await isLocalTranscriptionEnabled(teamId)),
|
||||
)
|
||||
}
|
||||
|
||||
async listLanguages() {
|
||||
this.requireEnabled()
|
||||
await this.requireEnabled()
|
||||
return this.loadLanguages()
|
||||
}
|
||||
|
||||
private async loadLanguages(teamId?: string) {
|
||||
try {
|
||||
return await listLocalTranscriptionLanguages()
|
||||
return await listLocalTranscriptionLanguages(teamId)
|
||||
} catch (error) {
|
||||
logger.warn({ err: error }, 'Failed to load local transcription languages')
|
||||
throw new HTTPException(503, { message: 'Transcription languages are unavailable' })
|
||||
@@ -77,11 +98,19 @@ export class TranscriptService {
|
||||
}
|
||||
|
||||
async generate(assetId: string, language: string | null): Promise<GenerateTranscriptResult> {
|
||||
this.requireEnabled()
|
||||
const source = await prisma.asset.findUnique({
|
||||
where: { id: assetId },
|
||||
select: { project: { select: { teamId: true } } },
|
||||
})
|
||||
if (!source?.project) {
|
||||
throw new HTTPException(400, { message: 'Transcripts require a processed video file' })
|
||||
}
|
||||
const { teamId } = source.project
|
||||
await this.requireEnabled(teamId)
|
||||
const saved = await this.findSaved(prisma, assetId, language)
|
||||
if (saved) return saved
|
||||
|
||||
const { model, languages } = await this.listLanguages()
|
||||
const { model, languages } = await this.loadLanguages(teamId)
|
||||
if (language && !languages.some((entry) => entry.code === language)) {
|
||||
throw new HTTPException(400, { message: 'Unsupported transcription language' })
|
||||
}
|
||||
@@ -248,8 +277,8 @@ export class TranscriptService {
|
||||
})
|
||||
}
|
||||
|
||||
private requireEnabled(): void {
|
||||
if (!isLocalTranscriptionEnabled()) {
|
||||
private async requireEnabled(teamId?: string): Promise<void> {
|
||||
if (!(await this.isGenerationEnabled(teamId))) {
|
||||
throw new HTTPException(503, { message: 'Local transcription is disabled' })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[transcription_task_id]` on the table `asset_comments` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterEnum
|
||||
ALTER TYPE "AgentType" ADD VALUE 'transcription';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "asset_comments" ADD COLUMN "transcription_task_id" TEXT;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "asset_comments_transcription_task_id_key" ON "asset_comments"("transcription_task_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "asset_comments" ADD CONSTRAINT "asset_comments_transcription_task_id_fkey" FOREIGN KEY ("transcription_task_id") REFERENCES "workflow_tasks"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -701,6 +701,8 @@ model AssetComment {
|
||||
second Float?
|
||||
sessionId String? @map("session_id")
|
||||
session AgentSession? @relation(fields: [sessionId], references: [id], onDelete: SetNull)
|
||||
transcriptionTaskId String? @unique @map("transcription_task_id")
|
||||
transcriptionTask WorkflowTask? @relation(fields: [transcriptionTaskId], references: [id], onDelete: SetNull)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@ -929,6 +931,7 @@ model WorkflowTask {
|
||||
sessionId String? @map("session_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
transcriptionFailureComment AssetComment?
|
||||
|
||||
@@map("workflow_tasks")
|
||||
@@index([status, heartbeat])
|
||||
@@ -942,6 +945,7 @@ enum AgentType {
|
||||
chat
|
||||
autofill
|
||||
embedding
|
||||
transcription
|
||||
}
|
||||
|
||||
enum AgentSessionType {
|
||||
|
||||
+2
-1
@@ -282,7 +282,8 @@ export type ShareActivityKind = (typeof ShareActivityKind)[keyof typeof ShareAct
|
||||
export const AgentType = {
|
||||
chat: 'chat',
|
||||
autofill: 'autofill',
|
||||
embedding: 'embedding'
|
||||
embedding: 'embedding',
|
||||
transcription: 'transcription'
|
||||
} as const
|
||||
|
||||
export type AgentType = (typeof AgentType)[keyof typeof AgentType]
|
||||
|
||||
+4
-4
File diff suppressed because one or more lines are too long
@@ -5557,6 +5557,7 @@ export const AssetCommentScalarFieldEnum = {
|
||||
annotation: 'annotation',
|
||||
second: 'second',
|
||||
sessionId: 'sessionId',
|
||||
transcriptionTaskId: 'transcriptionTaskId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
assetId: 'assetId',
|
||||
|
||||
@@ -435,6 +435,7 @@ export const AssetCommentScalarFieldEnum = {
|
||||
annotation: 'annotation',
|
||||
second: 'second',
|
||||
sessionId: 'sessionId',
|
||||
transcriptionTaskId: 'transcriptionTaskId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
assetId: 'assetId',
|
||||
|
||||
+226
-2
@@ -41,6 +41,7 @@ export type AssetCommentMinAggregateOutputType = {
|
||||
message: string | null
|
||||
second: number | null
|
||||
sessionId: string | null
|
||||
transcriptionTaskId: string | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
assetId: string | null
|
||||
@@ -56,6 +57,7 @@ export type AssetCommentMaxAggregateOutputType = {
|
||||
message: string | null
|
||||
second: number | null
|
||||
sessionId: string | null
|
||||
transcriptionTaskId: string | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
assetId: string | null
|
||||
@@ -72,6 +74,7 @@ export type AssetCommentCountAggregateOutputType = {
|
||||
annotation: number
|
||||
second: number
|
||||
sessionId: number
|
||||
transcriptionTaskId: number
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
assetId: number
|
||||
@@ -97,6 +100,7 @@ export type AssetCommentMinAggregateInputType = {
|
||||
message?: true
|
||||
second?: true
|
||||
sessionId?: true
|
||||
transcriptionTaskId?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
assetId?: true
|
||||
@@ -112,6 +116,7 @@ export type AssetCommentMaxAggregateInputType = {
|
||||
message?: true
|
||||
second?: true
|
||||
sessionId?: true
|
||||
transcriptionTaskId?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
assetId?: true
|
||||
@@ -128,6 +133,7 @@ export type AssetCommentCountAggregateInputType = {
|
||||
annotation?: true
|
||||
second?: true
|
||||
sessionId?: true
|
||||
transcriptionTaskId?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
assetId?: true
|
||||
@@ -231,6 +237,7 @@ export type AssetCommentGroupByOutputType = {
|
||||
annotation:PrismaJson.AnnotationList | null
|
||||
second: number | null
|
||||
sessionId: string | null
|
||||
transcriptionTaskId: string | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
assetId: string
|
||||
@@ -270,6 +277,7 @@ export type AssetCommentWhereInput = {
|
||||
annotation?: Prisma.JsonNullableFilter<"AssetComment">
|
||||
second?: Prisma.FloatNullableFilter<"AssetComment"> | number | null
|
||||
sessionId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
transcriptionTaskId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"AssetComment"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"AssetComment"> | Date | string
|
||||
assetId?: Prisma.StringFilter<"AssetComment"> | string
|
||||
@@ -279,6 +287,7 @@ export type AssetCommentWhereInput = {
|
||||
completionLastChangedById?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
replyToId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
|
||||
transcriptionTask?: Prisma.XOR<Prisma.WorkflowTaskNullableScalarRelationFilter, Prisma.WorkflowTaskWhereInput> | null
|
||||
asset?: Prisma.XOR<Prisma.AssetScalarRelationFilter, Prisma.AssetWhereInput>
|
||||
creator?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
completionLastChangedBy?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
@@ -294,6 +303,7 @@ export type AssetCommentOrderByWithRelationInput = {
|
||||
annotation?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
second?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
transcriptionTaskId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
assetId?: Prisma.SortOrder
|
||||
@@ -303,6 +313,7 @@ export type AssetCommentOrderByWithRelationInput = {
|
||||
completionLastChangedById?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
replyToId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
session?: Prisma.AgentSessionOrderByWithRelationInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskOrderByWithRelationInput
|
||||
asset?: Prisma.AssetOrderByWithRelationInput
|
||||
creator?: Prisma.UserOrderByWithRelationInput
|
||||
completionLastChangedBy?: Prisma.UserOrderByWithRelationInput
|
||||
@@ -314,6 +325,7 @@ export type AssetCommentOrderByWithRelationInput = {
|
||||
|
||||
export type AssetCommentWhereUniqueInput = Prisma.AtLeast<{
|
||||
id?: string
|
||||
transcriptionTaskId?: string
|
||||
AND?: Prisma.AssetCommentWhereInput | Prisma.AssetCommentWhereInput[]
|
||||
OR?: Prisma.AssetCommentWhereInput[]
|
||||
NOT?: Prisma.AssetCommentWhereInput | Prisma.AssetCommentWhereInput[]
|
||||
@@ -330,6 +342,7 @@ export type AssetCommentWhereUniqueInput = Prisma.AtLeast<{
|
||||
completionLastChangedById?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
replyToId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
|
||||
transcriptionTask?: Prisma.XOR<Prisma.WorkflowTaskNullableScalarRelationFilter, Prisma.WorkflowTaskWhereInput> | null
|
||||
asset?: Prisma.XOR<Prisma.AssetScalarRelationFilter, Prisma.AssetWhereInput>
|
||||
creator?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
completionLastChangedBy?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
@@ -337,7 +350,7 @@ export type AssetCommentWhereUniqueInput = Prisma.AtLeast<{
|
||||
replies?: Prisma.AssetCommentListRelationFilter
|
||||
attachments?: Prisma.AssetCommentAttachmentListRelationFilter
|
||||
reactions?: Prisma.AssetCommentReactionListRelationFilter
|
||||
}, "id">
|
||||
}, "id" | "transcriptionTaskId">
|
||||
|
||||
export type AssetCommentOrderByWithAggregationInput = {
|
||||
id?: Prisma.SortOrder
|
||||
@@ -345,6 +358,7 @@ export type AssetCommentOrderByWithAggregationInput = {
|
||||
annotation?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
second?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
transcriptionTaskId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
assetId?: Prisma.SortOrder
|
||||
@@ -369,6 +383,7 @@ export type AssetCommentScalarWhereWithAggregatesInput = {
|
||||
annotation?: Prisma.JsonNullableWithAggregatesFilter<"AssetComment">
|
||||
second?: Prisma.FloatNullableWithAggregatesFilter<"AssetComment"> | number | null
|
||||
sessionId?: Prisma.StringNullableWithAggregatesFilter<"AssetComment"> | string | null
|
||||
transcriptionTaskId?: Prisma.StringNullableWithAggregatesFilter<"AssetComment"> | string | null
|
||||
createdAt?: Prisma.DateTimeWithAggregatesFilter<"AssetComment"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeWithAggregatesFilter<"AssetComment"> | Date | string
|
||||
assetId?: Prisma.StringWithAggregatesFilter<"AssetComment"> | string
|
||||
@@ -389,6 +404,7 @@ export type AssetCommentCreateInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -404,6 +420,7 @@ export type AssetCommentUncheckedCreateInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -427,6 +444,7 @@ export type AssetCommentUpdateInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -442,6 +460,7 @@ export type AssetCommentUncheckedUpdateInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -461,6 +480,7 @@ export type AssetCommentCreateManyInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -488,6 +508,7 @@ export type AssetCommentUncheckedUpdateManyInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -519,6 +540,7 @@ export type AssetCommentCountOrderByAggregateInput = {
|
||||
annotation?: Prisma.SortOrder
|
||||
second?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrder
|
||||
transcriptionTaskId?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
assetId?: Prisma.SortOrder
|
||||
@@ -538,6 +560,7 @@ export type AssetCommentMaxOrderByAggregateInput = {
|
||||
message?: Prisma.SortOrder
|
||||
second?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrder
|
||||
transcriptionTaskId?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
assetId?: Prisma.SortOrder
|
||||
@@ -553,6 +576,7 @@ export type AssetCommentMinOrderByAggregateInput = {
|
||||
message?: Prisma.SortOrder
|
||||
second?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrder
|
||||
transcriptionTaskId?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
assetId?: Prisma.SortOrder
|
||||
@@ -784,6 +808,38 @@ export type AssetCommentUpdateOneRequiredWithoutReactionsNestedInput = {
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetCommentUpdateToOneWithWhereWithoutReactionsInput, Prisma.AssetCommentUpdateWithoutReactionsInput>, Prisma.AssetCommentUncheckedUpdateWithoutReactionsInput>
|
||||
}
|
||||
|
||||
export type AssetCommentCreateNestedOneWithoutTranscriptionTaskInput = {
|
||||
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedCreateWithoutTranscriptionTaskInput>
|
||||
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutTranscriptionTaskInput
|
||||
connect?: Prisma.AssetCommentWhereUniqueInput
|
||||
}
|
||||
|
||||
export type AssetCommentUncheckedCreateNestedOneWithoutTranscriptionTaskInput = {
|
||||
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedCreateWithoutTranscriptionTaskInput>
|
||||
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutTranscriptionTaskInput
|
||||
connect?: Prisma.AssetCommentWhereUniqueInput
|
||||
}
|
||||
|
||||
export type AssetCommentUpdateOneWithoutTranscriptionTaskNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedCreateWithoutTranscriptionTaskInput>
|
||||
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutTranscriptionTaskInput
|
||||
upsert?: Prisma.AssetCommentUpsertWithoutTranscriptionTaskInput
|
||||
disconnect?: Prisma.AssetCommentWhereInput | boolean
|
||||
delete?: Prisma.AssetCommentWhereInput | boolean
|
||||
connect?: Prisma.AssetCommentWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetCommentUpdateToOneWithWhereWithoutTranscriptionTaskInput, Prisma.AssetCommentUpdateWithoutTranscriptionTaskInput>, Prisma.AssetCommentUncheckedUpdateWithoutTranscriptionTaskInput>
|
||||
}
|
||||
|
||||
export type AssetCommentUncheckedUpdateOneWithoutTranscriptionTaskNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedCreateWithoutTranscriptionTaskInput>
|
||||
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutTranscriptionTaskInput
|
||||
upsert?: Prisma.AssetCommentUpsertWithoutTranscriptionTaskInput
|
||||
disconnect?: Prisma.AssetCommentWhereInput | boolean
|
||||
delete?: Prisma.AssetCommentWhereInput | boolean
|
||||
connect?: Prisma.AssetCommentWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetCommentUpdateToOneWithWhereWithoutTranscriptionTaskInput, Prisma.AssetCommentUpdateWithoutTranscriptionTaskInput>, Prisma.AssetCommentUncheckedUpdateWithoutTranscriptionTaskInput>
|
||||
}
|
||||
|
||||
export type AssetCommentCreateNestedManyWithoutSessionInput = {
|
||||
create?: Prisma.XOR<Prisma.AssetCommentCreateWithoutSessionInput, Prisma.AssetCommentUncheckedCreateWithoutSessionInput> | Prisma.AssetCommentCreateWithoutSessionInput[] | Prisma.AssetCommentUncheckedCreateWithoutSessionInput[]
|
||||
connectOrCreate?: Prisma.AssetCommentCreateOrConnectWithoutSessionInput | Prisma.AssetCommentCreateOrConnectWithoutSessionInput[]
|
||||
@@ -836,6 +892,7 @@ export type AssetCommentCreateWithoutCreatorInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
|
||||
@@ -850,6 +907,7 @@ export type AssetCommentUncheckedCreateWithoutCreatorInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -882,6 +940,7 @@ export type AssetCommentCreateWithoutCompletionLastChangedByInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
|
||||
@@ -896,6 +955,7 @@ export type AssetCommentUncheckedCreateWithoutCompletionLastChangedByInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -943,6 +1003,7 @@ export type AssetCommentScalarWhereInput = {
|
||||
annotation?: Prisma.JsonNullableFilter<"AssetComment">
|
||||
second?: Prisma.FloatNullableFilter<"AssetComment"> | number | null
|
||||
sessionId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
transcriptionTaskId?: Prisma.StringNullableFilter<"AssetComment"> | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"AssetComment"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"AssetComment"> | Date | string
|
||||
assetId?: Prisma.StringFilter<"AssetComment"> | string
|
||||
@@ -979,6 +1040,7 @@ export type AssetCommentCreateWithoutAssetInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
|
||||
@@ -993,6 +1055,7 @@ export type AssetCommentUncheckedCreateWithoutAssetInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
creatorId?: string | null
|
||||
@@ -1041,6 +1104,7 @@ export type AssetCommentCreateWithoutRepliesInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -1055,6 +1119,7 @@ export type AssetCommentUncheckedCreateWithoutRepliesInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1082,6 +1147,7 @@ export type AssetCommentCreateWithoutReplyToInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -1096,6 +1162,7 @@ export type AssetCommentUncheckedCreateWithoutReplyToInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1139,6 +1206,7 @@ export type AssetCommentUpdateWithoutRepliesInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1153,6 +1221,7 @@ export type AssetCommentUncheckedUpdateWithoutRepliesInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1191,6 +1260,7 @@ export type AssetCommentCreateWithoutAttachmentsInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -1205,6 +1275,7 @@ export type AssetCommentUncheckedCreateWithoutAttachmentsInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1243,6 +1314,7 @@ export type AssetCommentUpdateWithoutAttachmentsInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1257,6 +1329,7 @@ export type AssetCommentUncheckedUpdateWithoutAttachmentsInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1279,6 +1352,7 @@ export type AssetCommentCreateWithoutReactionsInput = {
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -1293,6 +1367,7 @@ export type AssetCommentUncheckedCreateWithoutReactionsInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1331,6 +1406,7 @@ export type AssetCommentUpdateWithoutReactionsInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1340,6 +1416,98 @@ export type AssetCommentUpdateWithoutReactionsInput = {
|
||||
}
|
||||
|
||||
export type AssetCommentUncheckedUpdateWithoutReactionsInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
message?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
completionLastChangedById?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
|
||||
}
|
||||
|
||||
export type AssetCommentCreateWithoutTranscriptionTaskInput = {
|
||||
id?: string
|
||||
message?: string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutCommentsInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
replyTo?: Prisma.AssetCommentCreateNestedOneWithoutRepliesInput
|
||||
replies?: Prisma.AssetCommentCreateNestedManyWithoutReplyToInput
|
||||
attachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutCommentInput
|
||||
reactions?: Prisma.AssetCommentReactionCreateNestedManyWithoutCommentInput
|
||||
}
|
||||
|
||||
export type AssetCommentUncheckedCreateWithoutTranscriptionTaskInput = {
|
||||
id?: string
|
||||
message?: string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
creatorId?: string | null
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
completionLastChangedById?: string | null
|
||||
replyToId?: string | null
|
||||
replies?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutReplyToInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutCommentInput
|
||||
reactions?: Prisma.AssetCommentReactionUncheckedCreateNestedManyWithoutCommentInput
|
||||
}
|
||||
|
||||
export type AssetCommentCreateOrConnectWithoutTranscriptionTaskInput = {
|
||||
where: Prisma.AssetCommentWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.AssetCommentCreateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedCreateWithoutTranscriptionTaskInput>
|
||||
}
|
||||
|
||||
export type AssetCommentUpsertWithoutTranscriptionTaskInput = {
|
||||
update: Prisma.XOR<Prisma.AssetCommentUpdateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedUpdateWithoutTranscriptionTaskInput>
|
||||
create: Prisma.XOR<Prisma.AssetCommentCreateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedCreateWithoutTranscriptionTaskInput>
|
||||
where?: Prisma.AssetCommentWhereInput
|
||||
}
|
||||
|
||||
export type AssetCommentUpdateToOneWithWhereWithoutTranscriptionTaskInput = {
|
||||
where?: Prisma.AssetCommentWhereInput
|
||||
data: Prisma.XOR<Prisma.AssetCommentUpdateWithoutTranscriptionTaskInput, Prisma.AssetCommentUncheckedUpdateWithoutTranscriptionTaskInput>
|
||||
}
|
||||
|
||||
export type AssetCommentUpdateWithoutTranscriptionTaskInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
message?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
|
||||
replies?: Prisma.AssetCommentUpdateManyWithoutReplyToNestedInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutCommentNestedInput
|
||||
reactions?: Prisma.AssetCommentReactionUpdateManyWithoutCommentNestedInput
|
||||
}
|
||||
|
||||
export type AssetCommentUncheckedUpdateWithoutTranscriptionTaskInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
message?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
@@ -1355,6 +1523,7 @@ export type AssetCommentUncheckedUpdateWithoutReactionsInput = {
|
||||
replyToId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
replies?: Prisma.AssetCommentUncheckedUpdateManyWithoutReplyToNestedInput
|
||||
attachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutCommentNestedInput
|
||||
reactions?: Prisma.AssetCommentReactionUncheckedUpdateManyWithoutCommentNestedInput
|
||||
}
|
||||
|
||||
export type AssetCommentCreateWithoutSessionInput = {
|
||||
@@ -1366,6 +1535,7 @@ export type AssetCommentCreateWithoutSessionInput = {
|
||||
updatedAt?: Date | string
|
||||
isCompleted?: boolean
|
||||
isInternal?: boolean
|
||||
transcriptionTask?: Prisma.WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput
|
||||
asset: Prisma.AssetCreateNestedOneWithoutCommentsInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutCommentsInput
|
||||
completionLastChangedBy?: Prisma.UserCreateNestedOneWithoutCompletionChangedCommentsInput
|
||||
@@ -1380,6 +1550,7 @@ export type AssetCommentUncheckedCreateWithoutSessionInput = {
|
||||
message?: string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1425,6 +1596,7 @@ export type AssetCommentCreateManyCreatorInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1440,6 +1612,7 @@ export type AssetCommentCreateManyCompletionLastChangedByInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1459,6 +1632,7 @@ export type AssetCommentUpdateWithoutCreatorInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
|
||||
@@ -1473,6 +1647,7 @@ export type AssetCommentUncheckedUpdateWithoutCreatorInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1491,6 +1666,7 @@ export type AssetCommentUncheckedUpdateManyWithoutCreatorInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1510,6 +1686,7 @@ export type AssetCommentUpdateWithoutCompletionLastChangedByInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
|
||||
@@ -1524,6 +1701,7 @@ export type AssetCommentUncheckedUpdateWithoutCompletionLastChangedByInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1542,6 +1720,7 @@ export type AssetCommentUncheckedUpdateManyWithoutCompletionLastChangedByInput =
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1557,6 +1736,7 @@ export type AssetCommentCreateManyAssetInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
creatorId?: string | null
|
||||
@@ -1576,6 +1756,7 @@ export type AssetCommentUpdateWithoutAssetInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
replyTo?: Prisma.AssetCommentUpdateOneWithoutRepliesNestedInput
|
||||
@@ -1590,6 +1771,7 @@ export type AssetCommentUncheckedUpdateWithoutAssetInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
@@ -1608,6 +1790,7 @@ export type AssetCommentUncheckedUpdateManyWithoutAssetInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
@@ -1623,6 +1806,7 @@ export type AssetCommentCreateManyReplyToInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
sessionId?: string | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1642,6 +1826,7 @@ export type AssetCommentUpdateWithoutReplyToInput = {
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutCommentsNestedInput
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1656,6 +1841,7 @@ export type AssetCommentUncheckedUpdateWithoutReplyToInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1674,6 +1860,7 @@ export type AssetCommentUncheckedUpdateManyWithoutReplyToInput = {
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1688,6 +1875,7 @@ export type AssetCommentCreateManySessionInput = {
|
||||
message?: string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: number | null
|
||||
transcriptionTaskId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assetId: string
|
||||
@@ -1707,6 +1895,7 @@ export type AssetCommentUpdateWithoutSessionInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
isCompleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
isInternal?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
transcriptionTask?: Prisma.WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput
|
||||
asset?: Prisma.AssetUpdateOneRequiredWithoutCommentsNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutCommentsNestedInput
|
||||
completionLastChangedBy?: Prisma.UserUpdateOneWithoutCompletionChangedCommentsNestedInput
|
||||
@@ -1721,6 +1910,7 @@ export type AssetCommentUncheckedUpdateWithoutSessionInput = {
|
||||
message?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1739,6 +1929,7 @@ export type AssetCommentUncheckedUpdateManyWithoutSessionInput = {
|
||||
message?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
annotation?:PrismaJson.AnnotationList | Prisma.NullableJsonNullValueInput
|
||||
second?: Prisma.NullableFloatFieldUpdateOperationsInput | number | null
|
||||
transcriptionTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1804,6 +1995,7 @@ export type AssetCommentSelect<ExtArgs extends runtime.Types.Extensions.Internal
|
||||
annotation?: boolean
|
||||
second?: boolean
|
||||
sessionId?: boolean
|
||||
transcriptionTaskId?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
assetId?: boolean
|
||||
@@ -1813,6 +2005,7 @@ export type AssetCommentSelect<ExtArgs extends runtime.Types.Extensions.Internal
|
||||
completionLastChangedById?: boolean
|
||||
replyToId?: boolean
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
transcriptionTask?: boolean | Prisma.AssetComment$transcriptionTaskArgs<ExtArgs>
|
||||
asset?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.AssetComment$creatorArgs<ExtArgs>
|
||||
completionLastChangedBy?: boolean | Prisma.AssetComment$completionLastChangedByArgs<ExtArgs>
|
||||
@@ -1829,6 +2022,7 @@ export type AssetCommentSelectCreateManyAndReturn<ExtArgs extends runtime.Types.
|
||||
annotation?: boolean
|
||||
second?: boolean
|
||||
sessionId?: boolean
|
||||
transcriptionTaskId?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
assetId?: boolean
|
||||
@@ -1838,6 +2032,7 @@ export type AssetCommentSelectCreateManyAndReturn<ExtArgs extends runtime.Types.
|
||||
completionLastChangedById?: boolean
|
||||
replyToId?: boolean
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
transcriptionTask?: boolean | Prisma.AssetComment$transcriptionTaskArgs<ExtArgs>
|
||||
asset?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.AssetComment$creatorArgs<ExtArgs>
|
||||
completionLastChangedBy?: boolean | Prisma.AssetComment$completionLastChangedByArgs<ExtArgs>
|
||||
@@ -1850,6 +2045,7 @@ export type AssetCommentSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.
|
||||
annotation?: boolean
|
||||
second?: boolean
|
||||
sessionId?: boolean
|
||||
transcriptionTaskId?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
assetId?: boolean
|
||||
@@ -1859,6 +2055,7 @@ export type AssetCommentSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.
|
||||
completionLastChangedById?: boolean
|
||||
replyToId?: boolean
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
transcriptionTask?: boolean | Prisma.AssetComment$transcriptionTaskArgs<ExtArgs>
|
||||
asset?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.AssetComment$creatorArgs<ExtArgs>
|
||||
completionLastChangedBy?: boolean | Prisma.AssetComment$completionLastChangedByArgs<ExtArgs>
|
||||
@@ -1871,6 +2068,7 @@ export type AssetCommentSelectScalar = {
|
||||
annotation?: boolean
|
||||
second?: boolean
|
||||
sessionId?: boolean
|
||||
transcriptionTaskId?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
assetId?: boolean
|
||||
@@ -1881,9 +2079,10 @@ export type AssetCommentSelectScalar = {
|
||||
replyToId?: boolean
|
||||
}
|
||||
|
||||
export type AssetCommentOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "message" | "annotation" | "second" | "sessionId" | "createdAt" | "updatedAt" | "assetId" | "creatorId" | "isCompleted" | "isInternal" | "completionLastChangedById" | "replyToId", ExtArgs["result"]["assetComment"]>
|
||||
export type AssetCommentOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "message" | "annotation" | "second" | "sessionId" | "transcriptionTaskId" | "createdAt" | "updatedAt" | "assetId" | "creatorId" | "isCompleted" | "isInternal" | "completionLastChangedById" | "replyToId", ExtArgs["result"]["assetComment"]>
|
||||
export type AssetCommentInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
transcriptionTask?: boolean | Prisma.AssetComment$transcriptionTaskArgs<ExtArgs>
|
||||
asset?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.AssetComment$creatorArgs<ExtArgs>
|
||||
completionLastChangedBy?: boolean | Prisma.AssetComment$completionLastChangedByArgs<ExtArgs>
|
||||
@@ -1895,6 +2094,7 @@ export type AssetCommentInclude<ExtArgs extends runtime.Types.Extensions.Interna
|
||||
}
|
||||
export type AssetCommentIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
transcriptionTask?: boolean | Prisma.AssetComment$transcriptionTaskArgs<ExtArgs>
|
||||
asset?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.AssetComment$creatorArgs<ExtArgs>
|
||||
completionLastChangedBy?: boolean | Prisma.AssetComment$completionLastChangedByArgs<ExtArgs>
|
||||
@@ -1902,6 +2102,7 @@ export type AssetCommentIncludeCreateManyAndReturn<ExtArgs extends runtime.Types
|
||||
}
|
||||
export type AssetCommentIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
session?: boolean | Prisma.AssetComment$sessionArgs<ExtArgs>
|
||||
transcriptionTask?: boolean | Prisma.AssetComment$transcriptionTaskArgs<ExtArgs>
|
||||
asset?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.AssetComment$creatorArgs<ExtArgs>
|
||||
completionLastChangedBy?: boolean | Prisma.AssetComment$completionLastChangedByArgs<ExtArgs>
|
||||
@@ -1912,6 +2113,7 @@ export type $AssetCommentPayload<ExtArgs extends runtime.Types.Extensions.Intern
|
||||
name: "AssetComment"
|
||||
objects: {
|
||||
session: Prisma.$AgentSessionPayload<ExtArgs> | null
|
||||
transcriptionTask: Prisma.$WorkflowTaskPayload<ExtArgs> | null
|
||||
asset: Prisma.$AssetPayload<ExtArgs>
|
||||
creator: Prisma.$UserPayload<ExtArgs> | null
|
||||
completionLastChangedBy: Prisma.$UserPayload<ExtArgs> | null
|
||||
@@ -1929,6 +2131,7 @@ export type $AssetCommentPayload<ExtArgs extends runtime.Types.Extensions.Intern
|
||||
annotation:PrismaJson.AnnotationList | null
|
||||
second: number | null
|
||||
sessionId: string | null
|
||||
transcriptionTaskId: string | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
assetId: string
|
||||
@@ -2332,6 +2535,7 @@ readonly fields: AssetCommentFieldRefs;
|
||||
export interface Prisma__AssetCommentClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> {
|
||||
readonly [Symbol.toStringTag]: "PrismaPromise"
|
||||
session<T extends Prisma.AssetComment$sessionArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$sessionArgs<ExtArgs>>): Prisma.Prisma__AgentSessionClient<runtime.Types.Result.GetResult<Prisma.$AgentSessionPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
transcriptionTask<T extends Prisma.AssetComment$transcriptionTaskArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$transcriptionTaskArgs<ExtArgs>>): Prisma.Prisma__WorkflowTaskClient<runtime.Types.Result.GetResult<Prisma.$WorkflowTaskPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
asset<T extends Prisma.AssetDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetDefaultArgs<ExtArgs>>): Prisma.Prisma__AssetClient<runtime.Types.Result.GetResult<Prisma.$AssetPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
creator<T extends Prisma.AssetComment$creatorArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$creatorArgs<ExtArgs>>): Prisma.Prisma__UserClient<runtime.Types.Result.GetResult<Prisma.$UserPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
completionLastChangedBy<T extends Prisma.AssetComment$completionLastChangedByArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetComment$completionLastChangedByArgs<ExtArgs>>): Prisma.Prisma__UserClient<runtime.Types.Result.GetResult<Prisma.$UserPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
@@ -2373,6 +2577,7 @@ export interface AssetCommentFieldRefs {
|
||||
readonly annotation: Prisma.FieldRef<"AssetComment", 'Json'>
|
||||
readonly second: Prisma.FieldRef<"AssetComment", 'Float'>
|
||||
readonly sessionId: Prisma.FieldRef<"AssetComment", 'String'>
|
||||
readonly transcriptionTaskId: Prisma.FieldRef<"AssetComment", 'String'>
|
||||
readonly createdAt: Prisma.FieldRef<"AssetComment", 'DateTime'>
|
||||
readonly updatedAt: Prisma.FieldRef<"AssetComment", 'DateTime'>
|
||||
readonly assetId: Prisma.FieldRef<"AssetComment", 'String'>
|
||||
@@ -2800,6 +3005,25 @@ export type AssetComment$sessionArgs<ExtArgs extends runtime.Types.Extensions.In
|
||||
where?: Prisma.AgentSessionWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* AssetComment.transcriptionTask
|
||||
*/
|
||||
export type AssetComment$transcriptionTaskArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the WorkflowTask
|
||||
*/
|
||||
select?: Prisma.WorkflowTaskSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
where?: Prisma.WorkflowTaskWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* AssetComment.creator
|
||||
*/
|
||||
|
||||
+189
-1
@@ -302,6 +302,7 @@ export type WorkflowTaskWhereInput = {
|
||||
sessionId?: Prisma.StringNullableFilter<"WorkflowTask"> | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"WorkflowTask"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"WorkflowTask"> | Date | string
|
||||
transcriptionFailureComment?: Prisma.XOR<Prisma.AssetCommentNullableScalarRelationFilter, Prisma.AssetCommentWhereInput> | null
|
||||
}
|
||||
|
||||
export type WorkflowTaskOrderByWithRelationInput = {
|
||||
@@ -321,6 +322,7 @@ export type WorkflowTaskOrderByWithRelationInput = {
|
||||
sessionId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
transcriptionFailureComment?: Prisma.AssetCommentOrderByWithRelationInput
|
||||
}
|
||||
|
||||
export type WorkflowTaskWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -343,6 +345,7 @@ export type WorkflowTaskWhereUniqueInput = Prisma.AtLeast<{
|
||||
sessionId?: Prisma.StringNullableFilter<"WorkflowTask"> | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"WorkflowTask"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"WorkflowTask"> | Date | string
|
||||
transcriptionFailureComment?: Prisma.XOR<Prisma.AssetCommentNullableScalarRelationFilter, Prisma.AssetCommentWhereInput> | null
|
||||
}, "id">
|
||||
|
||||
export type WorkflowTaskOrderByWithAggregationInput = {
|
||||
@@ -408,6 +411,7 @@ export type WorkflowTaskCreateInput = {
|
||||
sessionId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
transcriptionFailureComment?: Prisma.AssetCommentCreateNestedOneWithoutTranscriptionTaskInput
|
||||
}
|
||||
|
||||
export type WorkflowTaskUncheckedCreateInput = {
|
||||
@@ -427,6 +431,7 @@ export type WorkflowTaskUncheckedCreateInput = {
|
||||
sessionId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
transcriptionFailureComment?: Prisma.AssetCommentUncheckedCreateNestedOneWithoutTranscriptionTaskInput
|
||||
}
|
||||
|
||||
export type WorkflowTaskUpdateInput = {
|
||||
@@ -446,6 +451,7 @@ export type WorkflowTaskUpdateInput = {
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
transcriptionFailureComment?: Prisma.AssetCommentUpdateOneWithoutTranscriptionTaskNestedInput
|
||||
}
|
||||
|
||||
export type WorkflowTaskUncheckedUpdateInput = {
|
||||
@@ -465,6 +471,7 @@ export type WorkflowTaskUncheckedUpdateInput = {
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
transcriptionFailureComment?: Prisma.AssetCommentUncheckedUpdateOneWithoutTranscriptionTaskNestedInput
|
||||
}
|
||||
|
||||
export type WorkflowTaskCreateManyInput = {
|
||||
@@ -524,6 +531,11 @@ export type WorkflowTaskUncheckedUpdateManyInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
}
|
||||
|
||||
export type WorkflowTaskNullableScalarRelationFilter = {
|
||||
is?: Prisma.WorkflowTaskWhereInput | null
|
||||
isNot?: Prisma.WorkflowTaskWhereInput | null
|
||||
}
|
||||
|
||||
export type WorkflowTaskCountOrderByAggregateInput = {
|
||||
id?: Prisma.SortOrder
|
||||
uid?: Prisma.SortOrder
|
||||
@@ -587,6 +599,22 @@ export type WorkflowTaskSumOrderByAggregateInput = {
|
||||
outputTokens?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type WorkflowTaskCreateNestedOneWithoutTranscriptionFailureCommentInput = {
|
||||
create?: Prisma.XOR<Prisma.WorkflowTaskCreateWithoutTranscriptionFailureCommentInput, Prisma.WorkflowTaskUncheckedCreateWithoutTranscriptionFailureCommentInput>
|
||||
connectOrCreate?: Prisma.WorkflowTaskCreateOrConnectWithoutTranscriptionFailureCommentInput
|
||||
connect?: Prisma.WorkflowTaskWhereUniqueInput
|
||||
}
|
||||
|
||||
export type WorkflowTaskUpdateOneWithoutTranscriptionFailureCommentNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.WorkflowTaskCreateWithoutTranscriptionFailureCommentInput, Prisma.WorkflowTaskUncheckedCreateWithoutTranscriptionFailureCommentInput>
|
||||
connectOrCreate?: Prisma.WorkflowTaskCreateOrConnectWithoutTranscriptionFailureCommentInput
|
||||
upsert?: Prisma.WorkflowTaskUpsertWithoutTranscriptionFailureCommentInput
|
||||
disconnect?: Prisma.WorkflowTaskWhereInput | boolean
|
||||
delete?: Prisma.WorkflowTaskWhereInput | boolean
|
||||
connect?: Prisma.WorkflowTaskWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.WorkflowTaskUpdateToOneWithWhereWithoutTranscriptionFailureCommentInput, Prisma.WorkflowTaskUpdateWithoutTranscriptionFailureCommentInput>, Prisma.WorkflowTaskUncheckedUpdateWithoutTranscriptionFailureCommentInput>
|
||||
}
|
||||
|
||||
export type NullableEnumWorkflowTaskTypeFieldUpdateOperationsInput = {
|
||||
set?: $Enums.WorkflowTaskType | null
|
||||
}
|
||||
@@ -595,6 +623,98 @@ export type NullableEnumWorkflowTaskStatusFieldUpdateOperationsInput = {
|
||||
set?: $Enums.WorkflowTaskStatus | null
|
||||
}
|
||||
|
||||
export type WorkflowTaskCreateWithoutTranscriptionFailureCommentInput = {
|
||||
id?: string
|
||||
uid?: string
|
||||
teamId?: string | null
|
||||
projectId?: string | null
|
||||
assetId: string
|
||||
type?: $Enums.WorkflowTaskType | null
|
||||
status?: $Enums.WorkflowTaskStatus | null
|
||||
payload?:PrismaJson.WorkflowTaskPayload | Prisma.NullableJsonNullValueInput
|
||||
output?:PrismaJson.WorkflowTaskOutput | Prisma.NullableJsonNullValueInput
|
||||
heartbeat?: Date | string | null
|
||||
inputTokens?: number
|
||||
outputTokens?: number
|
||||
model?: string | null
|
||||
sessionId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
}
|
||||
|
||||
export type WorkflowTaskUncheckedCreateWithoutTranscriptionFailureCommentInput = {
|
||||
id?: string
|
||||
uid?: string
|
||||
teamId?: string | null
|
||||
projectId?: string | null
|
||||
assetId: string
|
||||
type?: $Enums.WorkflowTaskType | null
|
||||
status?: $Enums.WorkflowTaskStatus | null
|
||||
payload?:PrismaJson.WorkflowTaskPayload | Prisma.NullableJsonNullValueInput
|
||||
output?:PrismaJson.WorkflowTaskOutput | Prisma.NullableJsonNullValueInput
|
||||
heartbeat?: Date | string | null
|
||||
inputTokens?: number
|
||||
outputTokens?: number
|
||||
model?: string | null
|
||||
sessionId?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
}
|
||||
|
||||
export type WorkflowTaskCreateOrConnectWithoutTranscriptionFailureCommentInput = {
|
||||
where: Prisma.WorkflowTaskWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.WorkflowTaskCreateWithoutTranscriptionFailureCommentInput, Prisma.WorkflowTaskUncheckedCreateWithoutTranscriptionFailureCommentInput>
|
||||
}
|
||||
|
||||
export type WorkflowTaskUpsertWithoutTranscriptionFailureCommentInput = {
|
||||
update: Prisma.XOR<Prisma.WorkflowTaskUpdateWithoutTranscriptionFailureCommentInput, Prisma.WorkflowTaskUncheckedUpdateWithoutTranscriptionFailureCommentInput>
|
||||
create: Prisma.XOR<Prisma.WorkflowTaskCreateWithoutTranscriptionFailureCommentInput, Prisma.WorkflowTaskUncheckedCreateWithoutTranscriptionFailureCommentInput>
|
||||
where?: Prisma.WorkflowTaskWhereInput
|
||||
}
|
||||
|
||||
export type WorkflowTaskUpdateToOneWithWhereWithoutTranscriptionFailureCommentInput = {
|
||||
where?: Prisma.WorkflowTaskWhereInput
|
||||
data: Prisma.XOR<Prisma.WorkflowTaskUpdateWithoutTranscriptionFailureCommentInput, Prisma.WorkflowTaskUncheckedUpdateWithoutTranscriptionFailureCommentInput>
|
||||
}
|
||||
|
||||
export type WorkflowTaskUpdateWithoutTranscriptionFailureCommentInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
uid?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
teamId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
projectId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
type?: Prisma.NullableEnumWorkflowTaskTypeFieldUpdateOperationsInput | $Enums.WorkflowTaskType | null
|
||||
status?: Prisma.NullableEnumWorkflowTaskStatusFieldUpdateOperationsInput | $Enums.WorkflowTaskStatus | null
|
||||
payload?:PrismaJson.WorkflowTaskPayload | Prisma.NullableJsonNullValueInput
|
||||
output?:PrismaJson.WorkflowTaskOutput | Prisma.NullableJsonNullValueInput
|
||||
heartbeat?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
inputTokens?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
outputTokens?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
model?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
}
|
||||
|
||||
export type WorkflowTaskUncheckedUpdateWithoutTranscriptionFailureCommentInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
uid?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
teamId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
projectId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
assetId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
type?: Prisma.NullableEnumWorkflowTaskTypeFieldUpdateOperationsInput | $Enums.WorkflowTaskType | null
|
||||
status?: Prisma.NullableEnumWorkflowTaskStatusFieldUpdateOperationsInput | $Enums.WorkflowTaskStatus | null
|
||||
payload?:PrismaJson.WorkflowTaskPayload | Prisma.NullableJsonNullValueInput
|
||||
output?:PrismaJson.WorkflowTaskOutput | Prisma.NullableJsonNullValueInput
|
||||
heartbeat?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
inputTokens?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
outputTokens?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
model?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
}
|
||||
|
||||
|
||||
|
||||
export type WorkflowTaskSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
@@ -614,6 +734,7 @@ export type WorkflowTaskSelect<ExtArgs extends runtime.Types.Extensions.Internal
|
||||
sessionId?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
transcriptionFailureComment?: boolean | Prisma.WorkflowTask$transcriptionFailureCommentArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["workflowTask"]>
|
||||
|
||||
export type WorkflowTaskSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
@@ -674,10 +795,17 @@ export type WorkflowTaskSelectScalar = {
|
||||
}
|
||||
|
||||
export type WorkflowTaskOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "uid" | "teamId" | "projectId" | "assetId" | "type" | "status" | "payload" | "output" | "heartbeat" | "inputTokens" | "outputTokens" | "model" | "sessionId" | "createdAt" | "updatedAt", ExtArgs["result"]["workflowTask"]>
|
||||
export type WorkflowTaskInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
transcriptionFailureComment?: boolean | Prisma.WorkflowTask$transcriptionFailureCommentArgs<ExtArgs>
|
||||
}
|
||||
export type WorkflowTaskIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {}
|
||||
export type WorkflowTaskIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {}
|
||||
|
||||
export type $WorkflowTaskPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
name: "WorkflowTask"
|
||||
objects: {}
|
||||
objects: {
|
||||
transcriptionFailureComment: Prisma.$AssetCommentPayload<ExtArgs> | null
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
uid: string
|
||||
@@ -1095,6 +1223,7 @@ readonly fields: WorkflowTaskFieldRefs;
|
||||
*/
|
||||
export interface Prisma__WorkflowTaskClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> {
|
||||
readonly [Symbol.toStringTag]: "PrismaPromise"
|
||||
transcriptionFailureComment<T extends Prisma.WorkflowTask$transcriptionFailureCommentArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.WorkflowTask$transcriptionFailureCommentArgs<ExtArgs>>): Prisma.Prisma__AssetCommentClient<runtime.Types.Result.GetResult<Prisma.$AssetCommentPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -1156,6 +1285,10 @@ export type WorkflowTaskFindUniqueArgs<ExtArgs extends runtime.Types.Extensions.
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* Filter, which WorkflowTask to fetch.
|
||||
*/
|
||||
@@ -1174,6 +1307,10 @@ export type WorkflowTaskFindUniqueOrThrowArgs<ExtArgs extends runtime.Types.Exte
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* Filter, which WorkflowTask to fetch.
|
||||
*/
|
||||
@@ -1192,6 +1329,10 @@ export type WorkflowTaskFindFirstArgs<ExtArgs extends runtime.Types.Extensions.I
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* Filter, which WorkflowTask to fetch.
|
||||
*/
|
||||
@@ -1240,6 +1381,10 @@ export type WorkflowTaskFindFirstOrThrowArgs<ExtArgs extends runtime.Types.Exten
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* Filter, which WorkflowTask to fetch.
|
||||
*/
|
||||
@@ -1288,6 +1433,10 @@ export type WorkflowTaskFindManyArgs<ExtArgs extends runtime.Types.Extensions.In
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* Filter, which WorkflowTasks to fetch.
|
||||
*/
|
||||
@@ -1336,6 +1485,10 @@ export type WorkflowTaskCreateArgs<ExtArgs extends runtime.Types.Extensions.Inte
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* The data needed to create a WorkflowTask.
|
||||
*/
|
||||
@@ -1384,6 +1537,10 @@ export type WorkflowTaskUpdateArgs<ExtArgs extends runtime.Types.Extensions.Inte
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* The data needed to update a WorkflowTask.
|
||||
*/
|
||||
@@ -1450,6 +1607,10 @@ export type WorkflowTaskUpsertArgs<ExtArgs extends runtime.Types.Extensions.Inte
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* The filter to search for the WorkflowTask to update in case it exists.
|
||||
*/
|
||||
@@ -1476,6 +1637,10 @@ export type WorkflowTaskDeleteArgs<ExtArgs extends runtime.Types.Extensions.Inte
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
/**
|
||||
* Filter which WorkflowTask to delete.
|
||||
*/
|
||||
@@ -1496,6 +1661,25 @@ export type WorkflowTaskDeleteManyArgs<ExtArgs extends runtime.Types.Extensions.
|
||||
limit?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* WorkflowTask.transcriptionFailureComment
|
||||
*/
|
||||
export type WorkflowTask$transcriptionFailureCommentArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the AssetComment
|
||||
*/
|
||||
select?: Prisma.AssetCommentSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the AssetComment
|
||||
*/
|
||||
omit?: Prisma.AssetCommentOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.AssetCommentInclude<ExtArgs> | null
|
||||
where?: Prisma.AssetCommentWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* WorkflowTask without action
|
||||
*/
|
||||
@@ -1508,4 +1692,8 @@ export type WorkflowTaskDefaultArgs<ExtArgs extends runtime.Types.Extensions.Int
|
||||
* Omit specific fields from the WorkflowTask
|
||||
*/
|
||||
omit?: Prisma.WorkflowTaskOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WorkflowTaskInclude<ExtArgs> | null
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ declare global {
|
||||
transcode?: TranscodeSettings
|
||||
turntable?: TurntableSettings
|
||||
gotenberg?: GotenbergSettings
|
||||
embeddingServer?: { url?: string }
|
||||
mediaGeneration?: MediaGenerationSettings
|
||||
appearance?: AppearanceSettings
|
||||
emailNotification?: EmailNotificationSettings
|
||||
|
||||
@@ -213,6 +213,30 @@ export const updateGotenbergSettingsRequestSchema = z.object({
|
||||
})
|
||||
export type UpdateGotenbergSettingsRequest = z.infer<typeof updateGotenbergSettingsRequestSchema>
|
||||
|
||||
export const embeddingServerSettingsResponseSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
isEnvConfigured: z.boolean(),
|
||||
})
|
||||
export type EmbeddingServerSettingsResponse = z.infer<typeof embeddingServerSettingsResponseSchema>
|
||||
|
||||
export const updateEmbeddingServerSettingsRequestSchema = z.object({
|
||||
url: z
|
||||
.string()
|
||||
.trim()
|
||||
.refine((value) => {
|
||||
if (!value) return true
|
||||
const url = URL.parse(value)
|
||||
return (
|
||||
url !== null &&
|
||||
/^https?:\/\//i.test(value) &&
|
||||
!url.username &&
|
||||
!url.password &&
|
||||
!value.includes('?') &&
|
||||
!value.includes('#')
|
||||
)
|
||||
}, 'Enter an HTTP or HTTPS URL without credentials, a query string, or a fragment.'),
|
||||
})
|
||||
|
||||
export interface TeamAppearanceSettings {
|
||||
hideAgent?: boolean
|
||||
}
|
||||
@@ -228,6 +252,8 @@ export interface TeamSettingsResponse {
|
||||
}
|
||||
turntable?: TurntableSettingsResponse
|
||||
gotenberg?: GotenbergSettingsResponse
|
||||
embeddingServer?: EmbeddingServerSettingsResponse
|
||||
transcriptionAgentManagedByEnv?: boolean
|
||||
appearance?: TeamAppearanceSettings
|
||||
semanticSearchEnabled?: boolean
|
||||
archiveStorage?: ArchiveStorageInfo
|
||||
|
||||
@@ -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([]),
|
||||
)
|
||||
|
||||
@@ -53,7 +53,7 @@ interface AgentFormDialogProps {
|
||||
|
||||
const agentFormSchema = z.object({
|
||||
name: z.string().min(1, m.name_is_required()),
|
||||
type: z.enum(['chat', 'autofill', 'embedding']),
|
||||
type: z.enum(['chat', 'autofill', 'embedding', 'transcription']),
|
||||
permission: z.enum(['owner', 'editor', 'reviewer']),
|
||||
avatar: z.string().optional(),
|
||||
providerId: z.string().optional(),
|
||||
@@ -387,9 +387,12 @@ export function AgentFormDialog({
|
||||
if (!res.ok) throw new Error('Failed to create agent')
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSuccess: (_agent, values) => {
|
||||
onClose()
|
||||
queryClient.invalidateQueries({ queryKey: ['agents', teamId] })
|
||||
if (values.type === 'transcription') {
|
||||
void queryClient.invalidateQueries({ queryKey: ['signup-info'] })
|
||||
}
|
||||
toast.success(m.agent_created_successfully())
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -406,9 +409,12 @@ export function AgentFormDialog({
|
||||
if (!res.ok) throw new Error('Failed to update agent')
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSuccess: (_agent, { values }) => {
|
||||
onClose()
|
||||
queryClient.invalidateQueries({ queryKey: ['agents', teamId] })
|
||||
if (values.type === 'transcription') {
|
||||
void queryClient.invalidateQueries({ queryKey: ['signup-info'] })
|
||||
}
|
||||
toast.success(m.agent_updated_successfully())
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -502,6 +508,9 @@ export function AgentFormDialog({
|
||||
<SelectItem value="chat">{m.agent_type_chat()}</SelectItem>
|
||||
<SelectItem value="autofill">{m.agent_type_autofill()}</SelectItem>
|
||||
<SelectItem value="embedding">{m.agent_type_embedding()}</SelectItem>
|
||||
<SelectItem value="transcription">
|
||||
{m.agent_type_transcription()}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
Bot,
|
||||
ChevronDown,
|
||||
Cpu,
|
||||
Captions,
|
||||
Loader2,
|
||||
MessageSquare,
|
||||
MoreVertical,
|
||||
@@ -49,19 +50,21 @@ import { AgentFormDialog } from './AgentFormDialog'
|
||||
|
||||
interface AgentsSettingsProps {
|
||||
teamId: string
|
||||
transcriptionAgentManagedByEnv?: boolean
|
||||
}
|
||||
|
||||
const AGENT_TYPES: {
|
||||
type: AgentType
|
||||
label: string
|
||||
title: () => string
|
||||
icon: React.FC<React.SVGProps<SVGSVGElement>>
|
||||
}[] = [
|
||||
{ type: 'chat', label: 'Chat', icon: MessageSquare },
|
||||
{ type: 'autofill', label: 'Autofill', icon: Zap },
|
||||
{ type: 'embedding', label: 'Embedding', icon: Cpu },
|
||||
{ type: 'chat', title: m.chat_agents, icon: MessageSquare },
|
||||
{ type: 'autofill', title: m.autofill_agent, icon: Zap },
|
||||
{ type: 'embedding', title: m.embedding_agent, icon: Cpu },
|
||||
{ type: 'transcription', title: m.transcript_agent, icon: Captions },
|
||||
]
|
||||
|
||||
export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
export function AgentsSettings({ teamId, transcriptionAgentManagedByEnv }: AgentsSettingsProps) {
|
||||
const queryClient = useQueryClient()
|
||||
const { canAdmin } = usePermissions()
|
||||
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false)
|
||||
@@ -78,6 +81,7 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
const getSectionLabel = (type: AgentType) => {
|
||||
if (type === 'chat') return m.agent_type_chat()
|
||||
if (type === 'autofill') return m.agent_type_autofill()
|
||||
if (type === 'transcription') return m.agent_type_transcription()
|
||||
return m.agent_type_embedding()
|
||||
}
|
||||
|
||||
@@ -103,6 +107,9 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
onSuccess: () => {
|
||||
setIsDeleteDialogOpen(false)
|
||||
queryClient.invalidateQueries({ queryKey: ['agents', teamId] })
|
||||
if (agentToDelete?.type === 'transcription') {
|
||||
void queryClient.invalidateQueries({ queryKey: ['signup-info'] })
|
||||
}
|
||||
toast.success(m.agent_deleted_successfully())
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -170,9 +177,12 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
if (!res.ok) throw new Error('failed to update agent')
|
||||
return res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSuccess: (_agent, params) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['agents', teamId] })
|
||||
toast.success(m.agent_updated_successfully())
|
||||
if (params.type === 'transcription') {
|
||||
void queryClient.invalidateQueries({ queryKey: ['signup-info'] })
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(error.message)
|
||||
@@ -254,7 +264,9 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
{AGENT_TYPES.map((section) => {
|
||||
const typeAgents = agents.filter((a) => a.type === section.type)
|
||||
const Icon = section.icon
|
||||
const isSingleAgentType = section.type === 'autofill' || section.type === 'embedding'
|
||||
const isSingleAgentType = section.type !== 'chat'
|
||||
const isManagedTranscriptAgent =
|
||||
section.type === 'transcription' && transcriptionAgentManagedByEnv
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -269,13 +281,7 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
onClick={!isSingleAgentType ? () => toggleSection(section.type) : undefined}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<h3 className="font-semibold text-foreground">
|
||||
{section.type === 'chat'
|
||||
? m.chat_agents()
|
||||
: section.type === 'autofill'
|
||||
? m.autofill_agent()
|
||||
: m.embedding_agent()}
|
||||
</h3>
|
||||
<h3 className="font-semibold text-foreground">{section.title()}</h3>
|
||||
{!isSingleAgentType && (
|
||||
<Badge variant="secondary" className="h-5 px-1.5 min-w-[1.25rem] text-[10px]">
|
||||
{typeAgents.length}
|
||||
@@ -283,20 +289,23 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{!(isSingleAgentType && typeAgents.length > 0) && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 rounded-full bg-primary/10 text-primary hover:bg-primary/20"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setCreateType(section.type)
|
||||
setIsCreateDialogOpen(true)
|
||||
}}
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
</Button>
|
||||
)}
|
||||
{canAdmin &&
|
||||
!isManagedTranscriptAgent &&
|
||||
!(isSingleAgentType && typeAgents.length > 0) && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={m.create_type_agent({ type: getSectionLabel(section.type) })}
|
||||
className="h-8 w-8 rounded-full bg-primary/10 text-primary hover:bg-primary/20"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setCreateType(section.type)
|
||||
setIsCreateDialogOpen(true)
|
||||
}}
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
</Button>
|
||||
)}
|
||||
{!isSingleAgentType && (
|
||||
<ChevronDown
|
||||
className={cn(
|
||||
@@ -310,6 +319,13 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
|
||||
{(isSingleAgentType || expandedSections[section.type]) && (
|
||||
<div className="px-6 pb-6 pt-2 space-y-3">
|
||||
{section.type === 'transcription' && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{isManagedTranscriptAgent && typeAgents.length === 0
|
||||
? m.agent_managed_by_system_hint()
|
||||
: m.transcript_agent_description()}
|
||||
</p>
|
||||
)}
|
||||
<div className="grid grid-cols-1 gap-4">
|
||||
{typeAgents.map((agent) => (
|
||||
<Card
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { EmbeddingServerSettingsCard } from './EmbeddingServerSettingsCard'
|
||||
|
||||
const getSettings = vi.fn()
|
||||
const saveSettings = vi.fn()
|
||||
const testConnection = vi.fn()
|
||||
|
||||
vi.mock('@/ui/api/client', () => ({
|
||||
client: {
|
||||
api: {
|
||||
teams: {
|
||||
':teamId': {
|
||||
'embedding-server-settings': {
|
||||
$get: (args: unknown) => getSettings(args),
|
||||
$put: (args: unknown) => saveSettings(args),
|
||||
test: { $post: (args: unknown) => testConnection(args) },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }))
|
||||
|
||||
function renderCard() {
|
||||
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
||||
return render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<EmbeddingServerSettingsCard teamId="team-1" />
|
||||
</QueryClientProvider>,
|
||||
)
|
||||
}
|
||||
|
||||
describe('Embedding server integration card', () => {
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
vi.resetAllMocks()
|
||||
})
|
||||
|
||||
it('tests a draft URL and saves or clears it', async () => {
|
||||
getSettings.mockResolvedValue(Response.json({ isEnvConfigured: false }))
|
||||
const url = 'http://embedding:9379/v1'
|
||||
testConnection.mockResolvedValue(Response.json({ ok: true }))
|
||||
saveSettings
|
||||
.mockResolvedValueOnce(Response.json({ url, isEnvConfigured: false }))
|
||||
.mockResolvedValueOnce(Response.json({ isEnvConfigured: false }))
|
||||
renderCard()
|
||||
|
||||
const input = (await screen.findByLabelText('Server URL')) as HTMLInputElement
|
||||
fireEvent.change(input, { target: { value: url } })
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Test Connection' }))
|
||||
await screen.findByText('Connected successfully')
|
||||
const args = { param: { teamId: 'team-1' }, json: { url } }
|
||||
expect(testConnection).toHaveBeenCalledWith(args)
|
||||
expect(saveSettings).not.toHaveBeenCalled()
|
||||
|
||||
const save = screen.getByRole<HTMLButtonElement>('button', { name: 'Save' })
|
||||
fireEvent.click(save)
|
||||
await waitFor(() => expect(save.disabled).toBe(true))
|
||||
expect(saveSettings).toHaveBeenCalledWith(args)
|
||||
await waitFor(() => expect(input.disabled).toBe(false))
|
||||
fireEvent.change(input, { target: { value: '' } })
|
||||
fireEvent.click(save)
|
||||
await waitFor(() =>
|
||||
expect(saveSettings).toHaveBeenLastCalledWith({
|
||||
param: { teamId: 'team-1' },
|
||||
json: { url: '' },
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the environment URL read-only and tests the effective server', async () => {
|
||||
const url = 'http://embedding-server:9379/v1'
|
||||
getSettings.mockResolvedValue(Response.json({ url, isEnvConfigured: true }))
|
||||
testConnection.mockResolvedValue(Response.json({ ok: true }))
|
||||
renderCard()
|
||||
|
||||
const input = (await screen.findByLabelText('Server URL')) as HTMLInputElement
|
||||
expect(input.value).toBe(url)
|
||||
expect(input.readOnly).toBe(true)
|
||||
expect(screen.getByRole<HTMLButtonElement>('button', { name: 'Save' }).disabled).toBe(true)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Test Connection' }))
|
||||
await screen.findByText('Connected successfully')
|
||||
expect(testConnection).toHaveBeenCalledWith({ param: { teamId: 'team-1' }, json: {} })
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,148 @@
|
||||
import { useState } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { updateEmbeddingServerSettingsRequestSchema } from '@shumai/dtos'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { Badge } from '@/ui/components/ui/badge'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/ui/components/ui/card'
|
||||
import { Input } from '@/ui/components/ui/input'
|
||||
import { Label } from '@/ui/components/ui/label'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
export function EmbeddingServerSettingsCard({ teamId }: { teamId: string }) {
|
||||
const queryClient = useQueryClient()
|
||||
const queryKey = ['teams', teamId, 'embedding-server-settings']
|
||||
const endpoint = client.api.teams[':teamId']['embedding-server-settings']
|
||||
const [draft, setDraft] = useState<string | null>(null)
|
||||
|
||||
const {
|
||||
data: settings,
|
||||
isLoading,
|
||||
isError,
|
||||
} = useQuery({
|
||||
queryKey,
|
||||
queryFn: async () => {
|
||||
const response = await endpoint.$get({ param: { teamId } })
|
||||
if (!response.ok) throw new Error(m.failed_load_settings())
|
||||
return response.json()
|
||||
},
|
||||
})
|
||||
|
||||
const isReadOnly = Boolean(settings?.isEnvConfigured)
|
||||
const url = isReadOnly ? (settings?.url ?? '') : (draft ?? settings?.url ?? '')
|
||||
const validUrl =
|
||||
isReadOnly || updateEmbeddingServerSettingsRequestSchema.safeParse({ url }).success
|
||||
|
||||
const save = useMutation({
|
||||
mutationFn: async () => {
|
||||
const response = await endpoint.$put({ param: { teamId }, json: { url: url.trim() } })
|
||||
if (!response.ok) throw new Error(m.failed_update_settings())
|
||||
return response.json()
|
||||
},
|
||||
onSuccess: (updated) => {
|
||||
queryClient.setQueryData(queryKey, updated)
|
||||
setDraft(null)
|
||||
test.reset()
|
||||
void queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'settings'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['signup-info'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['transcription-languages'] })
|
||||
toast.success(m.settings_updated())
|
||||
},
|
||||
onError: () => toast.error(m.failed_update_settings()),
|
||||
})
|
||||
|
||||
const test = useMutation({
|
||||
mutationFn: async () => {
|
||||
const response = await endpoint.test.$post({
|
||||
param: { teamId },
|
||||
json: isReadOnly ? {} : { url: url.trim() },
|
||||
})
|
||||
if (!response.ok) throw new Error(m.embedding_server_connection_failed())
|
||||
return response.json()
|
||||
},
|
||||
})
|
||||
const isBusy = save.isPending || test.isPending
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<CardTitle>{m.embedding_server_settings()}</CardTitle>
|
||||
{isReadOnly && <Badge variant="secondary">{m.embedding_server_env_configured()}</Badge>}
|
||||
</div>
|
||||
<CardDescription>{m.embedding_server_description()}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
{isLoading ? (
|
||||
<Loader2 className="mx-auto my-6 size-6 animate-spin text-muted-foreground" />
|
||||
) : isError ? (
|
||||
<p role="alert" className="text-sm text-destructive">
|
||||
{m.failed_load_settings()}
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<Label htmlFor="embedding-server-url">{m.embedding_server_url()}</Label>
|
||||
<Input
|
||||
id="embedding-server-url"
|
||||
type="url"
|
||||
value={url}
|
||||
placeholder="http://embedding-server:9379/v1"
|
||||
readOnly={isReadOnly}
|
||||
disabled={isBusy}
|
||||
aria-invalid={!validUrl}
|
||||
aria-describedby={validUrl ? undefined : 'embedding-server-url-error'}
|
||||
onChange={(event) => {
|
||||
setDraft(event.target.value)
|
||||
test.reset()
|
||||
}}
|
||||
/>
|
||||
{!validUrl && (
|
||||
<p id="embedding-server-url-error" className="text-sm text-destructive">
|
||||
{m.embedding_server_invalid_url()}
|
||||
</p>
|
||||
)}
|
||||
{test.data?.ok && (
|
||||
<p role="status" className="text-sm">
|
||||
{m.embedding_server_connection_success()}
|
||||
</p>
|
||||
)}
|
||||
{(test.data?.ok === false || test.isError) && (
|
||||
<p role="alert" className="text-sm text-destructive">
|
||||
{m.embedding_server_connection_failed()}
|
||||
{test.data?.error && <> — {test.data.error}</>}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</CardContent>
|
||||
<CardFooter className="flex justify-between border-t border-border pt-4">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => test.mutate()}
|
||||
disabled={!settings || isBusy || !validUrl || !url.trim()}
|
||||
>
|
||||
{test.isPending && <Loader2 className="size-4 animate-spin" />}
|
||||
{m.embedding_server_test_connection()}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => save.mutate()}
|
||||
disabled={!settings || isReadOnly || isBusy || !validUrl || url === (settings.url ?? '')}
|
||||
>
|
||||
{save.isPending && <Loader2 className="size-4 animate-spin" />}
|
||||
{m.save()}
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
@@ -273,6 +273,17 @@
|
||||
"turntable_connection_success": "Connected successfully",
|
||||
"turntable_connection_failed": "Connection failed",
|
||||
"turntable_testing": "Testing...",
|
||||
"embedding_server_settings": "Embedding Server",
|
||||
"embedding_server_description": "Connect an EmbeddingGemma server for semantic search and video transcription.",
|
||||
"embedding_server_url": "Server URL",
|
||||
"embedding_server_env_configured": "Configured via environment variables (read-only)",
|
||||
"embedding_server_invalid_url": "Enter an HTTP or HTTPS URL without credentials, a query string, or a fragment.",
|
||||
"embedding_server_test_connection": "Test Connection",
|
||||
"embedding_server_connection_success": "Connected successfully",
|
||||
"embedding_server_connection_failed": "Connection failed",
|
||||
"agent_type_transcription": "Transcript",
|
||||
"transcript_agent": "Transcript Agent",
|
||||
"transcript_agent_description": "Posts an internal comment when a video transcription job fails.",
|
||||
"integrations": "Integrations",
|
||||
"integrations_settings_description": "Configure third-party service integrations for media rendering and document processing.",
|
||||
"storage": "Storage",
|
||||
|
||||
@@ -262,6 +262,17 @@
|
||||
"turntable_connection_success": "연결되었습니다",
|
||||
"turntable_connection_failed": "연결 실패",
|
||||
"turntable_testing": "테스트 중...",
|
||||
"embedding_server_settings": "임베딩 서버",
|
||||
"embedding_server_description": "시맨틱 검색과 동영상 음성 기록에 사용할 EmbeddingGemma 서버에 연결합니다.",
|
||||
"embedding_server_url": "서버 URL",
|
||||
"embedding_server_env_configured": "환경 변수로 설정됨(읽기 전용)",
|
||||
"embedding_server_invalid_url": "사용자 인증 정보, 쿼리 문자열 또는 프래그먼트가 없는 HTTP 또는 HTTPS URL을 입력하세요.",
|
||||
"embedding_server_test_connection": "연결 테스트",
|
||||
"embedding_server_connection_success": "연결되었습니다",
|
||||
"embedding_server_connection_failed": "연결 실패",
|
||||
"agent_type_transcription": "음성 기록",
|
||||
"transcript_agent": "음성 기록 에이전트",
|
||||
"transcript_agent_description": "동영상 음성 기록 작업이 실패하면 내부 댓글을 남깁니다.",
|
||||
"integrations": "연동",
|
||||
"integrations_settings_description": "미디어 렌더링과 문서 처리를 위한 외부 서비스 연동을 설정합니다.",
|
||||
"storage": "저장소",
|
||||
|
||||
@@ -273,6 +273,17 @@
|
||||
"turntable_connection_success": "连接成功",
|
||||
"turntable_connection_failed": "连接失败",
|
||||
"turntable_testing": "正在测试...",
|
||||
"embedding_server_settings": "向量模型服务",
|
||||
"embedding_server_description": "连接 EmbeddingGemma 服务以使用语义搜索和视频转录。",
|
||||
"embedding_server_url": "服务地址",
|
||||
"embedding_server_env_configured": "已通过环境变量配置(只读)",
|
||||
"embedding_server_invalid_url": "请输入不含凭据、查询参数或片段的 HTTP 或 HTTPS 地址。",
|
||||
"embedding_server_test_connection": "测试连接",
|
||||
"embedding_server_connection_success": "连接成功",
|
||||
"embedding_server_connection_failed": "连接失败",
|
||||
"agent_type_transcription": "转录",
|
||||
"transcript_agent": "转录智能体",
|
||||
"transcript_agent_description": "视频转录失败时发布内部评论。",
|
||||
"integrations": "集成",
|
||||
"integrations_settings_description": "配置用于媒体渲染与文档处理的第三方服务集成。",
|
||||
"storage": "存储",
|
||||
|
||||
@@ -24,6 +24,7 @@ import { AppearanceSettings } from '@/ui/components/settings/AppearanceSettings'
|
||||
import { EmailNotificationSettings } from '@/ui/components/settings/EmailNotificationSettings'
|
||||
import { ImageVideoGenerationSettings } from '@/ui/components/settings/ImageVideoGenerationSettings'
|
||||
import { TurntableSettingsCard } from '@/ui/components/settings/TurntableSettingsCard'
|
||||
import { EmbeddingServerSettingsCard } from '@/ui/components/settings/EmbeddingServerSettingsCard'
|
||||
import { GotenbergSettingsCard } from '@/ui/components/settings/GotenbergSettingsCard'
|
||||
import { StorageSettings } from '@/ui/components/settings/StorageSettings'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||
@@ -1227,7 +1228,10 @@ export function TeamSettingsPage() {
|
||||
|
||||
{activeTab === 'agents' && (
|
||||
<div className="h-full overflow-y-auto pr-1">
|
||||
<AgentsSettings teamId={teamId} />
|
||||
<AgentsSettings
|
||||
teamId={teamId}
|
||||
transcriptionAgentManagedByEnv={settings?.transcriptionAgentManagedByEnv}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1249,6 +1253,7 @@ export function TeamSettingsPage() {
|
||||
|
||||
{activeTab === 'integrations' && (
|
||||
<div className="h-full overflow-y-auto space-y-6 pr-1">
|
||||
<EmbeddingServerSettingsCard key={teamId} teamId={teamId} />
|
||||
<TurntableSettingsCard teamId={teamId} />
|
||||
<GotenbergSettingsCard teamId={teamId} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user