-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Amazon Bedrock Support ⛰️ #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Tested multimodal queries with Amazon Titan Multimodal Embeddings G1 (requires 🖼️ Data: images.zip Example: /**************
* MULTIMODAL *
**************/
-- Load sqlean extensions
.load ../sqlean/dist/crypto
.load ../sqlean/dist/fileio
.load ../sqlean/dist/text
-- Add Titan Embeddings Multimodal
insert into
temp.rembed_clients(name, options)
values
('amazon.titan-embed-image-v1', 'bedrock');
-- Create images table
create table multimodal(
input_text text,
input_image text --b64 encoded
);
-- Download images
.shell wget https://github.com/user-attachments/files/16530358/images.zip && unzip images.zip
-- Populate table with images
insert into multimodal
select
text_split(text_split(name, '/', -1), '.', 1),
encode(fileio_read(name), 'base64')
from
fileio_ls('./images')
where
name like '%.jpg';
-- Build a vector table for the multimodal embeddings
create virtual table vec_multimodal using vec0(
embeddings float[1024]
);
-- Embed text + images
insert into vec_multimodal(rowid, embeddings)
select
rowid,
rembed(
'amazon.titan-embed-image-v1',
input_text,
json(
concat(
'{"inputImage": "',
input_image,
'"}'
)
)
)
from
multimodal;
-- Run a multimodal query
.parameter set :query_image './images/puppy.jpg'
with matches as (
select
rowid,
distance
from vec_multimodal
where embeddings match
rembed(
'amazon.titan-embed-image-v1',
text_split(text_split(:query_image, '/', -1), '.', 1),
json(
concat(
'{"inputImage": "',
encode(fileio_read(:query_image), 'base64'),
'"}'
)
)
)
order by distance
limit 3
)
select
input_text,
distance
from matches
left join
multimodal
on
multimodal.rowid = matches.rowid; Output:
|
Added a fix for when the model ID contains 'bad' characters like colons The idea is to escape the model ID once ( Notice that the colon can appear multiple times in the model ID e.g. |
@asg017 would you mind reviewing this PR? |
This PR adds support for
EMBEDDING
models provided by Amazon Bedrock.Tested with Amazon Titan Embeddings Text and Cohere Embed.
Implementation includes ad-hoc functions to add AWS SigV4 signatures.
Example:
Output: