CortexDB Docs
Integrations

Prefect

Capture and recall CortexDB memory from Prefect flows via a configuration Block.

CortexDB ships a Prefect Block so flows and tasks can capture and recall memory with managed credentials.

Install

pip install cortexdbai[prefect]

Block

from cortexdb.integrations.prefect import CortexDBBlock

# Register once (or via the Prefect UI)
block = CortexDBBlock(
    api_url="https://api-v1.cortexdb.ai",
    actor="service:etl",
    bearer=os.environ["CORTEX_TOKEN"],
    scope="org:acme/service:etl",
)
block.save("cortexdb-prod")
from prefect import flow
from cortexdb.integrations.prefect import CortexDBBlock

@flow
def ingest(records):
    block = CortexDBBlock.load("cortexdb-prod")
    client = block.get_client()
    for r in records:
        client.experience(scope=block.scope, text=r["text"], role="user",
                          observed_at=r["ts"], idempotency_key=r["id"])

See also

On this page