mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-10 23:58:28 +00:00
* feat: remove trigger and run base on bullmq * fix: telemetry and trigger deploymen * feat: add Ollama container and update ingestion status for unchanged documents * feat: add logger to bullmq workers * 1. Remove chat and deep-search from trigger 2. Add ai/sdk for chat UI 3. Added a better model manager * refactor: simplify clustered graph query and add stop conditions for AI responses * fix: streaming * fix: docker docs --------- Co-authored-by: Manoj <saimanoj58@gmail.com>
77 lines
1.8 KiB
TypeScript
77 lines
1.8 KiB
TypeScript
import { z } from "zod";
|
|
import { createActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
|
|
import { json } from "@remix-run/node";
|
|
import { prisma } from "~/db.server";
|
|
import { enqueueSpaceAssignment } from "~/lib/queue-adapter.server";
|
|
|
|
// Schema for manual assignment trigger
|
|
const ManualAssignmentSchema = z.object({
|
|
mode: z.enum(["new_space"]),
|
|
newSpaceId: z.string().optional(),
|
|
batchSize: z.number().min(1).max(100).optional().default(25),
|
|
});
|
|
|
|
const { action } = createActionApiRoute(
|
|
{
|
|
body: ManualAssignmentSchema,
|
|
allowJWT: true,
|
|
authorization: {
|
|
action: "manage",
|
|
},
|
|
corsStrategy: "all",
|
|
},
|
|
async ({ authentication, body }) => {
|
|
const userId = authentication.userId;
|
|
const user = await prisma.user.findUnique({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
select: {
|
|
Workspace: {
|
|
select: {
|
|
id: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
try {
|
|
let taskRun;
|
|
|
|
// Direct LLM assignment trigger
|
|
taskRun = await enqueueSpaceAssignment({
|
|
userId,
|
|
workspaceId: user?.Workspace?.id as string,
|
|
mode: body.mode,
|
|
newSpaceId: body.newSpaceId,
|
|
batchSize: body.batchSize,
|
|
});
|
|
|
|
return json({
|
|
success: true,
|
|
message: `${body.mode} assignment task triggered successfully`,
|
|
|
|
payload: {
|
|
userId,
|
|
mode: body.mode,
|
|
newSpaceId: body.newSpaceId,
|
|
batchSize: body.batchSize,
|
|
},
|
|
});
|
|
} catch (error) {
|
|
console.error("Error triggering space assignment:", error);
|
|
return json(
|
|
{
|
|
error:
|
|
error instanceof Error
|
|
? error.message
|
|
: "Failed to trigger assignment",
|
|
success: false,
|
|
},
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
},
|
|
);
|
|
|
|
export { action };
|