🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
import { useRouter } from "next/router";
import { EvalTemplateTypeEnum } from "@langfuse/shared";
import { EvaluatorSetupLoadingPage } from "@/src/features/evals/v2/components/Evaluators/EvaluatorSetupLoadingPage/EvaluatorSetupLoadingPage";
import { useEvalTemplate } from "@/src/features/evals/v2/hooks/useEvalTemplate";
import { EvaluatorSetupPage } from "./EvaluatorSetupPage";
function requestedEvaluatorType(value: string | string[] | undefined) {
if (value === EvalTemplateTypeEnum.CODE) {
return EvalTemplateTypeEnum.CODE;
}
if (value === EvalTemplateTypeEnum.DECISION_MODEL) {
return EvalTemplateTypeEnum.DECISION_MODEL;
}
return EvalTemplateTypeEnum.LLM_AS_JUDGE;
}
export default function NewEvaluatorPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
const templateKey =
typeof router.query.template === "string" ? router.query.template : null;
const evaluatorId =
typeof router.query.evaluatorId === "string"
? router.query.evaluatorId
: null;
const template = useEvalTemplate({
projectId,
templateKey,
evaluatorId,
enabled: router.isReady,
});
if (!router.isReady || template.isPending) {
return <EvaluatorSetupLoadingPage mode="create" projectId={projectId} />;
}
if (template.isNotFound) {
return <div className="p-6">Evaluator template not found</div>;
}
const initialType = requestedEvaluatorType(router.query.type);
const creationSource = (() => {
if (templateKey) {
return { type: "managed" as const, templateKey };
}
if (evaluatorId) {
return { type: "custom" as const };
}
return { type: "scratch" as const };
})();
return (
<EvaluatorSetupPage
mode="create"
key={templateKey ?? evaluatorId ?? initialType}
projectId={projectId}
initialDraft={template.draft}
initialType={initialType}
creationSource={creationSource}
/>
);
}