The shape
{ type, content?, url?, mime? }{"type": ..., "content": ..., "url": ..., "mime": ...}| type | Carries |
|---|---|
| text | a string, in content |
| image | a picture: url, or base64 in content |
| video | a clip: url, or base64 in content |
| audio | a recording: url, or base64 in content |
| speech | audio meant to be transcribed rather than described |
| passages | pieces of text to rank or compare, rather than read as one |
| file | a document such as a PDF: url only, never content |
Two ways to supply one
import { readFileSync } from "node:fs";
await assistant.generate({
inputs: [
{ type: "text", content: "What changed between these two?" },
{ type: "image", url: "https://example.com/before.png" }, // fetched for you
{ type: "image", content: base64Png, mime: "image/png" }, // already in hand
// A local file is content too — read it yourself, there is no "path" input:
{ type: "image", content: readFileSync("./after.png").toString("base64"), mime: "image/png" },
],
});import base64
from pathlib import Path
assistant.generate(inputs=[
{"type": "text", "content": "What changed between these two?"},
{"type": "image", "url": "https://example.com/before.png"}, # fetched for you
{"type": "image", "content": base64_png, "mime": "image/png"}, # already in hand
# A local file is content too — read it yourself, there is no "path" input:
{"type": "image", "content": base64.b64encode(Path("after.png").read_bytes()).decode(),
"mime": "image/png"},
])With a url the type is worked out for you from what the server fetches. With base64 in content — your own bytes, or a file you just read — there is nothing to work it out from, so set mime yourself.
Order is meaning
Inputs are read in the order you give them. Put the question before the material when you want it read with that question in mind, and after when you want an unprompted description first.
passages is not just more text
Several text inputs are one body to read. passages is a set of separate items to be ranked or compared — which is what a reranking call needs.
await reranker.generate({
inputs: [
{ type: "text", content: "Which of these answers the question best?" },
{ type: "passages", content: [chunkA, chunkB, chunkC] },
],
});reranker.generate(inputs=[
{"type": "text", "content": "Which of these answers the question best?"},
{"type": "passages", "content": [chunk_a, chunk_b, chunk_c]},
])