语义书籍知识系统

Wyrd是一个个人书籍知识系统,提供语义搜索、知识图谱和MCP集成功能,帮助用户组织和查询书籍内容。

  • by TomatoOmelette
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 TomatoOmelette/wyrd

使用说明

威尔德

具有语义搜索、知识图和MCP集成的个人书籍知识系统。

知识之网,像命运本身一样相互联系。

特性

  • 语义搜索 -使用自然语言查询您的藏书
  • 知识图谱 -绘制跨来源的概念关系图
  • MCP服务器 -与Claude和其他LLM客户集成
  • 主题提取 -自动识别和组织主题
  • 人类治疗 -基于YAML的工作流,用于整理关键见解
  • 多个后端 -ChromaDB(默认),带有pgvector/Neo4j选项

需求

安装

使用紫外线(推荐)

git clone https://github.com/yourusername/wyrd.git
cd wyrd
uv sync
source .venv/bin/activate

使用pip

git clone https://github.com/yourusername/wyrd.git
cd wyrd
python -m venv .venv
source .venv/bin/activate
pip install -e .

使用Docker

docker build -t wyrd:latest .
docker-compose up

快速开始

# Add a book
wyrd add ~/Books/my-book.epub --subject "topic-name"

# Search your library
wyrd search "your question here"

# Start MCP server for Claude integration
wyrd serve --transport stdio

CLI命令

命令 描述
wyrd add <file> 将一本书添加到知识库
wyrd remove <slug> 删除一本书
wyrd list 列出所有书籍
wyrd search <query> 搜索知识库
wyrd chapters <slug> 列出书中的章节
wyrd summarize <slug> <chapter> 使用LLM总结一章
wyrd serve 启动MCP服务器
wyrd build 构建/重建索引
wyrd subjects 列出所有主题
wyrd topics 列出/搜索主题
wyrd concepts 列出/搜索概念

添加选项

wyrd add book.epub \
  --slug custom-slug \
  --subject "parenting" \
  --title "Custom Title" \
  --author "Author Name" \
  --chunk-size 512 \
  --chunk-overlap 50 \
  --extract-topics \
  --yes  # Skip confirmation

搜索选项

wyrd search "emotion coaching" \
  --limit 10 \
  --source book-slug \
  --subject parenting

服务选项

wyrd serve \
  --transport stdio  # or http
  --host 0.0.0.0 \
  --port 8000

总结选项

wyrd summarize my-book 1 \
  --provider ollama \       # or openai, anthropic
  --model llama3.2          # Provider-specific model

摘要用途 WYRD_SYNTHESIS_PROVIDER 默认情况下为env-var。如果未配置LLM,则返回到基于规则的提取。

管理命令

wyrd curate init <slug>       # Generate YAML templates
wyrd curate validate <path>   # Validate curation files
wyrd curate import <path>     # Import curated content

MCP工具

MCP服务器公开了四个工具:

工具 目的
search_knowledge 语义搜索,可选合成
explore_library 浏览主题和书籍
get_advice 获取某个主题的综合建议
compare_sources 比较来源如何处理主题

Claude桌面配置

添加到您的Claude Desktop配置中:

{
  "mcpServers": {
    "wyrd": {
      "command": "wyrd",
      "args": ["serve", "--transport", "stdio"]
    }
  }
}

配置

环境变量:

变量 默认值 描述
WYRD_EMBEDDING_MODEL all-MiniLM-L6-v2 句子转换模型
WYRD_EMBEDDING_PROVIDER local local, openai,或 voyage
WYRD_STORAGE_PATH ./storage 持久存储目录
WYRD_KNOWLEDGE_PATH ./knowledge 用户内容目录
WYRD_SYNTHESIS_PROVIDER none none, ollama, openai, anthropic

项目结构

wyrd/
├── src/wyrd/
│   ├── cli.py              # Command-line interface
│   ├── mcp_server/         # MCP server implementation
│   └── core/
│       ├── ingestion/      # Book parsing & chunking
│       ├── indexing/       # Storage backends
│       ├── retrieval/      # Search functionality
│       ├── synthesis/      # Response synthesis
│       └── topics/         # Topic management
├── knowledge/              # User content (books, topics, concepts)
├── storage/                # Generated indexes (gitignored)
└── tests/                  # Test suite

测试

pytest tests/
pytest tests/test_cli.py -v

许可证

麻省理工学院