ollama-ruby 1.12.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d979768964258e0f21d54b480b0afcd23c01ceefb75be3f828cb0440c45cd5d1
4
- data.tar.gz: b07ae78174a0614b146cd3cc7e4aeefc60ab86bc307b1b967f40c04841cce557
3
+ metadata.gz: d07a44fbcf79c2fcab881a2e2f2bcbcd42c18d040498e7988abb77e3aa97a6f5
4
+ data.tar.gz: 4ab66fbf6953ca66c3235eb9512ce38b53371d5f2178603ff678d94b30fa9551
5
5
  SHA512:
6
- metadata.gz: 2251a33cfdd40e1c53ebd9edb06a71994c68ef5a27ed82b35d691525459930e771a10dc93a0c8cc665e93980949a5abb60379f274954cee78a3edfeb4d92183e
7
- data.tar.gz: a956187b7c3cb96f9398ed3677e332251b21db0407c21468b04c540e9a1e925a3cb4a4ff7bfe2e946164d80a262e8cd6ce5219cb3bd51625bc39e8841fed2933
6
+ metadata.gz: '08433690e167532e8a98c81b212cb6a82a96329121f376379c56abf5ecfae2e7e11d96ba40875357b6a83796fe018db4b9a3b5148711860400cdbbe290c0e2c1'
7
+ data.tar.gz: bdf0161b3c9ba895ff79927bcd515f346c1582cebddc86f14d7077a16ad39c907a406d1db8a056ac0a7d1f19bdaf58468cbb4acab56d5618112fe875199da540
data/CHANGES.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changes
2
2
 
3
+ ## 2025-12-03 v1.14.0
4
+
5
+ - Added `as_json` method to `Ollama::Image` class that returns base64 string
6
+ for Ollama API compatibility
7
+ - Added test case verifying `image.to_json` produces quoted base64 string
8
+ - Method signature uses `*_args` to accept ignored parameters for JSON
9
+ compatibility
10
+ - Documented method behavior for JSON serialization compatibility
11
+
12
+ ## 2025-12-03 v1.13.0
13
+
14
+ - Updated `Ollama::Image#for_string` method to use `Base64.strict_encode64` for
15
+ image encoding
16
+ - Modified test expectations in `image_spec.rb` with new size **132196** and
17
+ checksum **20420**
18
+ - Updated `message_spec.rb` JSON payload to remove trailing newline from image
19
+ data
20
+ - Enhanced base64 encoding strictness for image handling in Ollama library
21
+
3
22
  ## 2025-11-30 v1.12.0
4
23
 
5
24
  - `ollama_cli`
data/lib/ollama/image.rb CHANGED
@@ -59,7 +59,7 @@ class Ollama::Image
59
59
  # @return [ Ollama::Image ] a new Image instance initialized with the
60
60
  # encoded string data and optional path
61
61
  def for_string(string, path: nil)
62
- for_base64(Base64.encode64(string), path:)
62
+ for_base64(Base64.strict_encode64(string), path:)
63
63
  end
64
64
 
65
65
  # Creates a new Image object from an IO object by reading its contents and
@@ -106,4 +106,14 @@ class Ollama::Image
106
106
  def to_s
107
107
  @data
108
108
  end
109
+
110
+ # Returns the base64-encoded string representation of the image data.
111
+ # When this object is serialized to JSON, it will produce a quoted base64
112
+ # string as required by the Ollama API.
113
+ #
114
+ # @param _args [Array] ignored arguments (for compatibility with JSON serialization)
115
+ # @return [String] the base64-encoded image data
116
+ def as_json(*_args)
117
+ to_s
118
+ end
109
119
  end
@@ -1,6 +1,6 @@
1
1
  module Ollama
2
2
  # Ollama version
3
- VERSION = '1.12.0'
3
+ VERSION = '1.14.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/ollama-ruby.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ollama-ruby 1.12.0 ruby lib
2
+ # stub: ollama-ruby 1.14.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama-ruby".freeze
6
- s.version = "1.12.0".freeze
6
+ s.version = "1.14.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -21,12 +21,16 @@ describe Ollama::Image do
21
21
  end
22
22
 
23
23
  it 'can be converted to base64 string' do
24
- expect(image.to_s.size).to eq 134400
25
- expect(image.to_s.sum).to eq 42460
24
+ expect(image.to_s.size).to eq 132196
25
+ expect(image.to_s.sum).to eq 20420
26
26
  expect(image.to_s[0, 40]).to eq '/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAA'
27
27
  end
28
28
 
29
29
  it 'tracks path of file' do
30
30
  expect(image.path).to eq asset('kitten.jpg')
31
31
  end
32
+
33
+ it 'can be converted into JSON as a quoted base64 string' do
34
+ expect(image.to_json).to eq '"%s"' % image.to_s
35
+ end
32
36
  end
@@ -26,7 +26,7 @@ describe Ollama::Message do
26
26
  images: [ image ],
27
27
  )
28
28
  expect(message.to_json).to eq(
29
- '{"role":"user","content":"hello world","thinking":"which world?","images":["dGVzdA==\n"]}'
29
+ '{"role":"user","content":"hello world","thinking":"which world?","images":["dGVzdA=="]}'
30
30
  )
31
31
  end
32
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ollama-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank