use helpers

This commit is contained in:
0xtoshii
2025-06-06 18:12:02 -07:00
parent 0c41c2c85f
commit f6dcae3f0c
2 changed files with 26 additions and 1 deletions
+1 -1
View File
@@ -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"
+25
View File
@@ -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)
},
}