WARNING: This repository contains an AI-assisted pilot implementation exploring integration of the NLWeb protocol with domain websites. It is experimental and intended for evaluation, not as a production-ready or officially endorsed implementation. NLWeb specifications and related tooling are still evolving; interfaces, behavior, and compatibility may change without notice. If you choose to use or adapt this software in production, evaluate it for your own requirements, test it thoroughly, and do so at your own risk. It is provided “as is,” without warranties or guarantees of fitness for a particular purpose.
Framework-neutral Python widget for exposing authoritative domain data through the NLWeb protocol. The official NLWeb Specification is authoritative for wire-level behavior; example-specific ingestion conventions do not override it.
uv add nlweb-widgetfrom nlweb_widget import ContentDocument, NLWebWidget
widget = NLWebWidget(domain="https://example.com")
await widget.startup()
await widget.index(
ContentDocument(
id="service-1",
url="https://example.com/services/ai",
title="AI consulting",
content="AI transformation and implementation services.",
schema_object={"@type": "Service", "name": "AI consulting"},
)
)The memory provider is dependency-free and remains the default. The widget is disabled by default until NLWEB_ENABLED=true is configured.
from nlweb_widget.integrations.fastapi_integration import mount_fastapi_nlweb
mount_fastapi_nlweb(app, widget)The same core works with the supported Flask, Django, Starlette, and standard-library adapters. Mounted protocol surfaces include /ask, /mcp, /.well-known/nlweb, and /health.
POST /ask accepts the NLWeb sections query, context, prefer, and meta.
{
"query": {"text": "Which AI services do you provide?", "site": "default"},
"context": {},
"prefer": {"mode": "list", "response_format": "conversational_search"},
"meta": {"version": "0.55", "session_context": {}}
}Supported modes are list and summarize; supported response formats are conversational_search and chatgpt_app. Unsupported modes/formats produce explicit NLWeb failures. MCP independently exposes tools/list and tools/call, including structured content, _meta, isError, and JSON-RPC protocol errors.
For HTTP /ask, set prefer.streaming to true to request Server-Sent Events (text/event-stream). The implementation emits the specification event sequence start, indexed result events, an optional application-level error, and complete (including session_context when present). Set prefer.streaming to false or omit it for a single JSON response. The FastAPI, Starlette, Django, Flask, and standard-library HTTP adapters expose the streaming binding; the MCP tool-call response remains a separate binding.
Install only the capability you need:
uv sync --extra postgres
uv sync --extra neo4j
uv sync --extra haystack
uv sync --extra qdrant
uv sync --extra qdrant-edge
uv sync --extra sqliteConfigure the provider with NLWEB_RETRIEVAL_STORE and its corresponding NLWEB_* settings. Provider-specific validation is conditional.
NLWEB_RETRIEVAL_STORE=qdrant_edge
NLWEB_QDRANT_EDGE_PATH=./.nlweb-qdrant-edge
NLWEB_QDRANT_EDGE_DIMENSIONS=1536
Qdrant Edge is an embedded/local provider and deliberately has a separate lifecycle from Qdrant Server/Cloud.
Install the optional provider with nlweb-widget[sqlite]. The package pins sqlite-vec==0.1.8 for this candidate because the upstream extension remains pre-v1.
NLWEB_RETRIEVAL_STORE=sqlite
NLWEB_SQLITE_PATH=./.nlweb-sqlite/nlweb.db
NLWEB_SQLITE_DIMENSIONS=384
The optional SQLite provider combines SQLite FTS5 keyword retrieval with
sqlite-vec KNN vector retrieval behind the same RetrievalProvider contract.
The extension is pinned to sqlite-vec==0.1.8 because the upstream project
remains pre-v1 and explicitly warns that breaking changes may occur. The provider
keeps its database path and embedding dimensions configuration-driven.
NLWEB_RETRIEVAL_STORE=pgvector
NLWEB_POSTGRES_DATABASE_URL=postgresql+asyncpg://nlweb:nlweb@localhost:5432/nlweb
NLWEB_PGVECTOR_DIMENSIONS=1536
NLWEB_RETRIEVAL_STORE=neo4j
NLWEB_NEO4J_URI=neo4j://localhost:7687
NLWEB_NEO4J_USERNAME=neo4j
NLWEB_NEO4J_PASSWORD=...
NLWEB_NEO4J_VECTOR_DIMENSIONS=1536
Neo4j vector dimensions are configuration-driven. The provider uses SEARCH on supported versions and retains an explicit legacy fallback.
Install multilingual local embeddings with uv sync --extra embeddings. E5-family models receive query:/passage: prefixes automatically unless overridden. Applications can inject their own embedding provider.
Install Docling with uv sync --extra documents to normalize supported unstructured sources into ContentDocument. Parser-specific objects never cross the public boundary.
The dependency-free nlweb_widget.embedding_benchmark harness reports Recall@1/3/5, mean query latency, and dimensions for provider/model selection.
The project-root .env is the minimum startup configuration source. .env.example contains commented optional-provider settings, including Qdrant Edge.
uv sync --dev
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv buildOptional-provider integration tests skip when the provider is not explicitly configured and fail when a configured provider cannot be exercised.
Please visit https://ipen-solutions.github.io/nlweb-widget-docs/ for complete documentation of the widget.
A comprehensive, detailed bundle of usage examples available for download and install at https://github.com/IPEN-Solutions/nlweb-widget-examples
This release is governed by revision-iteration-manifest-0.9.12.toml. Historical candidate manifests are retained as provenance; the approved release record is authoritative for 0.9.12 status.
See CHANGELOG.md for revision and provider details.
- Configured Qdrant Server tests now perform real initialize/upsert/search/cleanup and skip only when no endpoint is configured.
- Qdrant Edge reuses an already-open shard instead of reopening its WAL on every operation.
- FastAPI
/askand/mcpexpose typed NLWeb/MCP request schemas and editable OpenAPI examples. - Provider VS Code tasks and launch configurations use a consistent
Provider: <backend> — <action>convention. - OpenRouter synthesis remains optional; retrieval query demos do not fail solely because optional answer synthesis is unavailable.
When the documents extra is enabled, DOCLING_DEVICE, DOCLING_NUM_THREADS, and DOCLING_SAFE_PDF control the optional document adapter. DOCLING_SAFE_PDF=true selects backend PDF text extraction without OCR/table/layout inference, avoiding unnecessary Torch/RT-DETR execution on constrained CPU hosts. The default remains false for backward-compatible Docling behavior; provider examples explicitly enable safe PDF mode for Windows local QA.
See AUTHORITATIVE-DOMAIN-DATA-CONTRACT.md, CONTRACT-TRACEABILITY.md for the shared contract, requirement-to-test mapping.