Framework bridge
Build your own thin adapter to use Telys as a retriever or vector store inside LangChain or LlamaIndex, using only the public SDK and CallableEmbedder.
Both frameworks share one vector-store contract: add texts with metadata, and given a query, return the most similar texts. Telys provides both — add_texts and search_text — so the adapter is mostly plumbing. Get one thing right: the embedding space. Use CallableEmbedder to wrap the same embedding model your framework uses elsewhere, so the vectors match.
A framework-agnostic core
Start with an adapter that depends only on telys. With no framework imports, it runs and tests standalone; the wrappers below are thin shims over it.
import numpy as np
from telys import Telys, Eq
from telys.embedding import CallableEmbedder, EmbeddingProfile
class TelysStore:
"""A minimal, framework-neutral vector store over one Telys collection."""
def __init__(self, embed_fn, dimension: int, path: str = "./telys-store",
name: str = "docs", model_id: str = "byo-model"):
profile = EmbeddingProfile(
provider="bridge",
model_id=model_id,
model_version="1",
dimension=dimension,
normalization="l2",
distance="ip",
)
embedder = CallableEmbedder(
lambda texts: np.asarray(embed_fn(texts), dtype="float32"),
profile,
)
self.telys = Telys(path)
try:
self.col = self.telys.open_collection(name, embedder=embedder)
except FileNotFoundError:
self.col = self.telys.create_collection(
name, dim=dimension, partition_by="source", embedder=embedder,
# Only declared filter_columns round-trip through
# search_text(..., with_metadata=True). Any dynamic `extra` keys
# you pass to add_texts must ALSO be listed here, or they will
# NOT be returned in each hit's metadata.
filter_columns=("source", "text"),
)
self.col.save()
def add_texts(self, texts, ids, sources=None, extra=None):
sources = sources or ["default"] * len(texts)
extra = extra or [{}] * len(texts)
metas = [
{"source": s, "text": t, **e}
for t, s, e in zip(texts, sources, extra)
]
self.col.add_texts(list(texts), list(ids), metas)
self.col.save()
return ids
def similarity_search(self, query: str, k: int = 4, source: str | None = None):
res = self.col.search_text(
query,
top_k=k,
where=Eq("source", source) if source else None,
with_metadata=True,
)
return [
{"id": i, "score": s, "text": m["text"], "metadata": m}
for i, s, m in zip(res["ids"], res["scores"], res["metadata"])
]Wrap it as a LangChain retriever
LangChain's retriever contract is one method, _get_relevant_documents, returning Document objects. The shim maps a TelysStore result onto that shape.
Wrap it for LlamaIndex
LlamaIndex expects a retriever whose _retrieve returns NodeWithScore objects. Same TelysStore underneath — only the result mapping changes.
What you will see
Driving the LangChain shim returns ranked Document objects whose page_content is the stored text and whose metadata carries the Telys score and stored fields:
Because the adapter wraps add_texts / search_text, everything else in these docs — partitions, Eq filters, IVF, persistence — is available through the same TelysStore.
Next steps
Last updated
Was this helpful?