Skip to content

raggy.vectorstores.tpuf

TurboPuffer

Wrapper for turbopuffer.Namespace as an async context manager.

Attributes:

Name Type Description
namespace str

The namespace to use for the TurboPuffer instance.

Examples:

Upsert documents to a namespace:

from raggy.documents import Document
from raggy.vectorstores.tpuf import TurboPuffer

async with TurboPuffer() as tpuf: # default namespace is "raggy"
    await tpuf.upsert(documents=[Document(id="1", text="Hello, world!")])

Query a namespace:

from raggy.vectorstores.tpuf import TurboPuffer

async with TurboPuffer() as tpuf:
    result = await tpuf.query(text="Hello, world!")
    print(result)

TurboPufferSettings

Settings for the TurboPuffer vectorstore.

multi_query_tpuf async

searches a Turbopuffer namespace for the given queries

query_namespace async

Query a TurboPuffer namespace.

Parameters:

Name Type Description Default
query_text str

The text to query for.

required
filters dict | None

Filters to apply to the query.

None
namespace str

The namespace to query.

'raggy'
top_k int

The number of results to return.

10

Examples:

Basic Usage of query_namespace

from raggy.vectorstores.tpuf import query_namespace

print(await query_namespace("How to create a flow in Prefect?"))

Using filters with query_namespace

from raggy.vectorstores.tpuf import query_namespace

filters={
    'id': [['In', [1, 2, 3]]],
    'key1': [['Eq', 'one']],
    'filename': [['Or', [['Glob', '**.md'], ['Glob', '**.py']]], ['NotGlob', '/migrations/**']]
}

print(await query_namespace("How to create a flow in Prefect?", filters=filters))