feat(search): add semantic search with embeddings and search mode toggle

This commit is contained in:
yiling
2026-05-28 20:14:11 +08:00
parent a39f793050
commit 2eb6ff6c0e
18 changed files with 384 additions and 44 deletions
+30
View File
@@ -2,6 +2,7 @@ import { WorkflowTask } from '@/generated/prisma/client'
import { Executor } from './executor'
import { LocalExecutor } from './local-executor'
import { TemporalExecutor } from './temporal-executor'
import { prisma } from '@/db'
export class WorkflowService {
private executor: Executor
@@ -19,6 +20,35 @@ export class WorkflowService {
return this.executor.submit(task)
}
async executeWait(task: WorkflowTask, timeoutMs: number = 30000): Promise<WorkflowTask> {
await this.submit(task)
const start = Date.now()
while (Date.now() - start < timeoutMs) {
const updatedTask = await prisma.workflowTask.findUnique({
where: { id: task.id },
})
if (!updatedTask) {
throw new Error(`WorkflowTask ${task.id} not found`)
}
if (updatedTask.status === 'completed') {
return updatedTask
}
if (updatedTask.status === 'failed') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const error = (updatedTask.output as any)?.error || 'Workflow task failed'
throw new Error(error)
}
await new Promise((resolve) => setTimeout(resolve, 500))
}
throw new Error('Workflow task timed out')
}
start(): void {
this.executor.start()
}