Skip to main content

AI memory that understands time — temporal-tree retrieval for LLM agents

Project description

Aivery Python SDK

AI memory that understands time — temporal-tree retrieval for LLM agents.

from aivery import Memory

m = Memory()
m.add("I love hiking on weekends", user_id="alice")
results = m.search("outdoor activities", user_id="alice")

Why Aivery?

Most memory systems store facts as a flat list. Aivery organizes memories into a temporal tree: related memories are parent/child, time flows from root to leaf, contradictions fork into branches. Retrieval walks the tree — you get a coherent branch of context, not a bag of facts.

Compared to mem0 on the LOCOMO benchmark (LLM judge score, higher = better):

System LLM Score
mem0 (platform) 0.5571
Aivery (tree + heatmap, K=50) 0.6773
Aivery (wide retrieval, K=200→50) 0.8000

Installation

pip install aivery

Requires an Aivery API key. Point AIVERY_BASE_URL at https://api.aivery.systems or a self-hosted instance.

Quickstart

from aivery import Memory

m = Memory()

# Add from a plain string
m.add("I'm training for a marathon in April", user_id="alice")

# Add from a conversation
m.add(
    [
        {"role": "user", "content": "I just moved to San Francisco."},
        {"role": "assistant", "content": "Welcome! How are you finding it?"},
    ],
    user_id="alice",
)

# Search
results = m.search("where does alice live?", user_id="alice")
# [{"memory": "Alice lives in San Francisco", "score": 0.94, "id": "..."}]

# Get a context block for LLM injection
ctx = m.context("what do I know about alice?", user_id="alice")
# "- Alice is training for a marathon in April\n- Alice lives in San Francisco"

Drop-in OpenAI agent

import os
from openai import OpenAI
from aivery import Memory

openai = OpenAI()
memory = Memory()

def chat(message: str, user_id: str) -> str:
    ctx = memory.context(message, user_id=user_id, top_k=10)

    system = "You are a helpful assistant."
    if ctx:
        system += f"\n\nWhat you remember about the user:\n{ctx}"

    response = openai.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {"role": "system", "content": system},
            {"role": "user", "content": message},
        ],
    )
    answer = response.choices[0].message.content

    memory.add(
        [{"role": "user", "content": message}, {"role": "assistant", "content": answer}],
        user_id=user_id,
    )
    return answer

Async

from aivery import AsyncMemory

async with AsyncMemory() as m:
    await m.add("I love jazz", user_id="alice")
    results = await m.search("music preferences", user_id="alice")

Configuration

Method Description
Memory() Reads AIVERY_BASE_URL, AIVERY_API_KEY, AIVERY_ORG_ID from environment
Memory(host="http://...") Explicit host
Memory(api_key="aiv_...") Explicit API key

Environment variables:

AIVERY_BASE_URL=https://api.aivery.systems   # default
AIVERY_API_KEY=aiv_...                       # required
AIVERY_ORG_ID=00000000-...                   # multi-tenant org scoping

Hosted API

Use the Aivery hosted API at https://api.aivery.systems — no setup required.

Reproducing the LOCOMO benchmark

The numbers in the table above were produced using the LOCOMO dataset and the evaluation harness from mem0. The benchmark/ directory in this repo contains the Aivery integration scripts — see benchmark/README.md for full instructions.

Cost breakdown: Ingestion and answer generation run through your Aivery plan (server-side LLM — no key needed on your end). The LLM judge step requires your own OpenAI key and costs ~$5 for the full 1,540-question set. A Pro tier or higher is recommended for ingestion throughput.

Self-hosting

Self-hosting docs and a one-command Docker setup are coming soon.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aivery-0.1.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aivery-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file aivery-0.1.0.tar.gz.

File metadata

  • Download URL: aivery-0.1.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for aivery-0.1.0.tar.gz
Algorithm Hash digest
SHA256 887de4d59e37eb277906a0de3add1072fc6cda7217637687b4fde9d306822c39
MD5 cdf13e022aefe9773fc9e1ec6001c17d
BLAKE2b-256 07acdfc4cc75bad3e70f98b31dfb7466e07f9e8e0ad5956da6fe3183b5dbc7e9

See more details on using hashes here.

File details

Details for the file aivery-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aivery-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for aivery-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5afe7a64f2bbd3e40cadb8ea5d2323e783c0869413d6507319db17edd22264b
MD5 b81dfa3b7803c6ef2ab0b2a801f9021b
BLAKE2b-256 efe8bf995a36d1e6fa0f0d788c0a6aeff58c12ca85ce2a848a95073866c073bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page