llm-hippocampus


Namellm-hippocampus JSON
Version 0.0.3 PyPI version JSON
download
home_pageNone
SummaryLLM Hippocampus — a Context Engineering playground
upload_time2025-09-15 10:34:55
maintainerNone
docs_urlNone
authorjoelz
requires_python>=3.11
licenseNone
keywords python redis langchain openai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
<h1>🚀 LLM Hippocampus</h1>

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![Language](https://img.shields.io/github/languages/top/redis-developer/redis-rag-workbench)
![GitHub last commit](https://img.shields.io/github/last-commit/redis-developer/redis-rag-workbench)
![Python](https://img.shields.io/badge/python-3.11%2B-blue)

🎯 Build up and manage the LLM 's memory

</div>

🔥 **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](#quick-start)
- [Prerequisites](#prerequisites)
- [Getting Started](#getting-started)
  - [Available Commands](#available-commands)
  - [Development Workflows](#development-workflows)
  - [Environment Configuration](#environment-configuration)
- [Using Google VertexAI](#using-google-vertexai)
- [Project Structure](#project-structure)
- [Connecting to Redis Cloud](#connecting-to-redis-cloud)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)
- [Learn More](#learn-more)


## Quick Start

**Get up and install in your project:**

```bash
pip install llm-hippocampus
or
uv add llm-hippocampus
```

Welcome to LLM Hippocampus! 🎉

---

## Prerequisites

1. Make sure you have the following tools available:
   - [python](https://www.docker.com/products/docker-desktop/) 3.11+
   - [uv](https://docs.astral.sh/uv/)
   - [Redis Stack](https://redis.io/)
2. Setup one or more of the following:
   - [OpenAI API](https://platform.openai.com/)
     - You will need an API Key

## Getting Started
```python
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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llm-hippocampus",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "python, redis, langchain, openai",
    "author": "joelz",
    "author_email": "joelz <zhongbj_2621@163.com>",
    "download_url": "https://files.pythonhosted.org/packages/67/b4/c4e4d065e613fdb1a958dcdd785e3ac3b9ade212bc3363196fc94a93d534/llm_hippocampus-0.0.3.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\r\n<h1>\ud83d\ude80 LLM Hippocampus</h1>\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n![Language](https://img.shields.io/github/languages/top/redis-developer/redis-rag-workbench)\r\n![GitHub last commit](https://img.shields.io/github/last-commit/redis-developer/redis-rag-workbench)\r\n![Python](https://img.shields.io/badge/python-3.11%2B-blue)\r\n\r\n\ud83c\udfaf Build up and manage the LLM 's memory\r\n\r\n</div>\r\n\r\n\ud83d\udd25 **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 **.\r\n\r\n\u2728 **What makes this special?**\r\n- \ud83d\ude80 **One-command setup** - pip install llm-hippocampus\r\n- \u26a1  **LLM support** - OpenAI\r\n- \ud83c\udfaf **Redis-powered** - Vector search, caching, and memory management\r\n- \ud83d\udc33 **Docker ready** - Building... \r\n- \ud83d\udd27 **Developer-first** - Support to Hot load by installing llm-hippocampus\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Quick Start](#quick-start)\r\n- [Prerequisites](#prerequisites)\r\n- [Getting Started](#getting-started)\r\n  - [Available Commands](#available-commands)\r\n  - [Development Workflows](#development-workflows)\r\n  - [Environment Configuration](#environment-configuration)\r\n- [Using Google VertexAI](#using-google-vertexai)\r\n- [Project Structure](#project-structure)\r\n- [Connecting to Redis Cloud](#connecting-to-redis-cloud)\r\n- [Troubleshooting](#troubleshooting)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n- [Learn More](#learn-more)\r\n\r\n\r\n## Quick Start\r\n\r\n**Get up and install in your project:**\r\n\r\n```bash\r\npip install llm-hippocampus\r\nor\r\nuv add llm-hippocampus\r\n```\r\n\r\nWelcome to LLM Hippocampus! \ud83c\udf89\r\n\r\n---\r\n\r\n## Prerequisites\r\n\r\n1. Make sure you have the following tools available:\r\n   - [python](https://www.docker.com/products/docker-desktop/) 3.11+\r\n   - [uv](https://docs.astral.sh/uv/)\r\n   - [Redis Stack](https://redis.io/)\r\n2. Setup one or more of the following:\r\n   - [OpenAI API](https://platform.openai.com/)\r\n     - You will need an API Key\r\n\r\n## Getting Started\r\n```python\r\nfrom dotenv import load_dotenv\r\nfrom llm_hippocampus import env\r\nfrom llm_hippocampus.core.utils import list2np_array\r\nfrom llm_hippocampus.core.redis import create_search_index, client, load_data2search_index, vector_query\r\nfrom llm_hippocampus.session import Session\r\nload_dotenv()\r\n# Load the model\r\nsession = Session()\r\nembeddings = session.get_embedding_model()\r\nschema = {\r\n    \"index\": {\r\n        \"name\": \"data_agent_chain\",\r\n        \"prefix\": \"data_agent_chain\",\r\n    },\r\n    \"fields\": [\r\n        {\"name\": \"query\", \"type\": \"text\"},\r\n        {\"name\": \"scope\", \"type\": \"text\"},\r\n        {\"name\": \"intent\", \"type\": \"text\"},\r\n        {\r\n            \"name\": \"query_embedding\",\r\n            \"type\": \"vector\",\r\n            \"attrs\": {\r\n                \"dims\": 768,\r\n                \"distance_metric\": \"cosine\",\r\n                \"algorithm\": \"flat\",\r\n                \"datatype\": \"float32\"\r\n            }\r\n        }\r\n    ]\r\n}\r\n\r\ndata = [\r\n    {\r\n        'query': 'SAAJ91\u7684\u7ba1\u7406\u8d39\u7387\u548c\u6258\u7ba1\u8d39\u7387\u662f\u591a\u5c11\uff1f',\r\n        'scope': \"\u4ea7\u54c1\u57fa\u672c\u4fe1\u606f\",\r\n        'intent': '\u7ba1\u7406\u8d39\u7387\u3001\u6258\u7ba1\u8d39\u7387',\r\n        'query_embedding': list2np_array(embeddings.encode(\r\n            \"SAAJ91\u7684\u7ba1\u7406\u8d39\u7387\u548c\u6258\u7ba1\u8d39\u7387\u662f\u591a\u5c11\uff1f\",\r\n            precision=schema[\"fields\"][3][\"attrs\"][\"datatype\"],\r\n            truncate_dim=schema[\"fields\"][3][\"attrs\"][\"dims\"])).tobytes()\r\n    },\r\n    {\r\n        'query': 'SATP77\u5728\u4e8e2025\u5e7406\u670801\u65e5\u81f32025\u5e7406\u670830\u65e5\u7684\u80a1\u7968\u6301\u4ed3\u660e\u7ec6',\r\n        'scope': \"\u80a1\u7968\u6301\u4ed3\u4fe1\u606f\",\r\n        'intent': '\u80a1\u7968\u6301\u4ed3\u4fe1\u606f',\r\n        'query_embedding': list2np_array(embeddings.encode(\r\n            \"SATP77\u5728\u4e8e2025\u5e7406\u670801\u65e5\u81f32025\u5e7406\u670830\u65e5\u7684\u80a1\u7968\u6301\u4ed3\u660e\u7ec6\",\r\n            precision=schema[\"fields\"][3][\"attrs\"][\"datatype\"],\r\n            truncate_dim=schema[\"fields\"][3][\"attrs\"][\"dims\"])).tobytes()\r\n    },\r\n    {\r\n        'query': '\u622a\u81f3\u4e8e2025\u5e7401\u670801\u65e5\u81f32025\u5e7412\u670831\u65e5\uff0c001120\u7684\u6237\u5747\u5b9a\u6295\u91d1\u989d\uff1f',\r\n        'scope': \"\u5ba2\u6237\u5b9a\u6295\u60c5\u51b5\",\r\n        'intent': '\u5ba2\u6237\u5b9a\u6295\u60c5\u51b5',\r\n        'query_embedding': list2np_array(embeddings.encode(\r\n            \"\u622a\u81f3\u4e8e2025\u5e7401\u670801\u65e5\u81f32025\u5e7412\u670831\u65e5\uff0c001120\u7684\u6237\u5747\u5b9a\u6295\u91d1\u989d\",\r\n            precision=schema[\"fields\"][3][\"attrs\"][\"datatype\"],\r\n            truncate_dim=schema[\"fields\"][3][\"attrs\"][\"dims\"])).tobytes()\r\n    }\r\n]\r\n\r\nredis_client = client(env.REDIS_URL)\r\nindex = create_search_index(redis_client, schema)\r\nkeys = load_data2search_index(index, data)\r\n\r\nquery = \"400001\u7684\u7ba1\u7406\u8d39\u7387\"\r\nargs = {\r\n    \"distance_threshold\": session.distance_threshold,\r\n    \"top_k\": session.top_k,\r\n    \"vector_field_name\": \"query_embedding\",\r\n    \"precision\": schema[\"fields\"][3][\"attrs\"][\"datatype\"],\r\n    \"truncate_dim\": schema[\"fields\"][3][\"attrs\"][\"dims\"],\r\n    \"return_fileds\": [\"query\", \"scope\", \"intent\"],\r\n}\r\n\r\nresults = vector_query(query, index, embeddings, schema, **args)\r\n```\r\n\r\n### Development Workflows\r\n- Building\r\n\r\n\r\n## Project Structure\r\n\r\n\r\n## Contributing\r\n\r\n\ud83e\udd1d Contributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the LICENSE file for details.\r\n\r\n## Troubleshooting\r\n\r\n## Learn More\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "LLM Hippocampus \u2014 a Context Engineering playground",
    "version": "0.0.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/redis-developer/redis-rag-workbench/issues",
        "Repository": "https://github.com/redis-developer/redis-rag-workbench.git"
    },
    "split_keywords": [
        "python",
        " redis",
        " langchain",
        " openai"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dd56f4dc6cdee9d55f3366e3eaa0b356a479e4fe1e5382bb3afbf2c1567342f4",
                "md5": "3f93f18255d3649f129d33973c7d231d",
                "sha256": "4ec4c449e187f01353cc1b6d8668184886da2c9dbe86b2ec07f4d53df09cbf80"
            },
            "downloads": -1,
            "filename": "llm_hippocampus-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f93f18255d3649f129d33973c7d231d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 17014,
            "upload_time": "2025-09-15T10:34:52",
            "upload_time_iso_8601": "2025-09-15T10:34:52.793631Z",
            "url": "https://files.pythonhosted.org/packages/dd/56/f4dc6cdee9d55f3366e3eaa0b356a479e4fe1e5382bb3afbf2c1567342f4/llm_hippocampus-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "67b4c4e4d065e613fdb1a958dcdd785e3ac3b9ade212bc3363196fc94a93d534",
                "md5": "c927e903025251cec1a4f200688b4f5a",
                "sha256": "bf2445a7275e64813507b3a49b5a37a11479940b900fb52ce7f58f57088901db"
            },
            "downloads": -1,
            "filename": "llm_hippocampus-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c927e903025251cec1a4f200688b4f5a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 17543,
            "upload_time": "2025-09-15T10:34:55",
            "upload_time_iso_8601": "2025-09-15T10:34:55.187096Z",
            "url": "https://files.pythonhosted.org/packages/67/b4/c4e4d065e613fdb1a958dcdd785e3ac3b9ade212bc3363196fc94a93d534/llm_hippocampus-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-15 10:34:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "redis-developer",
    "github_project": "redis-rag-workbench",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "llm-hippocampus"
}
        
Elapsed time: 1.31917s