A support knowledge base that answers with citations
Write your help articles as files, then ask questions through the answer endpoint. Each answer cites the files it used, with path and version, and abstains instead of guessing when the evidence is not enough.
Example
Install the SDK (npm install @mirabase/sdk or pip install mirabase) and set MIRABASE_API_KEY.
import { Mirabase } from "@mirabase/sdk";
const mb = new Mirabase(); // reads MIRABASE_API_KEY
// waitSeconds holds the response for up to 10 seconds, until the file is indexed.
await mb.files.write("/help/refunds.md", "# Refunds\n\nRefunds are issued within 14 days of purchase.\n", {
contentType: "text/markdown",
waitSeconds: 10,
});
const reply = await mb.answer("How long do customers have to ask for a refund?");
if (reply.status === "answered") console.log(reply.answer, reply.citations);
else console.log("abstained:", reply.reason);
from mirabase import Mirabase
mb = Mirabase() # reads MIRABASE_API_KEY
# wait_seconds holds the response for up to 10 seconds, until the file is indexed.
mb.files.write(
"/help/refunds.md",
"# Refunds\n\nRefunds are issued within 14 days of purchase.\n",
content_type="text/markdown",
wait_seconds=10,
)
reply = mb.answer("How long do customers have to ask for a refund?")
if reply["status"] == "answered":
print(reply["answer"], reply["citations"])
else:
print("abstained:", reply.get("reason"))
A citation carries the file's path, its entry_id and version_id, and the passage. To use your own model instead, call mb.context(...) for a pack of sources within a token budget. See Retrieval and context.
Limits
- An answer requires the
knowledge:answercapability and counts toward the plan's monthly model usage. - A file is processed in the background after the write returns. Until it is indexed, search finds a short text file by its words only. See Processing.
- A single write accepts at most 16 MiB; larger files require a multipart upload. For many small files, use a batch write. See Write in a batch.
- If no Space is specified, an answer call reads every Space the key can read. Keep each customer's material in its own Space and specify it on each call, or issue a key limited to that Space.
- Update an article by writing to the same path. The earlier version is kept, and citations name the version they used.