bedrock-text to embed text or bedrock-image to search images by text or image.
Prerequisites
Installboto3 for either embedding function. Install pillow as well for image embeddings.
Text embeddings
Thebedrock-text registry entry supports these model IDs.
For Cohere text models, set
source_input_type or query_input_type in create() to override search_document or search_query. You can also pass profile_name, assumed_role, and role_session_name to bedrock-text.
Image embeddings
LanceDB embeds images when you add them to a table. You can search the table with text or a Pillow image.bedrock-image uses boto3’s default credential chain. Select a profile with AWS_PROFILE in the application’s environment or run the application with an IAM role.
Choose a binary source column (
bytes) for encoded image bytes or a string source column (str) for file paths readable by the process that adds rows. Pillow detects the source format from the file contents. If your table has nullable images and vectors, pass on_bad_vectors="null" to keep rows without an image. To use Cohere Embed v4, pass name="cohere.embed-v4:0" to create().
query_type="vector". Run the following code in an async context with the db_path and query_image from the example.
AWS settings
Pass these options tocreate() with either registry entry.