Python: Vectors and embeddings
Embed text, store vectors with metadata and run similarity search with the Python SDK.
await sovaria.vector_upsert("articles", [
{"id": "a1", "text": "How to reset your password", "metadata": {"lang": "en"}},
{"id": "a2", "text": "Exporting invoices as PDF", "metadata": {"lang": "en"}},
])
hits = await sovaria.vector_search("articles", "forgot my login", top_k=3, metadata_filter={"lang": "en"})Methods
sovaria.vector_delete_collection
Delete an entire vector collection.
await sovaria.vector_delete_collection(
collection: str,
) -> dict[str, Any]Parameters
collectionstrrequired
- Returns
dict[str, Any]
sovaria.vector_delete_record
Delete a record from a vector collection.
await sovaria.vector_delete_record(
collection: str,
record_id: str,
) -> dict[str, Any]Parameters
collectionstrrequiredrecord_idstrrequired
- Returns
dict[str, Any]
sovaria.vector_embed
Generate embeddings for one or more texts.
await sovaria.vector_embed(texts: list[str]) -> dict[str, Any]Parameters
textslist[str]required
- Returns
dict[str, Any]
sovaria.vector_list_collections
List vector collections in the current project scope.
await sovaria.vector_list_collections() -> dict[str, Any]- Returns
dict[str, Any]
sovaria.vector_list_records
List records stored in a vector collection.
await sovaria.vector_list_records(
collection: str,
*, limit: int | None = None,
offset: int | None = None,
) -> dict[str, Any]Parameters
collectionstrrequiredlimitint | NoneoptionaldefaultNoneoffsetint | NoneoptionaldefaultNone
- Returns
dict[str, Any]
sovaria.vector_search
Search a vector collection by semantic similarity.
await sovaria.vector_search(
collection: str,
query: str,
*, top_k: int = 5,
metadata_filter: dict[str, Any] | None = None,
) -> dict[str, Any]Parameters
collectionstrrequired- Collection name.
querystrrequired- Text to search for.
top_kintoptionaldefault5- How many results.
metadata_filterdict[str, Any] | NoneoptionaldefaultNone- Exact matches on metadata.
- Returns
dict[str, Any]
sovaria.vector_upsert
Embed and upsert documents into a vector collection.
await sovaria.vector_upsert(
collection: str,
docs: list[dict[str, Any]],
) -> dict[str, Any]Parameters
collectionstrrequireddocslist[dict[str, Any]]required
- Returns
dict[str, Any]
Something unclear or missing on this page?Tell us