Skip to main content

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",
        filenaming_function=lamdba x: f"{x[0]}-{x[1].embedding.txt"}, # optional function to name your embedding file
        cache_behavior=CacheBehavior.NO_CACHE, # set to #CacheBehavior.ONLY_CACHE to use previously cached embeddings
    )

License

MIT

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_s3_cached_embeddings-0.8.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file langchain_s3_cached_embeddings-0.8.0.tar.gz.

File metadata

File hashes

Hashes for langchain_s3_cached_embeddings-0.8.0.tar.gz
Algorithm Hash digest
SHA256 f4384f1db55316c9ca750eeb7c3be795f9e85b2b0aa5343e75293dedfc7aca0d
MD5 a0cad23e6c6df61d6f8476fe8cbc2cd5
BLAKE2b-256 d676df7e4c70f97645aaf3f443eba724511e969414d863db99c53395f5765c13

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_s3_cached_embeddings-0.8.0.tar.gz:

Publisher: python-publish.yml on cdimascio/langchain-s3-cached-embeddings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_s3_cached_embeddings-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_s3_cached_embeddings-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecda76a8b38f82a981a48f6d8a17f7ad2d95b2b41d9fbdb310a8548c26964515
MD5 e2a69c23395719a2c9ce3c8b807d942a
BLAKE2b-256 2e59a104af7487c7e4365b67ed173c431da4fb1c5424cefaec3b9e6ab6f4a9f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_s3_cached_embeddings-0.8.0-py3-none-any.whl:

Publisher: python-publish.yml on cdimascio/langchain-s3-cached-embeddings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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