Skip to main content

Use LangChain with CrateDB

Project description

langchain-cratedb

Bluesky Release Notes CI Downloads per month

Package version License Status Supported Python versions

» Documentation | Changelog | PyPI | Issues | Source code | License | CrateDB | Community Forum

The langchain-cratedb package implements the CrateDB provider for LangChain, i.e. core LangChain abstractions using CrateDB or CrateDB Cloud.

Feel free to use the abstractions as provided or else modify them / extend them as appropriate for your own applications. We appreciate contributions of any kind.

Introduction

CrateDB is a distributed and scalable SQL database for storing and analyzing massive amounts of data in near real-time, even with complex queries. It is PostgreSQL-compatible, and based on Lucene.

LangChain is a composable framework to build context-aware, reasoning applications with large language models, leveraging your company’s data and APIs.

LangChain for CrateDB is an AI/ML framework that unlocks the application of LLM technologies to hands-on projects, covering many needs end-to-end. It builds upon the large array of utilities bundled by the LangChain toolkit and the ultra-fast indexing capabilities of CrateDB.

You can apply LangChain to implement text-based applications using commercial models, for example provided by OpenAI, or open-source models, for example Meta's Llama multilingual text-only and text-image models.

Installation

pip install --upgrade langchain-cratedb

Requirements

The package currently supports CrateDB and its Python DB API driver, available per crate package. It will be automatically installed when installing the LangChain adapter.

You can run CrateDB Self-Managed or start using CrateDB Cloud, see CrateDB Installation, or CrateDB Cloud Console.

Usage

To learn about the LangChain adapter for CrateDB, please refer to the documentation and examples:

Vector Store

A few notebooks demonstrate how to use the CrateDB vector store functionality around its FLOAT_VECTOR data type and its KNN_MATCH function together with LangChain.

You will learn how to import and query unstructured data using the CrateDBVectorStore, for example to create a retrieval augmented generation (RAG) pipeline.

Retrieval-Augmented Generation (RAG) combines a retrieval system, which fetches relevant documents, with a generative model, allowing it to incorporate external knowledge for more accurate and informed responses.

Document Loader

This notebook demonstrates how to load documents from a CrateDB database, using LangChain's SQLDatabase and CrateDBLoader interfaces, based on SQLAlchemy.

Chat History

The chat message history adapter helps to store and manage chat message history in a CrateDB table, for supporting conversational memory.

Full Cache

The standard / full cache avoids invoking the LLM when the supplied prompt is exactly the same as one encountered already.

Semantic Cache

The semantic cache allows users to retrieve cached prompts based on semantic similarity between the user input and previously cached inputs, also avoiding to invoke the LLM when not needed.

Project Information

Acknowledgements

Kudos to the authors of all the many software components this library is inheriting from and building upon, most notably the langchain-postgres package, and langchain itself.

Contributing

The langchain-cratedb package is an open source project, and is managed on GitHub. We appreciate contributions of any kind.

License

The project uses the MIT license, like the langchain-postgres project it is deriving from.

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_cratedb-0.2.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

langchain_cratedb-0.2.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_cratedb-0.2.0.tar.gz.

File metadata

  • Download URL: langchain_cratedb-0.2.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for langchain_cratedb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0b951ed7d418322b08fa11cd9ff80de4769dcc6fc197552d9dbb021608697bf9
MD5 7b956e1e2a887e5fcf046b38d9c7b02c
BLAKE2b-256 1878811c93e04565b64078bcd089f66d25d92a9990c18d902384bc20c23f2108

See more details on using hashes here.

File details

Details for the file langchain_cratedb-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_cratedb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7e0b64f35566f92947ec17c215819e0d3a830106dab74565a9d91bda4070872
MD5 51870158538cecbaa59e525eb5d3833d
BLAKE2b-256 5533058da6ee118f11a0331a86892e017f1137953b9f1e4364bd51febfa044b8

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