langchain embeddings wrapper to persist embeddings for re-use later
Project description
langchain-s3-cached-embeddings
Proxies any langchain Embeddings class such as OpenAIEmbeddings, GoogleGenerativeAIEmbeddings, persisting all generated embeddings to S3. This allows subsequent calls to optionally leverage the cached embeddings, avoiding additional and unecessary cost of re-embedding.
Install
pip install langchain-s3-cached-embeddings
Usage
from langchain_s3_text_loaders import S3DirectoryLoader
embeddings = S3EmbeddingsConduit(
embeddings=OpenAIEmbeddings(model=model), # required
bucket="my-embeddings-bucket", # required
prefix="my-optional-prefix"
)
Advanced Usage
embeddings = S3EmbeddingsConduit(
embeddings=OpenAIEmbeddings(model=model), # required
bucket="my-embeddings-bucket", # required
prefix="my-optional-prefix"
filenaming_function: Optional[Callable[[str, int], str]] = None,
cache_behavior = CacheBehavior.NO_CACHE):
Usage Options
embeddings- (required) any class implementinglangchain_core.embeddings.Embeddingsbucket- (required) the s3 bucket nameprefix- (required) the s3 key namefilenaming_function- (optional) redeives two arguments, 1. the file contents (str), 2. the index (int) e.g.9for the10the document and returns the filename ()str)cache_behavior- (optional)CacheBehavior.NO_CACHE- do not use cached embeddings, instead embed using theembeddingsclass' standardembed_documents(...)methodCacheBehavior.ONLY_CACHE- use cached embeddings. if the embeddings are no present, it raises an exception
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_s3_cached_embeddings-0.8.3.tar.gz.
File metadata
- Download URL: langchain_s3_cached_embeddings-0.8.3.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f32dfedcbfd8e22ab77e1a507ba46abf3c154a7df4baae68e836c2e262e71bf5
|
|
| MD5 |
51f292ff2aefd4447381bea408271784
|
|
| BLAKE2b-256 |
ba994843654aad95876efdd7ee41a7478dccc807573e11d1caa3ca5ddf7b39aa
|
Provenance
The following attestation bundles were made for langchain_s3_cached_embeddings-0.8.3.tar.gz:
Publisher:
python-publish.yml on cdimascio/langchain-s3-cached-embeddings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_s3_cached_embeddings-0.8.3.tar.gz -
Subject digest:
f32dfedcbfd8e22ab77e1a507ba46abf3c154a7df4baae68e836c2e262e71bf5 - Sigstore transparency entry: 158330269
- Sigstore integration time:
-
Permalink:
cdimascio/langchain-s3-cached-embeddings@bf59e54a16ba3bcdbb2b353268a8241d5bb5359e -
Branch / Tag:
refs/tags/v0.8.3 - Owner: https://github.com/cdimascio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@bf59e54a16ba3bcdbb2b353268a8241d5bb5359e -
Trigger Event:
release
-
Statement type:
File details
Details for the file langchain_s3_cached_embeddings-0.8.3-py3-none-any.whl.
File metadata
- Download URL: langchain_s3_cached_embeddings-0.8.3-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e829b91dfa95cd01af3b6f4a246dd43c5496ae0646e7a750b6a55301a802382c
|
|
| MD5 |
46c15128252464dfcadc126f1e6878fc
|
|
| BLAKE2b-256 |
2c396d648c10e89e0c8849352e962ce02c725f7b75210f4a321ae0f48621bfe8
|
Provenance
The following attestation bundles were made for langchain_s3_cached_embeddings-0.8.3-py3-none-any.whl:
Publisher:
python-publish.yml on cdimascio/langchain-s3-cached-embeddings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_s3_cached_embeddings-0.8.3-py3-none-any.whl -
Subject digest:
e829b91dfa95cd01af3b6f4a246dd43c5496ae0646e7a750b6a55301a802382c - Sigstore transparency entry: 158330270
- Sigstore integration time:
-
Permalink:
cdimascio/langchain-s3-cached-embeddings@bf59e54a16ba3bcdbb2b353268a8241d5bb5359e -
Branch / Tag:
refs/tags/v0.8.3 - Owner: https://github.com/cdimascio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@bf59e54a16ba3bcdbb2b353268a8241d5bb5359e -
Trigger Event:
release
-
Statement type: