SuperAPI AI Directory

zhimeng-agent

Agents & models

View repository

Updated 10-16 01:31

About this skill

zhimeng's Agent operation skill

Overview

zhimeng's Agent is a RAG intelligent Q&A assistant based on the Obsidian knowledge base, powered by Claude Opus 4.5. It supports knowledge base Q&A, daily report synchronization, Feishu message push, and other features.

Service Information

Item Value
Service Address http://localhost:8001
Project Path /Users/qitmac001395/workspace/QAL/ideas/apps/zhimeng-agent
Knowledge Base Path /Users/qitmac001395/Documents/Obsidian Vault
Vector Database ChromaDB (data/chroma/)
LLM Model anthropic/claude-sonnet-4-20250514

Core Capabilities

Capability Endpoint Purpose Example Trigger Words
Knowledge Q&A POST /ask RAG Q&A based on the knowledge base "ask the knowledge base", "look up"
Health Check GET /health Check service status and document count "check Agent", "service status"
Rebuild Index POST /index Re-index Obsidian documents "rebuild index", "update knowledge base"
Feishu Webhook POST /webhook/feishu Receive Feishu message events -

API Detailed Description

1. Q&A Endpoint (POST /ask)

Request Body:

{
  "question": "用户问题",
  "top_k": 5,
  "include_sources": true,
  "filter_folder": null,
  "user_id": "用户唯一标识"
}

Response Body:

{
  "answer": "回答内容",
  "sources": [
    {"file": "文件名.md", "folder": "文件夹", "relevance": 0.85}
  ],
  "tokens_used": 1234
}

Parameter Description:

  • question (required): user question
  • top_k (optional, default 5): number of documents to retrieve (1-20)
  • include_sources (optional, default true): whether to return sources
  • filter_folder (optional): folder to limit the search to
  • user_id (optional): user identifier, used for conversation memory

2. Health Check (GET /health)

Response Body:

{
  "status": "healthy",
  "vectorstore_loaded": true,
  "document_count": 1316
}

3. Rebuild Index (POST /index)

Request Body:

{
  "paths": ["Journal", "Projects"],
  "force": false
}

Response Body:

{
  "status": "success",
  "chunks_indexed": 1500
}

Standard Operating Procedure (SOP)

SOP 1: Knowledge Base Q&A

步骤1: 检查服务状态
  curl http://localhost:8001/health

步骤2: 发送问题
  curl -X POST http://localhost:8001/ask \
    -H "Content-Type: application/json" \
    -d '{"question": "你的问题", "top_k": 5}'

步骤3: 解析响应中的 answer 和 sources

SOP 2: Daily Report Sync to Feishu

步骤1: 读取今日日报
  读取 ~/Documents/Obsidian Vault/Journal/YYYYMMDD.md

步骤2: 提取关键内容
  - 完成的工作
  - 代码变更统计
  - AI 消耗统计

步骤3: 格式化为飞书消息
  使用 feishu-messaging 技能发送

步骤4: 发送到目标用户
  调用 mcp__feishu__im_v1_message_create
  收件人: 王植萌 (open_id: ou_18b8063b232cbdec73ea1541dfb74890)

SOP 3: Rebuild Knowledge Base Index

步骤1: 停止正在进行的查询

步骤2: 调用索引接口
  curl -X POST http://localhost:8001/index \
    -H "Content-Type: application/json" \
    -d '{"force": true}'

步骤3: 验证索引结果
  curl http://localhost:8001/health
  确认 document_count 已更新

SOP 4: Start/Stop Service

Start Service:

cd /Users/qitmac001395/workspace/QAL/ideas/apps/zhimeng-agent
poetry run uvicorn src.main:app --host 0.0.0.0 --port 8001 --reload

Start Feishu long connection (local development, no public IP required):

cd /Users/qitmac001395/workspace/QAL/ideas/apps/zhimeng-agent
poetry run python src/feishu_ws.py

Start in Background:

# 主服务
nohup poetry run uvicorn src.main:app --host 0.0.0.0 --port 8001 > /tmp/zhimeng-agent.log 2>&1 &

# 飞书长连接
nohup poetry run python src/feishu_ws.py > feishu_ws.log 2>&1 &

Integration with Other Skills

Integrate feishu-messaging

Daily report sync workflow:

  1. This skill reads the Obsidian daily report
  2. Format the content
  3. Call the feishu-messaging skill to send the message

Integrate obsidian-organize

Knowledge base maintenance workflow:

  1. Use obsidian-organize to organize the document structure
  2. Trigger this skill's /index to rebuild the index
  3. Verify retrieval quality

Frequently Asked Questions

Q: The service cannot start?

Check:

  1. Python environment: poetry install
  2. Port usage: lsof -i :8001
  3. Environment variables: config/.env whether it exists

Q: Retrieval results are inaccurate?

Try:

  1. Rebuild the index: POST /index {"force": true}
  2. Increase the top_k value
  3. Use filter_folder to limit the scope

Q: The Feishu long connection is disconnected?

Check:

  1. Network connection
  2. Whether the App credentials have expired
  3. View logs: tail -f feishu_ws.log

Configuration file

config/.env

# LLM 配置
LLM_PROVIDER=anthropic
LLM_MODEL=claude-sonnet-4-20250514
ANTHROPIC_API_KEY=sk-ant-xxx

# 飞书配置
FEISHU_APP_ID=cli_xxx
FEISHU_APP_SECRET=xxx

# 服务配置
HOST=0.0.0.0
PORT=8001
DEBUG=true

config/settings.py

Main configuration items:

  • obsidian_vault_path: Knowledge base path
  • chroma_persist_dir: Vector database persistence directory
  • chunk_size: Document chunk size (default 1000)
  • chunk_overlap: Chunk overlap (default 200)

Monitoring and logging

Log locations

  • Main service: standard output or /tmp/zhimeng-agent.log
  • Feishu long connection: feishu_ws.log

Key log patterns

INFO:src.retriever:检索到 X 个相关文档  # 检索成功
INFO:httpx:HTTP Request: POST https://api.anthropic.com/v1/messages  # LLM 调用
INFO:src.smart_agent:已更新用户 xxx 的对话历史  # 对话记忆更新

Notes

  1. API key security: .env Do not commit the file to Git
  2. Cost control: Each Q&A consumes about Claude API $0.01-0.05
  3. Indexing time: A full rebuild takes about 2-5 minutes (depending on the number of documents)
  4. Conversation memory: Isolated by user_id; if there is no user_id, history is not retained
  5. Feishu long connection: The App needs to enable the "bot message long connection" capability