@sema-agent/core
Version:
Stateless, task-oriented AI agent core
31 lines (30 loc) • 1.27 kB
JavaScript
export function modelSupportsVision(model) {
return model?.input === undefined ? true : model.input.includes("image");
}
export const IMAGE_OMITTED_NO_VISION = "[image omitted: the serving model does not support image input]";
export function imagesOmittedNoVisionNote(count) {
return count > 1 ? `[${count} images omitted: the serving model does not support image input]` : IMAGE_OMITTED_NO_VISION;
}
export function sendableImages(blocks) {
const out = [];
for (const b of blocks) {
const c = b;
if (c.type === "image" && typeof c.data === "string" && typeof c.mimeType === "string") {
out.push({ type: "image", data: c.data, mimeType: c.mimeType });
}
}
return out;
}
function plural(count, noun) {
return `${count} ${noun}${count > 1 ? "s" : ""}`;
}
export function errorResultMediaNote(counts) {
const dropped = [];
if (counts.images > 0)
dropped.push(plural(counts.images, "image"));
if (counts.documents > 0)
dropped.push(plural(counts.documents, "document"));
if (dropped.length === 0)
return undefined;
return `[${dropped.join(" and ")} omitted — an error tool result must be text-only; re-run the tool successfully if you need the attachment]`;
}