ollama-ruby 1.15.0 → 1.16.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: e83f50382169132ae2774add6050e16e36bd9af29b5aca839007c0d48f0c51c0
4
- data.tar.gz: 5b1d915ea8bbf426d4f2ae08556533e1c78e4483857a8d649b96e9f668857491
3
+ metadata.gz: 12336647780f0ade66da333cfdc9aa2b6ef13d46104f1401753053d842fefe2c
4
+ data.tar.gz: 714a75014f7ec8ba5f11f8b947a8239830177bd61c52288fc7e5707067e265f5
5
5
  SHA512:
6
- metadata.gz: 9b0e7e583bcf8baa2fa5050ba84e1b94b890ed3d2fa8b871c72bb3a4dcf15f64ecebb6e665a6e7e49dc0f08e030cf5f5db5d0874f42f7f2f917572e03ed24672
7
- data.tar.gz: edae6c2a87f761b36fa0615073a999ba16451a3558a67d1d114f7cf510cdafaf44062ced275d21f1ea807c3badd0e3ae9d5fa4fc0b62cb8358bdf78bcbca9f44
6
+ metadata.gz: ca6f942ebe15774770d1ffba89ba0802050c1c403efb64f427ec3ee78bd744dd50e25b328078c06c1ff1895695f9d3d6294b42aa19b2e5dbe7908bdbc0872545
7
+ data.tar.gz: 86264aaeb4a1a8182ba9a1638fd9f598d6c7de385770e3fe98ef442081512a8cc881665691285a27fcd74885ab91d0afde05089f47bfd2495cdfaf79f95ebdce
data/CHANGES.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changes
2
2
 
3
+ ## 2025-12-09 v1.16.0
4
+
5
+ - Added support for handling HTTP 400 Bad Request errors
6
+ - Introduced new error class `Ollama::Errors::BadRequestError` for 400 status
7
+ codes
8
+ - Updated `Ollama::Client#request` method to raise `BadRequestError` for 400
9
+ responses
10
+ - Added test case in `spec/ollama/client_spec.rb` to verify 400 status code
11
+ handling
12
+ - Documented the new error class with example usage for think mode errors
13
+ - Maintained existing error handling for 404 and other status codes
14
+
3
15
  ## 2025-12-04 v1.15.0
4
16
 
5
17
  - Added documentation for `ollama_ps` executable utility in README
data/lib/ollama/client.rb CHANGED
@@ -173,6 +173,8 @@ class Ollama::Client
173
173
  response_line = parse_json(l)
174
174
  response_line and yielder.yield response_line
175
175
  end
176
+ when 400
177
+ raise Ollama::Errors::BadRequestError, "#{response.status} #{response.body.inspect}"
176
178
  when 404
177
179
  raise Ollama::Errors::NotFoundError, "#{response.status} #{response.body.inspect}"
178
180
  else
data/lib/ollama/errors.rb CHANGED
@@ -29,6 +29,22 @@ module Ollama
29
29
  class NotFoundError < Error
30
30
  end
31
31
 
32
+ # Ollama error class for handling cases where a requested resource is not
33
+ # found.
34
+ #
35
+ # This exception is raised when the Ollama API returns a 400 status code,
36
+ # indicating that the request was bad, e. g. think mode was requested from
37
+ # a non-thinking model.
38
+ #
39
+ # @example Handling a bad request error
40
+ # begin
41
+ # ollama.generate(model: 'llama3.1', prompt: 'Hello World', think: true)
42
+ # rescue Ollama::Errors::BadRequestError
43
+ # puts "Thinking not supported"
44
+ # end
45
+ class BadRequestError < Error
46
+ end
47
+
32
48
  # Ollama error class for handling timeout errors when communicating with
33
49
  # the Ollama API.
34
50
  #
@@ -1,6 +1,6 @@
1
1
  module Ollama
2
2
  # Ollama version
3
- VERSION = '1.15.0'
3
+ VERSION = '1.16.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.15.0 ruby lib
2
+ # stub: ollama-ruby 1.16.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama-ruby".freeze
6
- s.version = "1.15.0".freeze
6
+ s.version = "1.16.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]
@@ -71,6 +71,13 @@ describe Ollama::Client do
71
71
  }.to raise_error(Ollama::Errors::Error)
72
72
  end
73
73
 
74
+ it 'can raise error based on status code 400' do
75
+ expect(excon).to receive(:send).and_return(double(status: 400, body: '{}'))
76
+ expect {
77
+ ollama.generate(model: 'llama3.1', prompt: 'Hello World', think: true)
78
+ }.to raise_error(Ollama::Errors::BadRequestError)
79
+ end
80
+
74
81
  it 'can raise error based on status code 404' do
75
82
  expect(excon).to receive(:send).and_return(double(status: 404, body: '{}'))
76
83
  expect {
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.15.0
4
+ version: 1.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank