Skip to main content

langchain-knowledgelib

LangChain retriever for knowledgelib.io — pre-verified, cited knowledge units for AI agents.

Installation

pip install langchain-knowledgelib

Quick Start

from langchain_knowledgelib import KnowledgelibRetriever

retriever = KnowledgelibRetriever(k=3)
docs = retriever.invoke("best wireless earbuds under 150")

for doc in docs:
    print(f"[{doc.metadata['confidence']}] {doc.metadata['canonical_question']}")
    print(doc.page_content[:200])
    print()

Configuration

Parameter Default Description
api_url https://knowledgelib.io Base URL (change for self-hosted instances)
k 3 Number of results (1-20)
domain None Filter by domain (e.g., "consumer_electronics", "computing", "home")
fetch_full_content True Fetch full markdown or just canonical question text
api_key None Optional API key (not required for the free public API)

Document Metadata

Each returned Document includes rich metadata from knowledgelib.io:

doc.metadata = {
    "source": "knowledgelib.io",
    "id": "consumer-electronics/audio/wireless-earbuds-under-150/2026",
    "canonical_question": "What are the best wireless earbuds under $150 in 2026?",
    "confidence": 0.88,          # 0.0-1.0, based on source quality
    "last_verified": "2026-02-07",
    "source_count": 8,           # number of cited sources
    "freshness": "high",         # high/medium/low
    "token_estimate": 1800,      # approximate token count
    "relevance_score": 0.97,     # search relevance
    "url": "https://...",        # human-readable page
    "raw_md": "https://...",     # raw markdown URL
}

Use in a RAG Chain

from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_openai import ChatOpenAI

retriever = KnowledgelibRetriever(k=2, domain="consumer_electronics")

prompt = ChatPromptTemplate.from_template(
    "Answer based on these verified knowledge units:\n\n{context}\n\nQuestion: {question}"
)

chain = (
    {"context": retriever, "question": RunnablePassthrough()}
    | prompt
    | ChatOpenAI()
)

result = chain.invoke("best noise cancelling headphones under 200")

Async Support

docs = await retriever.ainvoke("best wireless earbuds under 150")

What is knowledgelib.io?

An AI Knowledge Library with structured, cited knowledge units optimized for AI agent consumption. Each unit answers one canonical question with full source provenance, confidence scoring, and freshness tracking. Pre-verified answers that save tokens ($0.02/query vs $0.50-$5.00 in agent compute), reduce hallucinations, and cite every source.

License

CC BY-SA 4.0

Metadata

Release files for langchain-knowledgelib 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-knowledgelib 0.1.1
File Size Uploaded Provenance
langchain_knowledgelib-0.1.1.tar.gz 5.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-knowledgelib 0.1.1
File Interpreter ABI Platform
langchain_knowledgelib-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / langchain_knowledgelib-0.1.1.tar.gz

Download URL langchain_knowledgelib-0.1.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f438cb3784ec025f2d9704bd9804f53200c37c2b7c5c6629807c74825f4a3f4c
BLAKE2b-256 checksum
How to use checksums
b30bea88ae6d6fd844cb1da4866dbaace8cfe166ae9dd0fb39b4367ef17c6930
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / langchain_knowledgelib-0.1.1-py3-none-any.whl

Download URL langchain_knowledgelib-0.1.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8beb082cf871257e345734c80b08ea1894dbcc982cb3be2efa1b197304382506
BLAKE2b-256 checksum
How to use checksums
e06fbf59f4f0ad1f6f2b311a9eb3ba8fc1ba72ad4b2f9eff2ea06adab1ed5d30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for langchain-knowledgelib 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page