From 310fe2e95b64cb12d385bb73184f97c80b462b13 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Wed, 9 Oct 2024 11:38:34 -0700 Subject: [PATCH] cr --- evals/highlights.ts | 20 +++++++++++++------- package.json | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/evals/highlights.ts b/evals/highlights.ts index 8f6163ae..f423d1b0 100644 --- a/evals/highlights.ts +++ b/evals/highlights.ts @@ -3,11 +3,13 @@ import { graph } from "../src/agent/index"; import { evaluate, EvaluationResult } from "langsmith/evaluation"; import "dotenv/config"; -const runGraph = async (input: Record): Promise> => { +const runGraph = async ( + input: Record +): Promise> => { // Interrupt after updating the artifact graph.interruptAfter = ["updateArtifact"]; return await graph.invoke(input); -} +}; const evaluateHighlights = (run: Run, example?: Example): EvaluationResult => { if (!example) { @@ -22,22 +24,26 @@ const evaluateHighlights = (run: Run, example?: Example): EvaluationResult => { const { expectedGeneration } = example.outputs; const { highlighted, artifacts } = example.inputs; - const expectedGenerationStart = artifacts[0].content.slice(0, highlighted.startCharIndex); - const expectedGenerationEnd = artifacts[0].content.slice(highlighted.endCharIndex); + const expectedGenerationStart = artifacts[0].content.slice( + 0, + highlighted.startCharIndex + ); + const expectedGenerationEnd = artifacts[0].content.slice( + highlighted.endCharIndex + ); const fullExpectedArtifact = `${expectedGenerationStart}${expectedGeneration}${expectedGenerationEnd}`; - const generatedArtifact = run.outputs.artifacts[0].content; if (generatedArtifact !== fullExpectedArtifact) { return { key: "correct_generation", score: false, - } + }; } return { key: "correct_generation", score: true, - } + }; }; async function runHighlightEval() { diff --git a/package.json b/package.json index eb524388..b17da512 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "next build", "start": "next start", "lint": "next lint", - "format": "prettier --config .prettierrc --write \"src\"", + "format": "prettier --config .prettierrc --write \"src\" \"evals\"", "eval:highlights": "yarn tsx evals/highlights.ts" }, "dependencies": {