First collection
Install Telys, sign in, then create a collection, add text, search it, and persist it to disk — end to end in a few minutes.
Go from pip install to a saved, searchable collection. Install the CLI, sign in to activate the runtime, then use the Python SDK to create a collection, add documents, search them, and save to disk.
Install the CLI
pipx isolates the CLI in its own environment; pip installs it into the current one.
pipx install telysPreferred: puts telys on your PATH without touching your project's dependencies.
pip install telysUse pip to make telys importable in the same environment as your application code.
Confirm the version:
telys versionExpected result:
telys 0.1.15 (format v1)Sign in and install the runtime
The SDK is a thin wrapper over a signed native runtime. telys login authenticates you (browser device-code flow by default) and installs the runtime for the free telys_developer plan.
telys loginFor headless machines or CI, pass a token instead of opening a browser:
telys login --token $TELYS_TOKENConfirm the runtime is present and its signature verifies:
telys runtime verifyCreate a collection
A collection lives under a store directory. Telys("./memory") creates that directory and loads the runtime on demand. create_collection builds and caches the collection in memory; it does not write to disk yet.
from telys import Telys
from telys.embedding import AlgentaMultigramEmbedder
t = Telys("./memory")
# Lexical, on-device embedder. Its dimension is read from the native kernel,
# so let it define the collection's dimension rather than hard-coding a number.
emb = AlgentaMultigramEmbedder()
col = t.create_collection(
"notes",
dim=emb.profile.dimension,
partition_by="scope",
embedder=emb,
# Only declared filter_columns are stored and returned by with_metadata=True.
# List "scope" too so the partition key comes back in each hit's metadata.
filter_columns=("scope", "category"),
)partition_by="scope" names the metadata field used as each record's physical partition key. Every record you add must carry that field.
Add a few documents
add_texts embeds each string and inserts it as a new row. ids are your own external identifiers; metadata is a per-row payload that must include the partition field (scope).
col.add_texts(
texts=[
"Telys keeps every vector on your own machine, offline by default.",
"A collection is written to disk only when you call save().",
"The signed runtime is a native library loaded on demand.",
],
ids=["doc-1", "doc-2", "doc-3"],
metadata=[
{"scope": "notes", "category": "storage"},
{"scope": "notes", "category": "lifecycle"},
{"scope": "notes", "category": "runtime"},
],
)Search the collection
search_text embeds the query with the same embedder and returns the closest ids and their scores. Pass with_metadata=True to include each hit's payload.
results = col.search_text(
"how do I write a collection to disk?",
top_k=3,
with_metadata=True,
)
print(results)Expected result:
{'ids': ['doc-2', 'doc-1', 'doc-3'],
'scores': [0.68, 0.21, 0.14],
'metadata': [{'scope': 'notes', 'category': 'lifecycle'},
{'scope': 'notes', 'category': 'storage'},
{'scope': 'notes', 'category': 'runtime'}]}ids and scores are aligned and sorted best-first. Scores are the inner product of L2-normalized vectors (cosine similarity): higher means more similar, and 1.0 is an identical match. Because AlgentaMultigramEmbedder is lexical, the top hit is the sentence that shares the most words and character n-grams with the query.
Persist to disk
Nothing so far survives the process. save() writes the id-map sidecar, then collection.json (the commit point), and returns the collection's directory.
path = col.save()
print(path)
# Only saved collections show up here:
print(t.collections())Expected result:
./memory/notes
['notes']Reopen it later in a fresh process, passing the same embedder. open_collection only auto-attaches an embedder you registered earlier with register_provider:
from telys import Telys
from telys.embedding import AlgentaMultigramEmbedder
t = Telys("./memory")
col = t.open_collection("notes", embedder=AlgentaMultigramEmbedder())
print(len(col)) # 3Troubleshooting
Next steps
Last updated
Was this helpful?