From 5ef83213038c479a0380d3ccb848a080ea40a48f Mon Sep 17 00:00:00 2001 From: ramnique <30795890+ramnique@users.noreply.github.com> Date: Fri, 14 Feb 2025 23:45:26 +0530 Subject: [PATCH] fix api types --- apps/rowboat/app/api/v1/[projectId]/chat/route.ts | 9 +++------ apps/rowboat/app/lib/types/types.ts | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/rowboat/app/api/v1/[projectId]/chat/route.ts b/apps/rowboat/app/api/v1/[projectId]/chat/route.ts index e6414cf9..f87bd6b4 100644 --- a/apps/rowboat/app/api/v1/[projectId]/chat/route.ts +++ b/apps/rowboat/app/api/v1/[projectId]/chat/route.ts @@ -54,13 +54,10 @@ export async function POST( } // if workflow id is provided in the request, use it, else use the published workflow id - let workflowId = result.data.workflowId; + let workflowId = result.data.workflowId ?? project.publishedWorkflowId; if (!workflowId) { - workflowId = project.publishedWorkflowId; - } - if (!workflowId) { - logger.log(`Project ${projectId} has no published workflow`); - return Response.json({ error: "Project has no published workflow" }, { status: 404 }); + logger.log(`No workflow id provided in request or project has no published workflow`); + return Response.json({ error: "No workflow id provided in request or project has no published workflow" }, { status: 404 }); } // fetch workflow const workflow = await agentWorkflowsCollection.findOne({ diff --git a/apps/rowboat/app/lib/types/types.ts b/apps/rowboat/app/lib/types/types.ts index d12f97c1..b412208b 100644 --- a/apps/rowboat/app/lib/types/types.ts +++ b/apps/rowboat/app/lib/types/types.ts @@ -107,9 +107,9 @@ export const ApiMessage = z.union([ export const ApiRequest = z.object({ messages: z.array(ApiMessage), state: z.unknown(), - skipToolCalls: z.boolean().optional(), - maxTurns: z.number().optional(), - workflowId: z.string().optional(), + skipToolCalls: z.boolean().nullable().optional(), + maxTurns: z.number().nullable().optional(), + workflowId: z.string().nullable().optional(), }); export const ApiResponse = z.object({