add prompt variants

This commit is contained in:
Kyle Corbitt
2023-06-23 23:04:50 -07:00
parent 87154fd4b7
commit cde22ac4bf
6 changed files with 158 additions and 24 deletions

View File

@@ -16,6 +16,37 @@ export const promptVariantsRouter = createTRPCRouter({
});
}),
create: publicProcedure
.input(
z.object({
experimentId: z.string(),
})
)
.mutation(async ({ input }) => {
const maxSortIndex =
(
await prisma.promptVariant.aggregate({
where: {
experimentId: input.experimentId,
},
_max: {
sortIndex: true,
},
})
)._max.sortIndex ?? 0;
const newScenario = await prisma.promptVariant.create({
data: {
experimentId: input.experimentId,
label: `Prompt Variant ${maxSortIndex + 1}`,
sortIndex: maxSortIndex + 1,
config: {},
},
});
return newScenario;
}),
update: publicProcedure
.input(
z.object({