Skip to content

Commit

Permalink
fix: allow user to syncPool when no evaluations are found (#67)
Browse files Browse the repository at this point in the history
* fix: allow user to syncPool when no evaluations are found

* use triggeLLM instead of syncPool
  • Loading branch information
thelostone-mc authored Nov 29, 2024
1 parent 67a82ac commit acdc61d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -79,9 +91,14 @@ export const ApplicationEvaluationOverviewPage = ({
{applicationEvaluations ? (
<EvaluationList evaluations={applicationEvaluations} />
) : (
<p className="text-center text-lg">
No evaluations have been submitted for this project yet.
</p>
<div className="flex flex-col items-center gap-8">
<Button
variant="outlined-success"
value="Trigger AI evaluation"
onClick={syncAndRefresh}
/>
<p className="text-lg">No evaluations have been submitted for this project yet.</p>
</div>
)}
</div>
<div className="flex items-center justify-center">
Expand Down
33 changes: 33 additions & 0 deletions src/features/checker/services/checker/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }> {
Expand Down Expand Up @@ -61,6 +68,32 @@ export async function syncPool(syncPoolBody: SyncPoolBody): Promise<boolean> {
}
}

export async function triggerLLM(triggerLLMBody: TriggerLLMBody): Promise<boolean> {
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<ProjectApplicationForManager>,
): Promise<{ twitter: boolean; github: boolean }> {
Expand Down

0 comments on commit acdc61d

Please sign in to comment.