mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 04:44:28 +00:00
fix(workflow): remove direct prisma database calls from query-embedding-for-search workflow
- Refactor queryEmbeddingForSearch workflow to use activities for DB updates - Add generic updateWorkflowTaskActivity database activity to decouple workflows from prisma runtime - Resolves webpack bundler scheme errors during docker build
This commit is contained in:
@@ -4,7 +4,7 @@ import type { AgentMessage, SessionTreeEntry } from '@earendil-works/pi-agent-co
|
||||
import { ulid } from 'ulid'
|
||||
import { metadataService } from '@/services/metadata/metadata'
|
||||
import { UpdateAssetMetadataRequest } from '@/dtos/metadata'
|
||||
import { WorkflowTaskStatus, AssetStatus } from '@/generated/prisma/client'
|
||||
import { WorkflowTaskStatus, AssetStatus, Prisma } from '@/generated/prisma/client'
|
||||
import type { AgentExecutionContext } from './agent'
|
||||
|
||||
export interface InitializeAgentSessionParams {
|
||||
@@ -590,3 +590,27 @@ export async function updateTaskUsageActivity(params: UpdateTaskUsageParams): Pr
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export interface UpdateWorkflowTaskParams {
|
||||
taskId: string
|
||||
status?: WorkflowTaskStatus
|
||||
heartbeat?: boolean
|
||||
output?: unknown
|
||||
inputTokens?: number
|
||||
outputTokens?: number
|
||||
model?: string | null
|
||||
}
|
||||
|
||||
export async function updateWorkflowTaskActivity(params: UpdateWorkflowTaskParams): Promise<void> {
|
||||
await prisma.workflowTask.update({
|
||||
where: { id: params.taskId },
|
||||
data: {
|
||||
...(params.status !== undefined ? { status: params.status } : {}),
|
||||
...(params.heartbeat ? { heartbeat: new Date() } : {}),
|
||||
...(params.output !== undefined ? { output: params.output as Prisma.InputJsonValue } : {}),
|
||||
...(params.inputTokens !== undefined ? { inputTokens: params.inputTokens } : {}),
|
||||
...(params.outputTokens !== undefined ? { outputTokens: params.outputTokens } : {}),
|
||||
...(params.model !== undefined ? { model: params.model } : {}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user