Class: Kiribi::Gemma4E2B::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kiribi/gemma4_e2b.rb

Direct Known Subclasses

AudioEncoder, Text, VisionEncoder

Class Method Summary collapse

Class Method Details

.download(dest_dir, force: false) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kiribi/gemma4_e2b.rb', line 12

def download(dest_dir, force: false)
  return if !force && self::FILES.all? { |f| File.exist?(File.join(dest_dir, f)) }
  FileUtils.rm_rf(dest_dir) if force
  FileUtils.mkdir_p(dest_dir)

  self::FILES.each do |f|
    path = File.join(dest_dir, f)
    File.open(path, "wb") do |io|
      Kiribi.http_get(url_for(f)) { |chunk| io.write(chunk) }
    end
  end
end

.url_for(filename) ⇒ Object



25
26
27
# File 'lib/kiribi/gemma4_e2b.rb', line 25

def url_for(filename)
  "#{BASE_URL}/onnx/#{filename}"
end