SessionIndex, created from
client.session(). For the full method
list, see the SDK reference.
Create or resume
client.session(index_name=...) returns a SessionIndex. If a cloud index with that name
already exists, it auto-loads into the session (no re-embedding); otherwise the session
starts empty. The workflow is identical in both cases, so you do not branch on whether the
index exists.
Mutate and query locally
add_docs, delete_docs, and get_docs run in-memory; add_docs embeds locally via the
Rust core with no network call. query also runs entirely in-memory (~1-10 ms) and supports
the same metadata filter syntax as client.query().
Persist to the cloud
push_index() uploads the session - documents and their locally-computed embeddings - to
the cloud under the session’s name, creating or replacing that index. No server-side
re-embedding occurs.
Extend an existing index
Becausesession() resumes by name, the same code extends an index across runs. Resume,
append new documents, then push back to overwrite the cloud copy with the combined set.
Live-call context: short-term plus long-term
A session is short-term context - the working set for the current interaction. A persistent cloud index loaded withload_index()
is long-term context - durable knowledge shared across interactions. A typical live call
loads a cloud FAQ index for long-term context and opens a session for short-term context,
then queries both for each turn.
Behavior notes
- The session’s embedding model is set by
model_idonsession()(default"moss-minilm"; also"moss-mediumlm"or"custom"). When resuming an existing cloud index, omitmodel_idto adopt the stored model - passing a different one raises aValueError. All participants resuming the same index must use the same model. - With
model_id="custom", each document must carry its own.embeddingand every query must passQueryOptions.embedding. See Custom embeddings. - Project credentials are validated when the session is opened;
session()raises if they are invalid.
Related
SessionIndex reference
Every session method and property.
Metadata filtering
Filter inside a session query.