Documents uploaded to a storage are cut up and indexed when they arrive, on our side. So the same call answers for a document database, a relational one and a bucket alike — the provider has nothing to do with it.
Parameters
querystringrequiredWhat you are looking for, in your own words.
limitintegerHow many passages to return.
await storage.run({ action: "search", query: "what is our refund window", limit: 5 });
// {
// results: [{ text: "…", score: 0.82, source: { id, name, index } }],
// scanned: 1240,
// model: "…",
// creditsUsed: 1
// }storage.run(action="search", query="what is our refund window", limit=5)
# {
# "results": [{"text": "…", "score": 0.82, "source": {"id", "name", "index"}}],
# "scanned": 1240,
# "model": "…",
# "creditsUsed": 1
# }results[].textstringThe passage itself — a fragment of a document, not the whole file.
results[].scorenumberHow close it is. Compare within one answer, not across two.
results[].sourceobject{ id, name, index } — which document, and which fragment of it.
scannedintegerHow many fragments were considered.
creditsUsedinteger1. Read it rather than assuming — it is what an agent's budget counts.
The credit, and when it comes back
Taken before the call and refunded on any refusal, including an unknown storage id — which vectorised nothing and should cost nothing.
It refuses rather than answering badly
Without a service to turn text into vectors, there is a fallback that is not semantic. Answering from it would return plausible scores that mean nothing — worse than no answer, because nothing tells you to distrust them.
import { IaGenifyError } from "iagenify";
try {
const found = await storage.run({ action: "search", query, limit: 5 });
return found.results;
} catch (err) {
if (err instanceof IaGenifyError && err.code === "embedding_unavailable") {
return null; // say « search is unavailable », never « nothing found »
}
throw err;
}from iagenify import IaGenifyError
def search(storage, query):
try:
return storage.run(action="search", query=query, limit=5)["results"]
except IaGenifyError as error:
if error.code == "embedding_unavailable":
return None # say « search is unavailable », never « nothing found »
raise