Skip to main content

LangChain integration for HippoDid — persistent character memory for AI agents

Project description

langchain-hippodid

Persistent character memory for LangChain agents — powered by HippoDid.

Add cloud-persistent, character-scoped memory to any LangChain chain in a few lines.

Install

pip install langchain-hippodid

Quick Start

from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_hippodid import HippoDidMemory

memory = HippoDidMemory(api_key="hd_...", character_id="your-character-uuid")

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant."),
    MessagesPlaceholder(variable_name="history"),
    ("human", "{input}"),
])

chain_with_memory = RunnableWithMessageHistory(
    prompt | ChatAnthropic(model="claude-sonnet-4-20250514"),
    memory.get_history,
    input_messages_key="input",
    history_messages_key="history",
)

chain_with_memory.invoke(
    {"input": "My name is Yang, I'm building SameThoughts"},
    config={"configurable": {"session_id": "default"}},
)
# Memory persists to HippoDid cloud — survives restarts, redeploys, everything.

Why HippoDid?

Feature Default LangChain HippoDidMemory
Persistence In-process only Cloud-persistent across sessions
Scope Global Character-scoped (one per user)
Retrieval Flat chat log Semantic search across structured categories
Context assembly Append all messages Profile + category summaries + relevant facts
LLM provider N/A Works with any provider (BYOK)

External ID Pattern — One Character Per User

Auto-create and resolve characters by your system's user ID:

from langchain_hippodid import HippoDidMemory

def get_memory(user_id: str) -> HippoDidMemory:
    return HippoDidMemory(
        api_key="hd_...",
        external_id=user_id,  # Auto-creates character if first time
    )

memory = get_memory("user_yang_001")

Memory Modes

Mode Behavior Best For
VERBATIM Stores exact message text, zero AI cost Chat history replay
EXTRACTED AI extracts structured facts via AUDN pipeline Long-term user knowledge
HYBRID Both verbatim archive and extracted facts Full fidelity + structured recall
memory = HippoDidMemory(
    api_key="hd_...",
    character_id="...",
    memory_mode="EXTRACTED",
)

Advanced: Custom Search & Context Assembly

Use HippoDidChatMessageHistory directly for fine-grained control:

from langchain_hippodid import HippoDidChatMessageHistory

history = HippoDidChatMessageHistory(
    api_key="hd_...",
    character_id="your-character-uuid",
)

# Semantic search across memories
results = history.search("travel preferences", top_k=5)

# Assemble full context (profile + memories) for a system prompt
context = history.get_context("current user preferences")

Links

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

langchain_hippodid-0.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

langchain_hippodid-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_hippodid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 589705d46eea4b62ec7e4d45b6177eac89379c389b99ad5a382d5ae6432fcae7
MD5 25594aae2f27cd99f9e30e9d9f001744
BLAKE2b-256 813f9b91f944aed632f5212ca545fc6aac80642bddfc2d0bdea4b5e25e3a78f4

See more details on using hashes here.

Provenance

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

Publisher: ci.yml on SameThoughts/langchain-hippodid

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

File details

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

File metadata

File hashes

Hashes for langchain_hippodid-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71785230cde0ff3c7b7790064a4b4abc88bda16b47870d1c8a1ceaa17108c94e
MD5 cbf52a9223fafbe6b0d30ffbb2d22354
BLAKE2b-256 2978dd04ab6bbb02b26858254be664532c3777290969b96cefcbd2565a29a83a

See more details on using hashes here.

Provenance

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

Publisher: ci.yml on SameThoughts/langchain-hippodid

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