La forma
{ type, content?, url?, mime? }{"type": ..., "content": ..., "url": ..., "mime": ...}| tipo | Conteúdo |
|---|---|
| text | una string, in contenido |
| Imagem | uma imagem: url, ou base64 em content |
| video | um clipe: url, ou base64 em content |
| audio | uma gravação: url, ou base64 em content |
| Discorso | audio significato per essere transcritto piuttosto que descritto |
| Passès | troses di testo a rang o a compara, in lugar di lere come un |
| file | a document such as a PDF: url only, never content |
Duas formas de fornecer uma entrada
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"},
])Com uma url, o tipo é deduzido do que o servidor obtém. Com base64 em content — seus próprios bytes, ou um arquivo que você acabou de ler — não há nada para deduzir: defina mime você mesmo.
Ordore significa
Le inputs sono let in ordine di loro. Met la domanda prima del material quando si desidera legî-la con que la domanda in mente, e dopo quando si desidera una descrizione non prompteded prima.
Passatès non è solo più text
Diversi text inputs sono un corpo a lere. passages è un set di items separati a classificare o a comparare — che è ciò che un ricalcar ha bisogno.
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]},
])