Catalog PyPI
PACKAGE EXPLORERView in registry

agentmemorymanager

PyPI

面向 LangChain / LangGraph 开发者的 AI Agent 三层记忆管理微服务

ai-agentfastapilangchainlanggraphllmmemory-managementpgvector
Versions collected1
Direct dependencies8From release 0.1.0
Last observed20 Oct, 22:41 UTC

README

Version 0.1.0 documentation

Agent Memory Manager

Python PostgreSQL Docker FastAPI License

面向 LangChain / LangGraph 开发者的 AI Agent 三层记忆管理微服务。将记忆管理从业务逻辑中解耦,提供自动化的长短期记忆注入接口。


特性

  • 三层记忆模型 — 会话记忆(对话上下文)+ 用户记忆(跨会话画像)+ Agent 记忆(Skill/人设)
  • Docker 一键部署 — docker compose up -d,零环境配置
  • 可选 LLM 增强 — 兼容 OpenAI API 格式,自动摘要/记忆提取/向量嵌入,未配置时自动降级
  • Python SDK — 3 行初始化,2 行注入上下文,1 行传给 LLM
  • pgvector 语义检索 — 余弦相似度 + 全文检索双模式
  • 调试控制台 — 单页 HTML,上下文预览 / 记忆检索 / LLM 日志

快速开始

# 1. 启动服务
git clone https://github.com/NullWinters/AgentMemoryManager.git
cd AgentMemoryManager
docker compose up -d

# 宿主机默认映射 8080→容器 8000(避免与本机 8000 冲突,可在 .env 设置 API_PORT)
curl http://localhost:8080/api/v1/health
# → {"status":"ok","pgvector":true}

# 2. 安装 SDK
pip install agentmemory-client
from agentmemory import MemoryClient

client = MemoryClient("http://localhost:8080", api_key="dev-secret")

# 一次性 Setup:注册 Agent + 绑定 Skill
client.setup(agent_id="book_bot", persona="你是书籍推荐助手...")
client.add_skill_to_agent("book_bot", skill_id)

# 开始会话
session = client.session_start(agent_id="book_bot", user_id="zhang")

# 对话循环
session.add_message(role="user", content="推荐一本进阶 Python 书")
ctx = session.inject_context(query="推荐一本进阶 Python 书")

# 三层记忆自动注入 → 直接发给 LLM
response = openai.chat.completions.create(
    model="gpt-4", messages=ctx.to_messages()
)
session.add_message(role="assistant", content=response.choices[0].message.content)

API 概览

端点说明
POST /api/v1/context核心:三层记忆注入
POST/GET /api/v1/sessions会话管理
POST/GET /api/v1/sessions/{id}/messages消息追加与查询
GET/PATCH /api/v1/users/{id}/profile用户画像
POST/GET/DELETE /api/v1/users/{id}/memories记忆片段管理
POST/GET/PATCH /api/v1/agentsAgent 注册与配置
POST/GET/PATCH/DELETE /api/v1/skillsSkill 管理
GET /api/v1/health健康检查

完整文档见 设计.md。


调试控制台

浏览器打开 http://localhost:8080/debug,提供:

  • Agent Info — 人设/配置编辑、Skill 开关
  • User Memory — 画像查看、向量检索/全文检索
  • Session — 对话历史浏览、模拟消息注入
  • Context Preview — 模拟 to_messages() 输出、Token 估算
  • LLM Logs — 每次 LLM 调用的 prompt/response 详情

项目结构

├── src/              # FastAPI 微服务源码
│   ├── routers/      # API 路由 (agents/skills/users/sessions/context)
│   ├── services/     # 业务逻辑层
│   ├── models/       # SQLAlchemy ORM 模型
│   ├── llm/          # LLM 模块 (provider/extractor/summarizer/embedder)
│   └── static/       # 调试前端 (debug.html)
├── sdk/              # Python SDK 包
│   └── agentmemory/  # MemoryClient / Session / Context
├── docker/           # init.sql (DDL + 高阶 SQL)
├── docker-compose.yml
├── docs/
│   ├── 设计.md        # 完整设计文档
│   ├── 用户手册.md     # 用户手册
│   └── superpowers/plans/  # 施工计划

技术栈

Python 3.11+ · FastAPI · PostgreSQL 16 · pgvector · SQLAlchemy 2.0 · Docker · OpenAI API


文档

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.05 Aug 20268

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
nullwinters/agentmemorymanager

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:41 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:bc5ed76bd78d8bcc0c50811e6534b3b1ffe9005a4af1dbb2d0da066b538bc650