Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/mytk2012/python_agent/ragnpx skills add mytk2012/python_agent --skill raggit clone --depth 1 https://github.com/mytk2012/python_agentWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00007 | $0.01617 |
| Opus 5 | $0.00003 | $0.00809 |
| Sonnet 5 | $0.00001 | $0.00323 |
| Haiku 4.5 | $0.00001 | $0.00162 |
Grade A, and why
rag scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 242 lines — stays where its author put it; the contents beside it link to each section on GitHub.
RAG Skill
检索增强生成(Retrieval-Augmented Generation)能力,结合文档检索和LLM生成。
功能
- 文档摄入(PDF、DOCX、TXT、Markdown)
- 文本分块(Chunking)
- 向量嵌入生成
- 向量数据库管理
- 语义搜索
- 混合搜索(向量 + 关键词)
- 知识库管理
快速开始
1. 启动 Docker 服务
cd rag/docker && docker-compose up -d
启动的服务包括:
- Weaviate(向量数据库)
- Elasticsearch(关键词检索)
- Redis(缓存存储)
- nginx(代理)
2. 配置环境变量
确保 .env 文件包含以下配置:
# Elasticsearch(必须与 docker/.env 中配置一致)
ELASTICSEARCH_USER=elastic
ELASTICSEARCH_PASSWORD="difyai123456"
# Weaviate
WEAVIATE_API_KEY=jane-secret-key
# Redis
REDIS_PASSWD="difyai123456"
# Embedding 服务(用于向量检索和 RAG Pipeline)
EMBEDDING_MODEL=bge-large-zh-v1.5
EMBEDDING_API_URL=http://localhost:9997/v1
EMBEDDING_API_KEY=sk-your-api-key
# LLM 服务(用于 RAG Pipeline)
LLM_MODEL=glm-5
LLM_API_URL=https://api.example.com/v1
LLM_API_KEY=sk-your-api-key
3. 运行示例代码
import asyncio
from rag import (
KnowledgeBaseConfig,
kb_manager,
)
# 必须先导入以注册内置分块策略
from rag.extensions.custom_line_split import * # noqa: F401
async def main():
# 创建知识库(ELAS_ONLY 模式,仅使用 Elasticsearch)
config = KnowledgeBaseConfig(
kb_id="my_kb",
kb_name="我的知识库",
KNOWLEDGE_PATH="rag/test_document/",
ELAS_ONLY=True,
)
kb = await kb_manager.create_knowledge_base(**config.to_dict())
print("✅ 知识库创建成功")
# 加载并添加文档
await kb_manager.load_and_add_documents("my_kb", "rag/test_document/")
print("✅ 文档加载成功")
# 检索
results = await kb_manager.retrieve("my_kb", "查询内容", k=5)
print(f"✅ 检索返回 {len(results)} 条结果")
# 清理
await kb_manager.delete_knowledge_base("my_kb")
print("✅ 知识库已删除")
asyncio.run(main())
验证功能
运行完整测试脚本:
uv run python tests/test_knowledge_base_complete.py
测试覆盖:
- 多知识库管理
- 文档处理和分块
- 向量存储连接
- 检索功能
检索模式
三种模式互斥,只能启用一种:
| 模式 | 说明 | 配置 |
|---|---|---|
ELAS_ONLY |
仅关键词检索(Elasticsearch) | ELAS_ONLY=True |
VECTOR_ONLY |
仅向量检索(Weaviate) | VECTOR_ONLY=True |
MIXED |
混合检索 | MIXED=True |
ELAS_ONLY 模式(推荐入门)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 242 lines · 7 tokens per session scan A 6fbee8cc4c59
rag is a skill published in the GitHub repository mytk2012/python_agent (22 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 7 tokens to every session and 1,617 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
nemotron-retrieval-recipes
Use when planning, debugging, tuning, evaluating, exporting, or deploying public Nemotron embed/rerank retrieval recipes.
openkb-deck-neon
Use when the user asks the openkb chat to make a deck / slide presentation / PPT / slides / 演示稿 / 幻灯片 from their compiled KB content AND wants a dark, high-tech, neon / glow / glassmorphism look (赛博 / 科技风 / 暗色 / 霓虹 / 炫酷). Generates a polished single-file HTML deck in the Aurora Glass visual direction (near-black…
openkb-deck-editorial
Use when the user asks the openkb chat to make a deck / slide presentation / PPT / slides / 演示稿 / 幻灯片 from their compiled KB content. Generates a polished single-file HTML deck in the Editorial Monocle visual direction (warm cream background, serif type, brick-red accent) — designed to be opened in a browser…
openkb-html-critic
Use to review a generated HTML deck or single-page artifact for visual quality and structural correctness. Especially good at catching CSS specificity bugs where slide-modifier classes (.divider, .center, .q, .flow etc.) accidentally override the base .slide{display:none} and cause one slide to stack on top of every…
moss-search
Sub-10ms semantic search for Zo via Moss. Create indexes, add documents, and query them with semantic and keyword search. Use when users want to search through documents, knowledge bases, or any text content.
moss-pikachu
Build and maintain Moss Pikachu, a macOS menu bar semantic file search app using Moss Python SDK (PyPI moss>=1.6.0), FSEvents, SwiftUI, and Pikachu pet animations. Use when working on MossPikachu, mossworker.py, FileMonitor, SearchService, menu bar overlay, or Moss integration in this repository.