Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
46704cf
Add support for multimodal embedding
Nov 27, 2025
1df5fe5
Remove brackets
Dec 2, 2025
ffe5c2a
Enable embeddings with and without text
Dec 5, 2025
8ce3654
Clean up comments
Dec 5, 2025
da901df
Fix dimensions parameter for VertexAI embeddings
Jan 14, 2026
ae5925c
Merge pull request #1 from Ndunge-Makau/multimodal-embeddings
Ndunge-Makau Jan 14, 2026
7f2902c
Merge branch 'crmne:main' into main
Ndunge-Makau Jan 14, 2026
9297de7
Fix dimension argument to allow embedding of any size
Jan 14, 2026
4cf79a1
Merge pull request #2 from Ndunge-Makau/Fix-dimension-bug
Ndunge-Makau Jan 14, 2026
71ecbff
Merge branch 'crmne:main' into main
Ndunge-Makau Jan 14, 2026
4c58f83
Merge branch 'crmne:main' into main
Ndunge-Makau Jan 20, 2026
4406bd3
Merge branch 'crmne:main' into main
Ndunge-Makau Jan 21, 2026
4ef2e6a
Merge branch 'crmne:main' into main
Ndunge-Makau Jan 23, 2026
37a2da2
Merge branch 'crmne:main' into main
Ndunge-Makau Jan 27, 2026
979b176
Add the multimodalembedding model by VertexAI
Jan 27, 2026
42f2052
Merge pull request #3 from Ndunge-Makau/add-multimodalembedding-model
Ndunge-Makau Jan 27, 2026
62a4dd7
Add with parameter to hold all media arguments
Jan 28, 2026
8caa042
Fix image and video input bug
Jan 29, 2026
a3b9b11
Merge pull request #4 from Ndunge-Makau/add-with-parameter-to-multimo…
Ndunge-Makau Jan 30, 2026
73f2e5e
Edit README.md
Jan 30, 2026
9cb2957
Merge pull request #5 from Ndunge-Makau/add-with-parameter-to-multimo…
Ndunge-Makau Jan 30, 2026
ef4c6a2
Fix potential regression issue
Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ RubyLLM.paint "a sunset over mountains in watercolor style"
```ruby
# Create embeddings
RubyLLM.embed "Ruby is elegant and expressive"

# Create multimodal embeddings (with supported models)
RubyLLM.embed "Ruby is elegant and expressive", with: ["image.png", "video.mp4"], model: multimodalembedding
```

```ruby
Expand Down
27 changes: 24 additions & 3 deletions lib/ruby_llm/embedding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,40 @@ def initialize(vectors:, model:, input_tokens: 0)
@input_tokens = input_tokens
end

def self.embed(text, # rubocop:disable Metrics/ParameterLists
def self.embed(text = nil, # rubocop:disable Metrics/ParameterLists
model: nil,
provider: nil,
assume_model_exists: false,
context: nil,
dimensions: nil)
dimensions: nil,
with: nil)
config = context&.config || RubyLLM.config
model ||= config.default_embedding_model
model, provider_instance = Models.resolve(model, provider: provider, assume_exists: assume_model_exists,
config: config)
model_id = model.id
args = set_embedding_params(
provider_instance,
text: text,
model_id: model_id,
dimensions: dimensions,
with: with
)

provider_instance.embed(text, model: model_id, dimensions:)
provider_instance.embed(**args)
end

def self.set_embedding_params(provider_instance,
text: nil,
model_id: nil,
dimensions: nil,
with: nil)
embed_params = provider_instance.method(:embed).parameters.map(&:last)
args = { model: model_id }
args[:text] = text if text
args[:dimensions] = dimensions if dimensions
args[:with] = with if with && embed_params.include?(:with)
args
end
end
end
Loading