diff --git a/evals/diff_editing/TestRunner.ts b/evals/diff_editing/TestRunner.ts index fc8aa75d2f..d5eedd992e 100644 --- a/evals/diff_editing/TestRunner.ts +++ b/evals/diff_editing/TestRunner.ts @@ -1,6 +1,6 @@ import { runSingleEvaluation, TestInput, TestResult } from "./ClineWrapper" import { basicSystemPrompt } from "./prompts/basicSystemPrompt" -import { formatResponse } from "../../src/core/prompts/responses" +import { formatResponse } from "./helpers" import { Anthropic } from "@anthropic-ai/sdk" import * as fs from "fs" import * as path from "path" diff --git a/evals/diff_editing/helpers.ts b/evals/diff_editing/helpers.ts new file mode 100644 index 0000000000..63ccd6d0c0 --- /dev/null +++ b/evals/diff_editing/helpers.ts @@ -0,0 +1,25 @@ +import { Anthropic } from "@anthropic-ai/sdk" + +const formatImagesIntoBlocks = (images?: string[]): Anthropic.ImageBlockParam[] => { + return images + ? images.map((dataUrl) => { + // data:image/png;base64,base64string + const [rest, base64] = dataUrl.split(",") + const mimeType = rest.split(":")[1].split(";")[0] + return { + type: "image", + source: { + type: "base64", + media_type: mimeType, + data: base64, + }, + } as Anthropic.ImageBlockParam + }) + : [] +} + +export const formatResponse = { + imageBlocks: (images?: string[]): Anthropic.ImageBlockParam[] => { + return formatImagesIntoBlocks(images) + }, +}