Skip to main content

🚀 LLM Hippocampus

License: MIT Language GitHub last commit Python

🎯 Build up and manage the LLM 's memory

🔥 LLM Hippocampus helping your project for building and experimenting with Context Engineering applications. harness the full power of Redis for lightning-fast vector search, intelligent semantic caching, persistent LLM memory, and **smart context engineering **.

✨ What makes this special?

  • 🚀 One-command setup - pip install llm-hippocampus
  • ⚡ LLM support - OpenAI
  • 🎯 Redis-powered - Vector search, caching, and memory management
  • 🐳 Docker ready - Building...
  • 🔧 Developer-first - Support to Hot load by installing llm-hippocampus

Table of Contents

Quick Start

Get up and install in your project:

pip install llm-hippocampus
or
uv add llm-hippocampus

Welcome to LLM Hippocampus! 🎉


Prerequisites

  1. Make sure you have the following tools available:
  2. Setup one or more of the following:

Getting Started

from dotenv import load_dotenv
from llm_hippocampus import env
from llm_hippocampus.core.utils import list2np_array
from llm_hippocampus.core.redis import create_search_index, client, load_data2search_index, vector_query
from llm_hippocampus.session import Session
load_dotenv()
# Load the model
session = Session()
embeddings = session.get_embedding_model()
schema = {
    "index": {
        "name": "data_agent_chain",
        "prefix": "data_agent_chain",
    },
    "fields": [
        {"name": "query", "type": "text"},
        {"name": "scope", "type": "text"},
        {"name": "intent", "type": "text"},
        {
            "name": "query_embedding",
            "type": "vector",
            "attrs": {
                "dims": 768,
                "distance_metric": "cosine",
                "algorithm": "flat",
                "datatype": "float32"
            }
        }
    ]
}

data = [
    {
        'query': 'SAAJ91的管理费率和托管费率是多少?',
        'scope': "产品基本信息",
        'intent': '管理费率、托管费率',
        'query_embedding': list2np_array(embeddings.encode(
            "SAAJ91的管理费率和托管费率是多少?",
            precision=schema["fields"][3]["attrs"]["datatype"],
            truncate_dim=schema["fields"][3]["attrs"]["dims"])).tobytes()
    },
    {
        'query': 'SATP77在于2025年06月01日至2025年06月30日的股票持仓明细',
        'scope': "股票持仓信息",
        'intent': '股票持仓信息',
        'query_embedding': list2np_array(embeddings.encode(
            "SATP77在于2025年06月01日至2025年06月30日的股票持仓明细",
            precision=schema["fields"][3]["attrs"]["datatype"],
            truncate_dim=schema["fields"][3]["attrs"]["dims"])).tobytes()
    },
    {
        'query': '截至于2025年01月01日至2025年12月31日,001120的户均定投金额?',
        'scope': "客户定投情况",
        'intent': '客户定投情况',
        'query_embedding': list2np_array(embeddings.encode(
            "截至于2025年01月01日至2025年12月31日,001120的户均定投金额",
            precision=schema["fields"][3]["attrs"]["datatype"],
            truncate_dim=schema["fields"][3]["attrs"]["dims"])).tobytes()
    }
]

redis_client = client(env.REDIS_URL)
index = create_search_index(redis_client, schema)
keys = load_data2search_index(index, data)

query = "400001的管理费率"
args = {
    "distance_threshold": session.distance_threshold,
    "top_k": session.top_k,
    "vector_field_name": "query_embedding",
    "precision": schema["fields"][3]["attrs"]["datatype"],
    "truncate_dim": schema["fields"][3]["attrs"]["dims"],
    "return_fileds": ["query", "scope", "intent"],
}

results = vector_query(query, index, embeddings, schema, **args)

Development Workflows

  • Building

Project Structure

Contributing

🤝 Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Learn More

Metadata

Release files for llm-hippocampus 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-hippocampus 0.0.6
File Size Uploaded Provenance Actions
llm_hippocampus-0.0.6.tar.gz 17.8 kB Without provenance Details for llm_hippocampus-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-hippocampus 0.0.6
File Interpreter ABI Platform Actions
llm_hippocampus-0.0.6-py3-none-any.whl Python 3 none any Details for llm_hippocampus-0.0.6-py3-none-any.whl

Total release size: 35.1 kB

Release files / llm_hippocampus-0.0.6.tar.gz

Download URL llm_hippocampus-0.0.6.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a4ef36a6289fefac2083f9b6000c3e287cafd35d2b3b01c097aaafdc89f66ee8
BLAKE2b-256 checksum
How to use checksums
5d71802ba6a0103081266f46bd599a20c646c7b072eec71e2f3a670f04decba9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / llm_hippocampus-0.0.6-py3-none-any.whl

Download URL llm_hippocampus-0.0.6-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc96830760abff65e970ee13c3f4dea99145383266be3b319e88f9dd920a5009
BLAKE2b-256 checksum
How to use checksums
1b3f504c1bbf4bd7268496c9c0b5a496bf7f1004f3e1dddc54a806d33fcc91f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for llm-hippocampus 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page