Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit acdc61d

Browse files
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
1 parent 67a82ac commit acdc61d

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/features/checker/pages/ApplicationEvaluationOverviewPage/ApplicationEvaluationOverviewPage.tsx

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Hex } from "viem";
22

33
import { PoolSummary, ProjectBanner } from "@/components";
4+
import { triggerLLM } from "@/mainAll";
45
import { Button, Icon, IconType } from "@/primitives";
56

67
import { EvaluationList } from "~checker/components";
78
import { useApplicationOverviewEvaluations, useInitialize } from "~checker/hooks";
89
import {
10+
goToApplicationEvaluationOverviewAction,
911
goToReviewApplicationsAction,
1012
goToSubmitApplicationEvaluationAction,
1113
useCheckerDispatchContext,
@@ -41,6 +43,16 @@ export const ApplicationEvaluationOverviewPage = ({
4143
dispatch(goToReviewApplicationsAction());
4244
};
4345

46+
const syncAndRefresh = async () => {
47+
await triggerLLM({
48+
chainId,
49+
alloPoolId: poolId,
50+
alloApplicationId: applicationId,
51+
signature: "0xdeadbeef",
52+
});
53+
dispatch(goToApplicationEvaluationOverviewAction({ projectId: applicationId }));
54+
};
55+
4456
const project = application.metadata.application.project;
4557

4658
return (
@@ -79,9 +91,14 @@ export const ApplicationEvaluationOverviewPage = ({
7991
{applicationEvaluations ? (
8092
<EvaluationList evaluations={applicationEvaluations} />
8193
) : (
82-
<p className="text-center text-lg">
83-
No evaluations have been submitted for this project yet.
84-
</p>
94+
<div className="flex flex-col items-center gap-8">
95+
<Button
96+
variant="outlined-success"
97+
value="Trigger AI evaluation"
98+
onClick={syncAndRefresh}
99+
/>
100+
<p className="text-lg">No evaluations have been submitted for this project yet.</p>
101+
</div>
85102
)}
86103
</div>
87104
<div className="flex items-center justify-center">

src/features/checker/services/checker/api.ts

+33
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ export interface SyncPoolBody {
77
alloPoolId: string;
88
}
99

10+
export interface TriggerLLMBody {
11+
chainId: number;
12+
alloPoolId: string;
13+
alloApplicationId: string;
14+
signature: string;
15+
}
16+
1017
export async function submitEvaluation(
1118
evaluationBody: EvaluationBody,
1219
): Promise<{ evaluationId: string }> {
@@ -61,6 +68,32 @@ export async function syncPool(syncPoolBody: SyncPoolBody): Promise<boolean> {
6168
}
6269
}
6370

71+
export async function triggerLLM(triggerLLMBody: TriggerLLMBody): Promise<boolean> {
72+
const url = `${CHECKER_ENDPOINT}/api/evaluate/llm`;
73+
74+
try {
75+
const response = await fetch(url, {
76+
method: "POST",
77+
headers: {
78+
"Content-Type": "application/json",
79+
},
80+
body: JSON.stringify({
81+
...triggerLLMBody,
82+
}),
83+
});
84+
85+
if (!response.ok) {
86+
const errorData = await response.json();
87+
throw new Error(`Error: ${response.status} - ${errorData.message || "Unknown error"}`);
88+
}
89+
90+
return true;
91+
} catch (error) {
92+
console.error("Error triggering LLM:", error);
93+
throw error;
94+
}
95+
}
96+
6497
export async function verifyCredentials(
6598
application: Partial<ProjectApplicationForManager>,
6699
): Promise<{ twitter: boolean; github: boolean }> {

0 commit comments

Comments
 (0)