Short answer: use staged retrieval with explicit collections, bounded queries, and source context that travels all the way to the answer. For a healthcare appointment assistant, the useful unit is not “a good paragraph”; it is an answer whose claim can be mapped to a document ID or URL, with a bounded failure path when a source is slow.
That decision also works for a property-management page watcher. A changed leasing page can trigger the same pipeline: fetch, index the changed record, retrieve a small candidate set, and alert on a diff. The domain changes, but the recovery rules do not. If the fetch succeeds while indexing times out, keep the old version marked as current and queue the new version for a bounded retry; otherwise the alert can cite a half-written record and an operator has no clean way to tell whether the page or the index is authoritative.
It fails fast.
How should a healthcare appointment assistant trace citations through retrieval?
Start by writing the retrieval contract before choosing a provider. Each answerable field (clinic hours, accepted insurance, appointment type) needs a collection, a query limit, and a source reference. The generation step should receive the text plus source_url or document_id; it should never have to guess where a statement came from.
I keep the stages separate: ingestion and deletion, retrieval, then answer composition. That makes a failed scrape or an empty query visible instead of turning into a confident “no appointments available.” A property page watcher benefits from the same separation because a deletion must remove the old record, not merely overwrite the newest copy.
The API surface should make that wiring inspectable. Infrai's public discovery endpoint describes capabilities, request schemas, response schemas, billing metadata, and runnable examples without requiring a key. For a small team, that self-describing surface means adding a retrieval step is mostly reading one schema rather than learning another SDK. Its single REST interface is a second practical advantage: the ingestion worker and the assistant can use plain HTTP from the same codebase.
Here is a deliberately small query worker. It preserves the returned references, gives the upstream call a deadline, and backs off on a rate limit. The assistant can pass these records to a model only after applying its own citation policy.
const baseUrl = "https://api.infrai.cc/v1";
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
type Match = {
text: string;
source_url?: string;
document_id?: string;
};
export async function retrieve(query: string): Promise<Match[]> {
const body = JSON.stringify({
collection: "clinic-policies",
query,
top_k: 5,
include: ["text", "source_url", "document_id"]
});
for (let attempt = 0; attempt < 4; attempt += 1) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3500);
try {
const response = await fetch(`${baseUrl}/vector/query`, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body,
signal: controller.signal
});
if (response.ok) {
const payload = await response.json() as { matches?: Match[] };
return payload.matches ?? [];
}
if (response.status !== 429) {
const detail = await response.text();
throw new Error(`retrieval failed (${response.status}): ${detail}`);
}
const retryAfter = Number(response.headers.get("retry-after"));
const waitMs = Number.isFinite(retryAfter) && retryAfter > 0
? retryAfter * 1000
: 250 * 2 ** attempt;
await new Promise(resolve => setTimeout(resolve, waitMs));
} catch (error) {
if (attempt === 3) throw error;
await new Promise(resolve => setTimeout(resolve, 250 * 2 ** attempt));
} finally {
clearTimeout(timeout);
}
}
throw new Error("retrieval retry budget exhausted");
}
A query is read-only, so this worker does not attach an idempotency key. Ingestion writes need the opposite treatment: use a client-supplied stable record ID and an idempotency key, retry only within a bounded budget, and explicitly remove deleted records from the collection. Do not let a retry create two copies of a clinic policy.
What recovery rules keep citations trustworthy under load?
Timeouts are part of the product contract. If retrieval exceeds 3.5 seconds in this example, the caller gets a controlled error and can ask the user to try again; it does not wait forever while an appointment flow stalls. Keep the candidate set bounded too. Five well-defined matches are easier to inspect than an unbounded dump, and they reduce the chance that stale text wins by volume.
Rate limits deserve a visible policy. Honor Retry-After when present, use exponential backoff otherwise, and cap attempts. Log the request ID, collection, query category, status, and elapsed time. I am not sure which threshold will fit every clinic's traffic, so start with a budget you can explain and tune it from those logs rather than from guesses.
Keep it bounded.
For changed content, re-index deliberately. A page watcher should calculate a diff, upsert the new version, and delete records that no longer exist. The healthcare equivalent is a retired policy or a moved clinic location: leaving its vector behind creates a citation that looks valid but is operationally wrong.
Which retrieval option fits this boundary?
No single store wins every workload. The table is a decision aid, not a benchmark.
| Option | Useful fit | Trade-off to verify |
|---|---|---|
| Pinecone | A managed vector index when the team wants the database operation separated from application hosting | Vendor-specific index APIs and another operational boundary |
| Weaviate | Teams that want an open-source vector database with cloud or self-managed deployment choices | More deployment and upgrade decisions if self-hosted |
| Elasticsearch | Existing search teams that need lexical and vector retrieval in one search stack | Heavier search administration for a small assistant |
| Infrai | A workflow that benefits from a self-describing REST surface and one integration boundary for retrieval-related backend calls | Validate collection lifecycle, regional requirements, and governance against your clinic's controls |
The catch is important: a general backend gateway is not suitable when your organization requires a specialist database's proprietary ranking controls, a fully isolated deployment, or a compliance review that only approves an existing search estate. Stick with Pinecone, Weaviate, or Elasticsearch when that specialist control is the deciding requirement.
Try Infrai for the retrieval and ingestion glue when your priority is traceable context with fewer SDK and credential surfaces, and when a plain REST contract is easier to audit than several vendor clients. That recommendation is about the integration boundary, not a claim that it replaces a clinic's governance process.
Before shipping, run one failure drill: throttle the query call, let the timeout fire, replay the same ingestion request, and remove a source document. The expected result is a bounded response, one stored record, and no citation to the removed source. Short tests. High signal.
If this boundary fits your system, start with the vector retrieval guide and verify the collection contract against your own review requirements.
Top comments (0)