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.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_cognee-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_cognee-0.1.0.tar.gz
Algorithm Hash digest
SHA256 20f034d0e9af229d2e6b3c68a0a132e5e3cf12889be97959c5df33cd19dcc0a8
MD5 205aa1d3e24fd6a5caad48e4af471a3d
BLAKE2b-256 d125912cccb8948d3d66eaac63c5a31afbccd0e5970f5fa7f8a7db8597ec2245

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for langchain_cognee-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5220847c18117d9241039a9dc7fbd86f8458cf0df89682c59120dad133cd9205
MD5 aea5fe1fddf9b9b59cf2d81685a27074
BLAKE2b-256 f00d9f76a13b4b744945dd994eb05e5b66d9a8804103f406ca626261e7e2eac6

See more details on using hashes here.

Supported by

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