Files
famapp/tests/unit/llm-content.test.ts
ginnoir c8db5475d3 feat(agent): add voice input and photo attachments to assistant
Wire mic through Whisper-compatible transcriptions on LLM_BASE_URL.

Photos upload to MinIO and reach the vision model as base64 image_url parts.
2026-07-05 02:01:48 -05:00

28 lines
932 B
TypeScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { buildVisionContentParts, textFromMessageContent } from "../../src/lib/llm/content";
describe("llm content helpers", () => {
it("reads plain string content", () => {
assert.equal(textFromMessageContent("hello"), "hello");
});
it("joins text parts from multimodal content", () => {
assert.equal(
textFromMessageContent([
{ type: "text", text: "first" },
{ type: "image_url", image_url: { url: "data:image/png;base64,abc" } },
{ type: "text", text: "second" },
]),
"first\nsecond",
);
});
it("builds vision parts with fallback prompt when text is empty", () => {
const parts = buildVisionContentParts("", ["data:image/jpeg;base64,abc"]);
assert.equal(parts.length, 2);
assert.equal(parts[0]?.type, "text");
assert.equal(parts[1]?.type, "image_url");
});
});