Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

import telys works without the runtime, but every collection operation loads the signed native runtime lazily, and AlgentaMultigramEmbedder needs the native kernel. telys login installs both. Without them you see RuntimeNotInstalled (engine) or ImportError (embedder). See Verify your install.

1

Install the CLI

pipx isolates the CLI in its own environment; pip installs it into the current one.

pipx install telys

Preferred: puts telys on your PATH without touching your project's dependencies.

pip install telys

Use pip to make telys importable in the same environment as your application code.

Confirm the version:

telys version

Expected result:

telys 0.1.15 (format v1)
2

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 login

For headless machines or CI, pass a token instead of opening a browser:

telys login --token $TELYS_TOKEN

Confirm the runtime is present and its signature verifies:

telys runtime verify
3

Create 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.

4

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"},
    ],
)
5

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.

6

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))   # 3

Troubleshooting

RuntimeNotInstalled on the first collection call

The signed runtime is not installed or not verified. Run telys login, then telys runtime verify. See Install & runtime issues.

ImportError when constructing AlgentaMultigramEmbedder

The lexical embedders need the native kernel that ships with the verified runtime. Confirm the runtime is installed (telys runtime status), or point Telys at a kernel with $TELYS_KERNEL. See Embedding dimension mismatches.

KeyError from add_texts

One of the ids already exists. add_texts only inserts new rows. Use upsert_texts to insert-or-replace, or pick fresh ids.

Next steps

Last updated

Was this helpful?