语义记忆检索服务

AIF-BIN Recall 是一个本地优先的AI代理记忆服务器,提供语义搜索、混合检索和MCP集成功能,适用于AI代理的记忆管理和检索。

  • by Terronex-dev
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 Terronex-dev/aifbin-recall

使用说明

AIF-BIN召回

AI代理的本地第一内存服务器。

AIF-BIN召回索引集合 AIF-BIN 语义记忆文件,并通过HTTP API和MCP(模型上下文协议)为AI代理集成提供快速检索。

特性

  • 语义搜索 --使用嵌入向量按意义查询内存
  • 混合检索 --将向量相似性与关键字匹配相结合
  • MCP服务器 --与人工智能代理(Claude、OpenClaw等)的原生集成
  • HTTP API --任何客户端的RESTful端点
  • 零云 --完全本地化,无需外部服务
  • 收集管理 --将记忆组织成逻辑组

需求

  • Node.js 18+或Bun 1.0+
  • npm、yarn或pnpm

安装

使用首选的Node.js包管理器全局安装CLI:

# Using npm (recommended)
npm install -g aifbin-recall

# Using yarn
yarn global add aifbin-recall

# Using pnpm
pnpm add -g aifbin-recall

# Using Bun (Linux / macOS)
bun install -g aifbin-recall

来源

git clone https://github.com/Terronex-dev/aifbin-recall.git
cd aifbin-recall
npm install
npm run build
npm link

验证安装

aifbin-recall --version
# Output: 0.1.0

快速开始

# Index a directory of .aif-bin files
aifbin-recall index ./memories --collection my-project

# Start the server
aifbin-recall serve

# Search via CLI
aifbin-recall search "what decisions did we make about the API?"

# Or query the HTTP API
curl "http://localhost:3847/search?q=API+decisions&collection=my-project"

CLI参考

命令 描述
aifbin-recall index <dir> 从目录中索引.aif bin文件
aifbin-recall serve 启动HTTP服务器
aifbin-recall mcp 启动AI代理的MCP服务器
aifbin-recall search <query> 通过CLI搜索记忆
aifbin-recall collections 列出所有收藏
aifbin-recall info 显示数据库信息

索引选项

aifbin-recall index ./memories \
  --collection my-project \
  --recursive \
  --db ~/.aifbin-recall/custom.db

服务选项

aifbin-recall serve \
  --port 3847 \
  --host 0.0.0.0

搜索选项

aifbin-recall search "your query" \
  --collection my-project \
  --limit 10 \
  --model minilm

MCP集成

将AIF-BIN Recall添加到AI代理的MCP配置中:

{
  "mcpServers": {
    "aifbin-recall": {
      "command": "aifbin-recall",
      "args": ["mcp"]
    }
  }
}

可用的MCP工具:

工具 说明
recall_search 跨集合的语义搜索
recall_get 按ID检索特定记忆
recall_collections 列出可用收藏
recall_index 向集合中添加新文件

HTTP API

端点 方法 描述
/search GET/POST 带可选过滤器的语义搜索
/recall/:id GET 检索特定内存块
/collections GET 列出所有集合
/collections/:name POST 创建/更新集合
/index POST .aif bin文件的索引目录
/health GET 服务器健康检查

搜索请求

# GET request
curl "http://localhost:3847/search?q=your+query&collection=my-project&limit=10"

# POST request with options
curl -X POST http://localhost:3847/search \
  -H "Content-Type: application/json" \
  -d '{"query": "your query", "collection": "my-project", "limit": 10}'

搜索响应

{
  "results": [
    {
      "id": "chunk-uuid",
      "text": "The matched text content...",
      "score": 0.89,
      "vectorScore": 0.92,
      "keywordScore": 0.85,
      "sourceFile": "/path/to/file.aif-bin",
      "chunkIndex": 0,
      "metadata": {}
    }
  ]
}

配置

配置文件位置: ~/.aifbin-recall/config.yaml

server:
  port: 3847
  host: localhost

index:
  path: ~/.aifbin-recall/index.db
  
search:
  default_limit: 10
  hybrid_weight: 0.7  # 0 = keywords only, 1 = vectors only

embedding:
  model: minilm  # Options: minilm, mpnet, bge-small, bge-base, e5-small

嵌入模型

AIF-BIN Recall使用本地句子转换器模型进行查询嵌入:

型号 尺寸 速度 质量
minilm 384 最快 良好(默认)
mpnet 768 中等 较好
bge-small 384 快速 良好
bge-base 768 较慢 最好
e5-small 384 快速 良好

模型在首次使用时会自动下载并在本地缓存。

运作原理

  1. 索引:AIF-BIN召回阅读 .aif-bin 文件(由创建 AIF-BIN Pro)并将它们嵌入的向量和文本块提取到本地SQLite数据库中。

  2. 搜索:查询使用相同的模型嵌入,然后使用余弦相似度与索引向量进行匹配。可选的BM25关键字匹配提供混合检索。

  3. 检索:结果包括原始文本、元数据、源文件和相似性得分,可用于RAG管道或直接AI消费。

AIF-BIN生态系统的一部分

产品 描述
AIF-BIN 核心规范和SDK(Python、TypeScript、Rust、Go、C#、Java、Swift、Kotlin)
AIF-BIN精简版 用于基本.aif-bin文件操作的免费CLI
AIF-BIN Pro 具有AI提取和批处理功能的专业CLI
AIF-BIN召回 用于查询集合的内存服务器(您在这里)
机器人BIN AI聊天机器人的持久内存

贡献

欢迎投稿!请阅读我们的 贡献指南 在提交pull请求之前。

许可证

麻省 理工© 2026 Terronex

商标

“AIF-BIN”、“AIF-BIN-Recall”、“AIF-BIN-Pro”和Terronex名称是Terronex的商标。麻省理工学院的许可证不允许使用这些商标。有关详细信息,请参阅通知文件。