Use LangChain with CrateDB
Project description
langchain-cratedb
» 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file langchain_cratedb-0.1.1.tar.gz
.
File metadata
- Download URL: langchain_cratedb-0.1.1.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/75.6.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.21
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b04aa8ef59ce3d44ce6814f357a18510169f16d3c660a7686b05995f5a64cd1a
|
|
MD5 |
fe92a29a5ed9b015f1d3c1956de16d85
|
|
BLAKE2b-256 |
dcedda772c17d7baa332c07fcf54e8d3dc7adedb1527afec76f922f146515c45
|
File details
Details for the file langchain_cratedb-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: langchain_cratedb-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/75.6.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.21
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
820fa15696560d79b45d86432512db7e1f3be960b1a750c74b89b03d9d76236f
|
|
MD5 |
0068f2435063cf417ef7d2ba69c25a88
|
|
BLAKE2b-256 |
00b68ddb560059411b4e55066d285276cd2dddb8dcf35c590eb8908902ef43d8
|