Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
1.2 kB · 31 lines
TypeScript
1234567891011121314151617181920212223242526272829303132import { describe, expect, it } from "vitest";import type { KernelAttachment } from "../src/core/kernel/index.js";import { imageBlocksFromAttachments } from "../src/core/tools/ipython.js";
describe("imageBlocksFromAttachments", () => { it("returns no blocks when there are no attachments", () => { expect(imageBlocksFromAttachments(undefined)).toEqual([]); expect(imageBlocksFromAttachments([])).toEqual([]); });
it("converts supported image attachments to ImageContent blocks", () => { const attachments: KernelAttachment[] = [ { mimeType: "image/png", data: "AAAA", path: "/tmp/a.png" }, { mimeType: "image/jpeg", data: "BBBB" }, ]; expect(imageBlocksFromAttachments(attachments)).toEqual([ { type: "image", data: "AAAA", mimeType: "image/png" }, { type: "image", data: "BBBB", mimeType: "image/jpeg" }, ]); });
it("drops non-image attachments", () => { const attachments: KernelAttachment[] = [ { mimeType: "application/pdf", data: "CCCC" }, { mimeType: "image/webp", data: "DDDD" }, ]; expect(imageBlocksFromAttachments(attachments)).toEqual([ { type: "image", data: "DDDD", mimeType: "image/webp" }, ]); });});