From 5281531d6f4aab4605c407d5167dd8e44f237f0d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 29 Sep 2024 23:43:10 +0000 Subject: feature(web): Add ability to rerun inference on all bookmarks. Fixes 443 --- .../components/dashboard/admin/AdminActions.tsx | 24 ++++++++++++++++++++++ packages/trpc/routers/admin.ts | 11 ++++++++++ 2 files changed, 35 insertions(+) diff --git a/apps/web/components/dashboard/admin/AdminActions.tsx b/apps/web/components/dashboard/admin/AdminActions.tsx index 783f7e76..dfdf65eb 100644 --- a/apps/web/components/dashboard/admin/AdminActions.tsx +++ b/apps/web/components/dashboard/admin/AdminActions.tsx @@ -35,6 +35,23 @@ export default function AdminActions() { }, }); + const { + mutate: reRunInferenceOnAllBookmarks, + isPending: isInferencePending, + } = api.admin.reRunInferenceOnAllBookmarks.useMutation({ + onSuccess: () => { + toast({ + description: "Inference jobs enqueued", + }); + }, + onError: (e) => { + toast({ + variant: "destructive", + description: e.message, + }); + }, + }); + return (
Actions
@@ -66,6 +83,13 @@ export default function AdminActions() { > Recrawl All Links (Without Inference) + reRunInferenceOnAllBookmarks()} + > + Regenerate AI Tags for All Bookmarks + triggerSearchReindex(b.id))); }), + reRunInferenceOnAllBookmarks: adminProcedure.mutation(async ({ ctx }) => { + const bookmarkIds = await ctx.db.query.bookmarks.findMany({ + columns: { + id: true, + }, + }); + + await Promise.all( + bookmarkIds.map((b) => OpenAIQueue.enqueue({ bookmarkId: b.id })), + ); + }), }); -- cgit v1.2.3-70-g09d2