Skip to main content

langchain-cognee

This package contains the LangChain integration with cognee.

This package enables you to:

  • Ingest documents into cognee
  • Build or update a knowledge graph
  • Retrieve and query your data using LangChain's standard interfaces

For more information, check out cognee documentation.

Installation

pip install -U langchain-cognee

Configuration

Set your environment variables required by cognee:

export LLM_API_KEY="your-openai-api-key"

Cognee's default settings:

  • LLM Provider: OpenAI
  • Databases: SQLite, LanceDB, networkx

In case you want to customize your settings, please refer here and configure your env variables accordingly.

Supported databases

  • Relational databases: SQLite, PostgreSQL
  • Vector databases: LanceDB, PGVector, QDrant, Weviate
  • Graph databases: Neo4j, NetworkX

Basic Usage

Below is a minimal example of how to use this integration:

    from langchain_cognee.retrievers import CogneeRetriever
    from langchain_core.documents import Document

    # 1) Instantiate the retriever
    retriever = CogneeRetriever(
        llm_api_key="YOUR_KEY", 
        dataset_name="test_dataset", 
        k=3
    )

    # 2) (Optional) Reset dataset if you want a clean slate
    retriever.reset_dataset()

    # 3) Add documents
    docs = [
        Document(page_content="Elon Musk is the CEO of SpaceX."),
        Document(page_content="SpaceX focuses on rockets."),
    ]
    retriever.add_documents(docs)

    # 4) Build knowledge graph
    retriever.process_data()

    # 5) Retrieve documents
    results = retriever.invoke("Tell me about Elon Musk")
    for doc in results:
        print(doc.page_content)

You can also incorporate CogneeRetriever in any LangChain chain.

Metadata

Release files for langchain-cognee 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-cognee 0.1.1
File Size Uploaded
langchain_cognee-0.1.1.tar.gz 6.3 kB Details

Built distribution (wheel)

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

Total release size: 15.5 kB

Release files / langchain_cognee-0.1.1.tar.gz

Download URL langchain_cognee-0.1.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1ab75f6110591779dc11cb63379767524179e0b847eba8507023df951051c100
BLAKE2b-256 checksum
How to use checksums
034d985b98a08991ae00bf6ac44ede419cb9b78d6f463f80b03aa44823542cb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.11.5 Darwin/23.6.0

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

Download URL langchain_cognee-0.1.1-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
000d1b21bc3461bf7d6f46e27710563b773ce784641a691524b3b33749e1fbcd
BLAKE2b-256 checksum
How to use checksums
12e06ec0826eeef2d7dd75ba3621464d997a3136e3642a5cc2fe5dcc8c64aeb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.11.5 Darwin/23.6.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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