Skip to main content

Compact Qdrant-backed memory for host-owned LLM applications.

Project description

memory-os

Compact Qdrant-backed memory for AI applications.

MemoryOS does not generate final answers. Your application owns the chat flow and the user-facing LLM call. MemoryOS extracts multiple important memory chunks from the user's prompt, stores those chunks separately in Qdrant, applies forgetting-curve style decay to them over time, and also keeps a small rolling prompt/response history per session.

Public API

pip install pymemoryos
from memory_os import MemoryOS

memory = MemoryOS(
    qdrant_url="https://your-qdrant-url",
    qdrant_api_key="your-qdrant-api-key",
    llm=configured_llm,                    # any object with .invoke()
    embedding_model=configured_embed_model, # any object with .embed()
    session_id="user_123",
)

memory.store(prompt: str, response: str) -> None
memory.retrieve(prompt: str) -> dict

That is the entire intended surface.

Usage

context = memory.retrieve(user_prompt)

final_response = host_llm.invoke(
    f"Relevant memory:\n{context}\n\nUser:\n{user_prompt}"
)

memory.store(user_prompt, final_response)

Behavior

  • store(prompt, response) calls llm.invoke(...) once to distill the completed prompt into multiple important memory chunks.
  • store(prompt, response) calls embedding_model.embed(...) on each extracted memory chunk, then upserts those chunks separately to Qdrant.
  • store(prompt, response) also stores the raw prompt/response pair in a simple rolling session history capped at 7 pairs.
  • retrieve(prompt) calls embedding_model.embed(...) to vectorize the current prompt, then queries Qdrant for relevant memories.
  • retrieve(prompt) reranks Qdrant hits using an Ebbinghaus-style decay score: similarity * decay_score * importance * emotional_weight.
  • retrieve(prompt) also returns the latest 4-5 stored prompt/response pairs for the same session as immediate context.
  • All Qdrant reads and writes are filtered by session_id.
  • When an old pair is evicted from the 7-pair history, the Qdrant memory chunks created from that prompt are also removed.
  • Each stored memory chunk keeps decay state in Qdrant payload, including last_accessed, access_count, stability, importance, emotion, emotional_weight, decay_score, final_score, and last_similarity.

Retrieve shape

{
    "recent_pairs": [
        {"prompt": "...", "response": "...", "created_at": 1720000000.0},
    ],
    "memories": [
        {
            "text": "...",
            "score": 0.92,
            "created_at": 1720000000.0,
            "decay_score": 0.81,
            "importance": 0.9,
            "emotion": "fear",
        },
    ],
}

Boundaries

  • MemoryOS never generates the final answer to a user query.
  • MemoryOS uses llm.invoke() only to break the user's prompt into storable memory chunks.
  • MemoryOS uses embedding_model.embed() only for vector storage and retrieval.
  • Required init config is exactly qdrant_url, qdrant_api_key, llm, embedding_model, and session_id.

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

pymemoryos-0.1.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

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

pymemoryos-0.1.0-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymemoryos-0.1.0.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymemoryos-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a22de05600986a885aea0b7a2ab999881dd19761ca852002cb2bcbed825212a
MD5 02d1a56f6d467f15856930fb144a83e7
BLAKE2b-256 9af1650be69e5d56a77201e4c12985d67538075b10e4789e280395ac79376d08

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymemoryos-0.1.0.tar.gz:

Publisher: publish.yml on karann810/MemoryOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pymemoryos-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 39.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymemoryos-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78cfd6aa81d0b92ac43252fcc5cd83b7af639a5c2c7428e31c41ad6e274fbe79
MD5 a6c84b3b02089c5ab5fde70fba066b9d
BLAKE2b-256 0ba2f86f53974a010e6ba58d9fc42cf8537137031463726fa6349f9d0d2d7ec8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymemoryos-0.1.0-py3-none-any.whl:

Publisher: publish.yml on karann810/MemoryOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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