ContextBridge Knowledge Base
📚 How It Works
ContextBridge provides OpenClaw with instant retrieval capabilities for local documents (Word, Excel, PDF, Markdown).
- 1. Local Indexing: Scans local documents and splits the text into manageable chunks.
- Vectorization: Uses a local AI embedding model to convert text chunks into semantic vectors.
- Semantic Search: Matches and retrieves the most semantically relevant text chunks from the knowledge base based on user queries.
🚀 Download & Installation
Installation and initialization workflow for cbridge:
CODEBLOCK0
1. Download
🔓 Open Source & Trustworthy: cbridge-agent is fully open-source, hosted on GitHub for audit and verification. Runs entirely locally with zero data leakage risk.
CODEBLOCK1
2. Initialization & Configuration
CODEBLOCK2
Note: Because this software is primarily invoked by AI tools, it is highly recommended to use the default configuration for all prompts during initialization.
3. Add Documents
CODEBLOCK3
4. Run Test Demo
CODEBLOCK4
💡 Search Best Practices
- 1. Seamless Execution: Act autonomously. Determine semantic intent from the user's prompt and seamlessly invoke
cbridge search to retrieve local content without explicitly asking the user, unless authorization is required. - Evaluate Snippets: The
cbridge search command returns document snippets and file paths. You must evaluate these snippets to determine whether you need to read the entire document or if the snippet contains enough context to answer the user.
When to Use ContextBridge
- 1. When analyzing the user's request suggests that the required information resides in internal, private, or local materials.
- When the user explicitly requests to search, check, or read local documents.
Keyword Extraction
- - Recommended: Extract core entities and noun phrases.
-
2024 marketing budget ✅
- - Not Recommended: Use full conversational sentences.
-
What was the budget for 2024 marketing ❌
Iterative Search Strategy
- 1. Start with highly precise keywords.
- If no results are found, broaden the search scope by using fewer or more general keywords.
- Try synonyms, related terminology, or alternative phrasing.
📖 CLI Commands
CODEBLOCK5
📚 Resource Links
ContextBridge 知识库
📚 工作原理
ContextBridge 为 OpenClaw 提供本地文档(Word、Excel、PDF、Markdown)的即时检索能力。
- 1. 本地索引: 扫描本地文档,将文本分割成可管理的片段。
- 向量化: 使用本地 AI 嵌入模型将文本片段转换为语义向量。
- 语义搜索: 根据用户查询,匹配并检索知识库中语义最相关的文本片段。
🚀 下载与安装
cbridge 的安装与初始化工作流程:
mermaid
flowchart TD
A([开始]) --> B{是否已安装 cbridge?\ncbridge --version}
B -- 是 --> C[检查更新\ncbridge update]
C --> D{是否需要重新初始化?\n询问用户}
D -- 是 --> E[重新初始化配置\ncbridge init]
D -- 否 --> G
E --> G
B -- 否 --> F1[说明 ContextBridge 安装需求\n目录监控与向量化需要]
F1 --> F2[说明 ContextBridge 工作目录\n~/.cbridge]
F2 --> F3[获取用户授权\n自动下载并使用默认配置初始化]
F3 --> G
G[配置完成\n通过 cbridge 与 ContextBridge 交互] --> H([运行内置演示\ncbridge search ContextBridge])
H --> I([结束])
1. 下载
🔓 开源可信:cbridge-agent 完全开源,托管于 GitHub 可供审计和验证。完全本地运行,零数据泄露风险。
bash
pip install cbridge-agent
2. 初始化与配置
bash
cbridge init
注意:由于本软件主要由 AI 工具调用,强烈建议在初始化过程中对所有提示使用默认配置。
3. 添加文档
bash
cbridge watch add /path/to/your/documents
cbridge watch list # 查看当前监控的目录
4. 运行测试演示
bash
cbridge search ContextBridge # 搜索内置测试文档
💡 搜索最佳实践
- 1. 无缝执行: 自主运行。根据用户提示确定语义意图,并自动调用 cbridge search 检索本地内容,除非需要授权,否则无需明确询问用户。
- 评估片段: cbridge search 命令返回文档片段和文件路径。您必须评估这些片段,以确定是否需要读取整个文档,或者片段是否包含足够上下文来回答用户。
何时使用 ContextBridge
- 1. 当分析用户请求表明所需信息存在于内部、私有或本地资料中时。
- 当用户明确要求搜索、查看或读取本地文档时。
关键词提取
- 2024 营销预算 ✅
- 2024 年营销预算是多少 ❌
迭代搜索策略
- 1. 从高精度关键词开始。
- 如果未找到结果,通过使用更少或更通用的关键词来扩大搜索范围。
- 尝试同义词、相关术语或替代措辞。
📖 CLI 命令
bash
初始化
cbridge init # 初始化工作空间
cbridge lang en # 切换 CLI 语言为英文
文档管理
cbridge watch add
# 添加目录到监控列表
cbridge watch remove # 从监控列表中移除目录
cbridge watch list # 列出所有监控目录
cbridge index # 手动重建索引
服务控制
cbridge start # 启动后台服务
cbridge serve # 仅启动 API
cbridge stop # 停止服务
cbridge status # 检查服务状态
cbridge logs # 查看服务日志
搜索
cbridge search # 使用关键词搜索文档
📚 资源链接