NLWeb
Microsoft 的 NLWeb 是一个提议中的框架,它使用 Schema.org、RSS 等格式和新兴的 MCP 协议,为网站提供自然语言接口。
Qdrant 在 NLWeb 中作为向量存储后端,支持嵌入存储和上下文检索。
用法
NLWeb 默认包含 Qdrant 集成。你可以安装和配置它,以使用 Qdrant 作为检索引擎。
安装
克隆仓库并设置环境
git clone https://github.com/microsoft/NLWeb
cd NLWeb
python -m venv .venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
cd code
pip install -r requirements.txt
配置 Qdrant
要使用 Qdrant,请更新你的配置。
1. 复制并编辑环境变量文件
cp .env.template .env
确保你的 .env 文件中设置了以下值
QDRANT_URL="https://xyz-example.cloud-region.cloud-provider.cloud.qdrant.io:6333"
QDRANT_API_KEY="<your-api-key-here>"
2. 更新 code/config 中的配置文件
config_retrieval.yaml
retrieval_engine: qdrant_url
或者,你可以使用内存中的 Qdrant 实例进行实验。
retrieval_engine: qdrant_local
endpoints:
qdrant_local:
# Path to a local directory
database_path: "../data/"
# Set the collection name to use
index_name: nlweb_collection
# Specify the database type
db_type: qdrant
加载数据
配置完成后,使用 RSS feed 加载你的内容。
在 code 目录中
python -m tools.db_load https://feeds.libsyn.com/121695/rss Behind-the-Tech
这将把内容摄取到你的本地 Qdrant 实例中。
运行服务器
要启动 NLWeb,在 code 目录中运行
python app-file.py
你现在可以通过自然语言查询你的内容,可以通过 https://:8000/ 上的 Web UI,或直接通过与 MCP 兼容的 REST API。