Skip to main content

An integration package connecting Cognee and LangChain

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_cognee-0.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

langchain_cognee-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_cognee-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_cognee-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.5 Darwin/23.6.0

File hashes

Hashes for langchain_cognee-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1ab75f6110591779dc11cb63379767524179e0b847eba8507023df951051c100
MD5 c2481f7bf0826d0630580aafca4d4761
BLAKE2b-256 034d985b98a08991ae00bf6ac44ede419cb9b78d6f463f80b03aa44823542cb7

See more details on using hashes here.

File details

Details for the file langchain_cognee-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langchain_cognee-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.5 Darwin/23.6.0

File hashes

Hashes for langchain_cognee-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 000d1b21bc3461bf7d6f46e27710563b773ce784641a691524b3b33749e1fbcd
MD5 3ca3733ab1f10af66c0f5ab96bb82bea
BLAKE2b-256 12e06ec0826eeef2d7dd75ba3621464d997a3136e3642a5cc2fe5dcc8c64aeb5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page