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:
+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`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user