From acdc61d2ac48bb25a876818c4087575e489fdbac Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Sat, 30 Nov 2024 00:03:13 +0530 Subject: [PATCH] fix: allow user to syncPool when no evaluations are found (#67) * fix: allow user to syncPool when no evaluations are found * use triggeLLM instead of syncPool --- .../ApplicationEvaluationOverviewPage.tsx | 23 +++++++++++-- src/features/checker/services/checker/api.ts | 33 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/features/checker/pages/ApplicationEvaluationOverviewPage/ApplicationEvaluationOverviewPage.tsx b/src/features/checker/pages/ApplicationEvaluationOverviewPage/ApplicationEvaluationOverviewPage.tsx index 140bba11..096963c2 100644 --- a/src/features/checker/pages/ApplicationEvaluationOverviewPage/ApplicationEvaluationOverviewPage.tsx +++ b/src/features/checker/pages/ApplicationEvaluationOverviewPage/ApplicationEvaluationOverviewPage.tsx @@ -1,11 +1,13 @@ import { Hex } from "viem"; import { PoolSummary, ProjectBanner } from "@/components"; +import { triggerLLM } from "@/mainAll"; import { Button, Icon, IconType } from "@/primitives"; import { EvaluationList } from "~checker/components"; import { useApplicationOverviewEvaluations, useInitialize } from "~checker/hooks"; import { + goToApplicationEvaluationOverviewAction, goToReviewApplicationsAction, goToSubmitApplicationEvaluationAction, useCheckerDispatchContext, @@ -41,6 +43,16 @@ export const ApplicationEvaluationOverviewPage = ({ dispatch(goToReviewApplicationsAction()); }; + const syncAndRefresh = async () => { + await triggerLLM({ + chainId, + alloPoolId: poolId, + alloApplicationId: applicationId, + signature: "0xdeadbeef", + }); + dispatch(goToApplicationEvaluationOverviewAction({ projectId: applicationId })); + }; + const project = application.metadata.application.project; return ( @@ -79,9 +91,14 @@ export const ApplicationEvaluationOverviewPage = ({ {applicationEvaluations ? ( ) : ( -

- No evaluations have been submitted for this project yet. -

+
+
)}
diff --git a/src/features/checker/services/checker/api.ts b/src/features/checker/services/checker/api.ts index 364010f0..b3d43fa6 100644 --- a/src/features/checker/services/checker/api.ts +++ b/src/features/checker/services/checker/api.ts @@ -7,6 +7,13 @@ export interface SyncPoolBody { alloPoolId: string; } +export interface TriggerLLMBody { + chainId: number; + alloPoolId: string; + alloApplicationId: string; + signature: string; +} + export async function submitEvaluation( evaluationBody: EvaluationBody, ): Promise<{ evaluationId: string }> { @@ -61,6 +68,32 @@ export async function syncPool(syncPoolBody: SyncPoolBody): Promise { } } +export async function triggerLLM(triggerLLMBody: TriggerLLMBody): Promise { + const url = `${CHECKER_ENDPOINT}/api/evaluate/llm`; + + try { + const response = await fetch(url, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...triggerLLMBody, + }), + }); + + if (!response.ok) { + const errorData = await response.json(); + throw new Error(`Error: ${response.status} - ${errorData.message || "Unknown error"}`); + } + + return true; + } catch (error) { + console.error("Error triggering LLM:", error); + throw error; + } +} + export async function verifyCredentials( application: Partial, ): Promise<{ twitter: boolean; github: boolean }> {