mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 16:28:28 +00:00
fix: add queue for space-assignemt
This commit is contained in:
parent
bcc0560cf0
commit
fa2511e540
@ -1,4 +1,4 @@
|
|||||||
import { task } from "@trigger.dev/sdk/v3";
|
import { queue, task } from "@trigger.dev/sdk/v3";
|
||||||
import { logger } from "~/services/logger.service";
|
import { logger } from "~/services/logger.service";
|
||||||
import { SpaceService } from "~/services/space.server";
|
import { SpaceService } from "~/services/space.server";
|
||||||
import { makeModelCall } from "~/lib/model.server";
|
import { makeModelCall } from "~/lib/model.server";
|
||||||
@ -75,8 +75,14 @@ const AssignmentResultSchema = z.array(
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const spaceAssignmentQueue = queue({
|
||||||
|
name: "space-assignment-queue",
|
||||||
|
concurrencyLimit: 1,
|
||||||
|
});
|
||||||
|
|
||||||
export const spaceAssignmentTask = task({
|
export const spaceAssignmentTask = task({
|
||||||
id: "space-assignment",
|
id: "space-assignment",
|
||||||
|
queue: spaceAssignmentQueue,
|
||||||
maxDuration: 1800, // 15 minutes timeout
|
maxDuration: 1800, // 15 minutes timeout
|
||||||
run: async (payload: SpaceAssignmentPayload) => {
|
run: async (payload: SpaceAssignmentPayload) => {
|
||||||
const {
|
const {
|
||||||
@ -704,9 +710,15 @@ async function processBatch(
|
|||||||
|
|
||||||
// Episode-intent matching is MEDIUM complexity (semantic analysis with intent alignment)
|
// Episode-intent matching is MEDIUM complexity (semantic analysis with intent alignment)
|
||||||
let responseText = "";
|
let responseText = "";
|
||||||
await makeModelCall(false, prompt, (text: string) => {
|
await makeModelCall(
|
||||||
responseText = text;
|
false,
|
||||||
}, undefined, 'high');
|
prompt,
|
||||||
|
(text: string) => {
|
||||||
|
responseText = text;
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
"high",
|
||||||
|
);
|
||||||
|
|
||||||
// Response text is now set by the callback
|
// Response text is now set by the callback
|
||||||
|
|
||||||
@ -1179,5 +1191,9 @@ function parseLLMResponse(
|
|||||||
|
|
||||||
// Helper function to trigger the task
|
// Helper function to trigger the task
|
||||||
export async function triggerSpaceAssignment(payload: SpaceAssignmentPayload) {
|
export async function triggerSpaceAssignment(payload: SpaceAssignmentPayload) {
|
||||||
return await spaceAssignmentTask.trigger(payload);
|
return await spaceAssignmentTask.trigger(payload, {
|
||||||
|
queue: "space-assignment-queue",
|
||||||
|
concurrencyKey: payload.userId,
|
||||||
|
tags: [payload.userId],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,6 @@ export const addToQueue = async (
|
|||||||
|
|
||||||
const queuePersist = await prisma.ingestionQueue.create({
|
const queuePersist = await prisma.ingestionQueue.create({
|
||||||
data: {
|
data: {
|
||||||
spaceId: body.spaceId ? body.spaceId : null,
|
|
||||||
data: body,
|
data: body,
|
||||||
type: body.type,
|
type: body.type,
|
||||||
status: IngestionStatus.PENDING,
|
status: IngestionStatus.PENDING,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user