Skip to main content

Local-first, privacy-first agent memory — Lite edition (Apache-2.0)

Project description

AIngram (Lite)

Local-first agent memory in one SQLite file: hybrid vector + FTS5 search, optional knowledge graph (entities and relationships), Ed25519-signed entries, and an optional MCP server. Apache-2.0. No cloud dependency; embeddings run via ONNX (Nomic) on your machine.

Install

pip install aingram

Optional extras:

Extra Purpose
aingram[extraction] GLiNER entity extraction (background linking)
aingram[llm] HTTP client for Ollama / local LLM (e.g. consolidation)
aingram[mcp] MCP server (FastMCP)
aingram[api] Anthropic API (Sonnet extractor)
aingram[all] mcp, extraction, llm, and cli-related deps

The aingram CLI is available once the package is installed (Typer is a core dependency).

CUDA / GPU (embeddings): The default package uses the CPU build of ONNX Runtime. Do not install onnxruntime and onnxruntime-gpu together. To use GPU: pip uninstall -y onnxruntime onnxruntime-gpu then pip install onnxruntime-gpu. See ONNX Runtime GPU install for CUDA/cuDNN expectations.

Quick start (Python)

from aingram import MemoryStore

with MemoryStore('./agent_memory.db') as mem:
    mem.remember('User prefers dark mode and concise answers')
    for r in mem.recall('What does the user prefer?', limit=5):
        print(r.score, r.entry.content)

CLI

aingram --db ./agent_memory.db status
aingram --db ./agent_memory.db add "User likes Python"
aingram --db ./agent_memory.db search "Python"
aingram --db ./agent_memory.db entities
aingram --db ./agent_memory.db graph "Alice"
aingram --db ./agent_memory.db consolidate
aingram --db ./agent_memory.db compact --yes --target-dim 256
aingram --db ./agent_memory.db export ./backup.json
aingram --db ./agent_memory.db import ./backup.json

compact is one-way (e.g. 768 → 256 embedding width). Use --yes to confirm.

Configuration

Precedence (highest first): constructor kwargs → environment variables → ~/.aingram/config.toml → defaults.

Env var Meaning
AINGRAM_MODELS_DIR Model cache directory
AINGRAM_EMBEDDING_DIM Width for new DBs (must match an existing DB after creation)
AINGRAM_LLM_URL Ollama base URL
AINGRAM_LLM_MODEL Default LLM name
AINGRAM_LOG_LEVEL aingram logger level
AINGRAM_WORKER_ENABLED true / false
AINGRAM_EXTRACTOR_MODE none, local, or sonnet
AINGRAM_EXTRACTOR_MODEL Extractor model id
AINGRAM_ONNX_PROVIDER cpu, cuda, npu, or omit for auto
AINGRAM_TELEMETRY_ENABLED true / false — anonymous CLI usage telemetry

Example ~/.aingram/config.toml:

embedding_dim = 768
worker_enabled = true
models_dir = "C:/Users/me/.aingram/models"
llm_url = "http://localhost:11434"
llm_model = "mistral"
extractor_mode = "none"
telemetry_enabled = true

Use AIngramConfig and load_merged_config() for the same rules in application code.

Privacy and anonymous telemetry

CLI only: the aingram command-line tool may send events. Using the Python API or MCP does not use this channel.

The CLI may send anonymous usage events by default: a random install id (~/.aingram/telemetry_id), the name of the top-level command you ran (e.g. add, status), and the package version. No memory text, queries, paths, or secrets are included. Events are sent over HTTPS to https://api.aingram.dev/v1/telemetry.

Opt out (any one):

  • Add --no-telemetry to a single invocation, e.g. aingram --no-telemetry --db ./agent_memory.db status.
  • Set telemetry_enabled = false in ~/.aingram/config.toml.
  • Set AINGRAM_TELEMETRY_ENABLED=false in the environment.

This is separate from any future opt-in “contribute training examples” feature, which would involve content you deliberately choose to share.

Consolidation and LLM

Pass an LLM instance into MemoryStore.consolidate(llm=...) when you want richer merge/synthesis behavior (optional). Install aingram[llm] and use your stack’s Ollama or other client as appropriate.

Export / import

MemoryStore.export_json(path) writes a Lite JSON backup (sessions, chains, entries, graph, vectors). import_json(path) targets an empty database by default, or merge=True to skip entries that already exist. Export and DB embedding_dim must match on import.

For programmatic verification of a session chain, use MemoryStore.verify().

MCP

With aingram[mcp] installed, see aingram.mcp_server.create_server for tools such as remember, recall, reference, verify, and get_experiment_context, with optional bearer-token middleware.

Examples

Runnable scripts using MemoryStore.remember / MemoryStore.recall live in examples/. See examples/README.md.

Development

pip install -e ".[dev,all]"
pytest
ruff check aingram/ && ruff format --check aingram/

Guidelines and pre-push hygiene (including secret scanning) are in CONTRIBUTING.md.

Python 3.11+.

Social

Join the official Aingram discord here: https://discord.gg/zSJCFZnXxf

License

Apache-2.0. See LICENSE and NOTICE.

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

aingram-1.0.0.tar.gz (135.1 kB view details)

Uploaded Source

Built Distribution

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

aingram-1.0.0-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file aingram-1.0.0.tar.gz.

File metadata

  • Download URL: aingram-1.0.0.tar.gz
  • Upload date:
  • Size: 135.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for aingram-1.0.0.tar.gz
Algorithm Hash digest
SHA256 806cdd7f36fc2eae1004b793ff250eb9cde917e3e8520e54d33865d253c587fe
MD5 2b67778ae35108a43916bf4ef84315e9
BLAKE2b-256 0e7a266887642fa8b35f427837d431e6d6429ff03b49882671effb5a713b955d

See more details on using hashes here.

File details

Details for the file aingram-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aingram-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for aingram-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a9bdd1f6de6eda983f65246db43bf9f4e78e271568ee5d18d8d1d5f4eccb5d9
MD5 deb1053b07b0b6596fcd1ed651f3bc28
BLAKE2b-256 4d6d1b4d06d3590dae761c343be8ff9fbc2633e907a06a2f43a35969515db1d1

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