Skip to main content

PyMongo integration with VoyageAI for multimodal embedding

Project description

PyMongo-VoyageAI-Multimodal

PyMongo integration with VoyageAI for multimodal embedding.

Installation

Requires Python 3.10+.

pip install --pre pymongo-voyageai-multimodal

Quickstart

Obtain an API key for VoyageAI.

from pymongo_voyageai_multimodal import PyMongoVoyageAI

# Create our client.
client = PyMongoVoyageAI(
    voyageai_api_key=os.environ["VOYAGE_API_KEY"],
    mongo_connection_string=os.environ["MONGODB_URI"],
    s3_bucket_name="<my-bucket-name>",
    collection_name="test",
    database_name="tests",
)

# Load data from a pdf url.
url = "https://www.fdrlibrary.org/documents/356632/390886/readingcopy.pdf"
images = client.url_to_images(url)
resp = client.add_documents(images)

# Wait for the vector search index to update.
client.wait_for_indexing()

# Query the embeddings, extracting the images.
query = "The consequences of a dictator's peace"
data = client.similarity_search(query, extract_images=True)

# Display the best image match.
data[0]["inputs"][0].image.show()

# Clean up and close the client.
client.delete_many({})
client.close()

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

pymongo_voyageai_multimodal-0.2.0.dev0.tar.gz (15.6 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 pymongo_voyageai_multimodal-0.2.0.dev0.tar.gz.

File metadata

File hashes

Hashes for pymongo_voyageai_multimodal-0.2.0.dev0.tar.gz
Algorithm Hash digest
SHA256 33b33ee720996c7b702268e8d067853f2e79d3f4e6d818f30977ed9ca2d4bc37
MD5 ab0aa7564064216b67601f916f46d485
BLAKE2b-256 dddd11ad26e24aa159f7d9f34643618a269524d28451b93219d4462c2fa6dd90

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymongo_voyageai_multimodal-0.2.0.dev0.tar.gz:

Publisher: release-python.yml on mongodb-labs/pymongo-voyageai-multimodal

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

File details

Details for the file pymongo_voyageai_multimodal-0.2.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for pymongo_voyageai_multimodal-0.2.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 d282aac205c8ff8e6acc6d3d0a213574159b0146501effdabd824eeddac46eed
MD5 15241355c19c095f17303e059ef74f87
BLAKE2b-256 85d7496b07516584d86b2e072c53375e4c6d541de3532084b5a21e6999883910

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymongo_voyageai_multimodal-0.2.0.dev0-py3-none-any.whl:

Publisher: release-python.yml on mongodb-labs/pymongo-voyageai-multimodal

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