ollama-ruby 1.25.0 → 1.26.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: 1a8729b76057bbe9bda6d774b3d5ee4e9227ed0c6f3eaa6518b40efe5b0e979a
4
- data.tar.gz: c56b35df0a1afe4cdf12cc06a95763d62d4fdcdc5fc96093c0b28484c4174d6b
3
+ metadata.gz: f101efa42abe520f7fb3f718bf6b4ac146ec0b28639dd3183d75d180a471d346
4
+ data.tar.gz: 2875f4865a3fb7a47d2f737752b0e3e6025f5d129ea4510d289bb4cdbabc6412
5
5
  SHA512:
6
- metadata.gz: 9f51f5d86982a8d32c69df5f6660fd4a51e6c054fbfb9ef245c40fc46cac1d18cf42c00544649839377ccc7f2383cf9bb040e37a4a1f72fe517dde1b66708add
7
- data.tar.gz: f870f0e817b8c33072ceac03e73d076f93c0b396942a689068fccbb8b14fa217b68105e152f087ea0fc3871a71a927f2612831a7b2c8538a1ae91ec6bb76118c
6
+ metadata.gz: c8e41ec6ec520238ccfe3a721600faa9d61356f05fb3fb46f3ca6c83ff0abbc78585a9c01afda0287d2ace92132d2458aecc6acc75ab0a9266df65cf964a60a0
7
+ data.tar.gz: b054b3326b5cde5afaf96ed8b667f13d3fb32710dff22a817da52133e418577388026d5e117395f405a743fe0a205cbdfc65e96eaf8185c64c38d9c00a5865aa
data/CHANGES.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-10-23 v1.26.0
4
+
5
+ ### Features
6
+
7
+ - Added `Ollama::BaseURL` module with a `base_url` method to normalize host
8
+ specifications into `URI` objects, automatically prepending `http://` when no
9
+ scheme is present.
10
+ - Exposed `Ollama.base_url` as the public entry point for resolving base URLs.
11
+
12
+ ### Fixes
13
+
14
+ - Updated `bin/ollama_browse` to strip the tag suffix from the model argument
15
+ before querying the tags URL, preventing 404 errors for models with tags
16
+ (e.g., `qwen3-coder:latest`).
17
+
18
+ ### Improvements
19
+
20
+ - Replaced inline base URL construction in `bin/ollama_cli`,
21
+ `bin/ollama_console`, `bin/ollama_ps`, and `bin/ollama_update` with calls to
22
+ `Ollama.base_url`.
23
+
24
+ ### Build & CI
25
+
26
+ - Updated the `gem_hadar` development dependency to **2.20.1**.
27
+
28
+ ### Testing
29
+
30
+ - Added `spec/ollama/base_url_spec.rb` to cover bare host:port strings,
31
+ IP:port, full `http://`/`https://` URLs, `URI` object pass-through, and
32
+ `fallback: false` behavior.
33
+
34
+ ### Documentation
35
+
36
+ - Added a "Vision (Multimodal) Models" section to the README with a workflow
37
+ for importing vision models using `push_blob` and `create`.
38
+ - Added a note clarifying that `push_blob` returns `sha256:`-prefixed digests
39
+ and that `files` map keys must be basenames.
40
+ - Added a tip to verify exact filenames via the Hugging Face API
41
+ `siblings[].rfilename`.
42
+ - Simplified the `show`/`create` parameter-inheritance example in the README to
43
+ use Ruby 3.1+ hash shorthand.
44
+ - Fixed various typos in the README, including `&` to `&`, "the the",
45
+ "choosen" to "chosen", "commdand(s)" to "command(s)", and "can be be created"
46
+ to "can be created".
47
+
3
48
  ## 2026-10-17 v1.25.0
4
49
 
5
50
  * `DTO#to_hash` now only rejects `nil` attribute values instead of also
data/README.md CHANGED
@@ -10,7 +10,7 @@ an ollama server via the
10
10
 
11
11
  Complete API documentation is available at: [GitHub.io](https://flori.github.io/ollama-ruby/)
12
12
 
13
- ## Installation (gem & bundler)
13
+ ## Installation (gem & bundler)
14
14
 
15
15
  To install Ollama, you can use the following methods:
16
16
 
@@ -89,7 +89,7 @@ Commands: chat,copy,create,delete,embeddings,generate,help,ps,pull,push,show,tag
89
89
 
90
90
  ## API
91
91
 
92
- This Ollama library provides commands to interact with the the [Ollama REST
92
+ This Ollama library provides commands to interact with the [Ollama REST
93
93
  API](https://github.com/ollama/ollama/blob/main/docs/api.md)
94
94
 
95
95
 
@@ -131,9 +131,9 @@ The following standard handlers are available for the commands below:
131
131
  Their `output` IO handle can be changed by e. g. passing `Print.new(output:
132
132
  io)` with `io` as the IO handle to the _generate_ command.
133
133
 
134
- If you don't pass a handler explicitly, either the `stream_handler` is choosen
134
+ If you don't pass a handler explicitly, either the `stream_handler` is chosen
135
135
  if the command expects a streaming response or the `default_handler` otherwise.
136
- See the following commdand descriptions to find out what these defaults are for
136
+ See the following command descriptions to find out what these defaults are for
137
137
  each command. These commands can be tried out directly in the `ollama_console`.
138
138
 
139
139
  ### Chat
@@ -280,16 +280,63 @@ create(
280
280
  This method is highly efficient as it uses streaming uploads and avoids
281
281
  redundant data transfers if the blob already exists on the server.
282
282
 
283
+ > **Note:** `push_blob` returns the digest with the `sha256:` prefix already
284
+ > included. The keys in the `files` map must be the **basename** of the file
285
+ > (e.g., `my-model-q4_0.gguf`), not a path or digest.
286
+
283
287
  You can also import parameters from an existing model using the `show`
284
288
  endpoint. `Options.from_string` parses the multi-line `parameters` field into
285
289
  a typed `Options` instance that can be passed to `create(…, parameters:)`:
286
290
 
287
291
  ```ruby
288
- info = show(model: 'llama3.1')
289
- options = Options.from_string(info.parameters)
290
- create(model: 'my-clone', from: 'llama3.1', parameters: options)
292
+ info = show(model: 'llama3.1')
293
+ parameters = Options.from_string(info.parameters)
294
+ create(model: 'my-clone', from: 'llama3.1', parameters:)
291
295
  ```
292
296
 
297
+ ### Vision (Multimodal) Models
298
+
299
+ For vision-capable models (e.g., Gemma 4, Qwen VL), you push **two** blobs:
300
+ the language model weights and the vision projector. The `mmproj-*` filename
301
+ convention is what tells Ollama a file is a projector — there is no Modelfile
302
+ directive for it.
303
+
304
+ This workflow is particularly convenient in the `ollama_console`:
305
+
306
+ ```ruby
307
+ # Point at your local files (full paths from hf download)
308
+ gp = '/home/flori/.cache/huggingface/hub/…/model.i1-Q5_K_S.gguf' # Large Language Model
309
+ mp = '/home/flori/.cache/huggingface/hub/…/model.mmproj-f16.gguf' # Vision Encoder
310
+
311
+ # Push both blobs (digests come back sha256:-prefixed)
312
+ digest_gp = push_blob(body: File.new(gp, 'rb'))
313
+ digest_mp = push_blob(body: File.new(mp, 'rb'))
314
+
315
+ # Build the files map: basename => digest
316
+ files = {
317
+ File.basename(gp) => digest_gp,
318
+ File.basename(mp) => digest_mp
319
+ }
320
+
321
+ # Inherit template & parameters from a same-architecture reference
322
+ ref = show(model: 'gemma4:31b-it-q4_K_M')
323
+ template = ref.template
324
+ parameters = Ollama::Options.from_string(ref.parameters)
325
+
326
+ # Create the model
327
+ create(
328
+ model: 'flori/my-visual-model:i1-Q5_K_S',
329
+ files:,
330
+ template:,
331
+ parameters:
332
+ )
333
+ ```
334
+
335
+ > **Tip:** Verify exact filenames via the HF API
336
+ > (`/api/models/<repo_id>` → `siblings[].rfilename`) or the repo file tree
337
+ > before downloading. Model card tables may use display names (e.g., "BF16")
338
+ > that differ from actual filenames (e.g., `mmproj-f16.gguf`).
339
+
293
340
  ## Auxiliary objects
294
341
 
295
342
  The following objects are provided to interact with the ollama server. You can
@@ -297,7 +344,7 @@ run all of the examples in the `ollama_console`.
297
344
 
298
345
  ### Message
299
346
 
300
- Messages can be be created by using the **Message** class:
347
+ Messages can be created by using the **Message** class:
301
348
 
302
349
  ```ruby
303
350
  message = Message.new role: 'user', content: 'hello world'
@@ -317,10 +364,10 @@ It's possible to create an **Image** object via `for_base64(data)`,
317
364
 
318
365
  ### Options
319
366
 
320
- For `chat` and `generate` commdands it's possible to pass an **Options** object
367
+ For `chat` and `generate` commands it's possible to pass an **Options** object
321
368
  to configure different
322
369
  [parameters](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#parameter)
323
- for the running model. To set the `temperature` can be done via:
370
+ for the running model. To set the `temperature` you can:
324
371
 
325
372
  ```ruby
326
373
  options = Options.new(temperature: 0.999)
@@ -603,7 +650,6 @@ the following command:
603
650
  ```bash
604
651
  gem install ollama-chat
605
652
  ```
606
- - Set default format to **table** when no `-f` flag is provided
607
653
 
608
654
  Once installed, you can run `ollama_chat` from your terminal or command prompt.
609
655
  This will launch a chat interface where you can interact with an LLM.
data/bin/ollama_browse CHANGED
@@ -15,6 +15,7 @@ require 'excon'
15
15
  require 'nokogiri'
16
16
 
17
17
  model = ARGV.shift or fail 'model name as first argument is required'
18
+ model = model.gsub(/:.*/, '')
18
19
  url_prefix = 'https://ollama.com/library'
19
20
  tags_url = '%s/%s/tags' % [ url_prefix, model ]
20
21
  result = Excon.get(tags_url)
data/bin/ollama_cli CHANGED
@@ -137,7 +137,7 @@ opts = go 'u:m:M:s:p:P:H:c:I:STdih', defaults: { ?H => 'ChatStart' }
137
137
 
138
138
  opts[?h] and usage
139
139
 
140
- base_url = opts[?u] || ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
140
+ base_url = Ollama.base_url(opts[?u] || ENV['OLLAMA_URL'] || ENV.fetch('OLLAMA_HOST'))
141
141
  api_key = ENV['OLLAMA_API_KEY']
142
142
  client_config = Client::Config[
143
143
  { base_url:, api_key:, debug: !!opts[?d] } |
data/bin/ollama_console CHANGED
@@ -25,11 +25,12 @@ require 'irb/history'
25
25
  # The base_url method returns the Ollama API base URL.
26
26
  #
27
27
  # It first checks for the OLLAMA_URL environment variable.
28
- # If not set, it defaults to 'http://' followed by the OLLAMA_HOST environment variable.
28
+ # If not set, it falls back to the OLLAMA_HOST environment variable.
29
+ # The result is normalized via {Ollama.base_url}.
29
30
  #
30
- # @return [ String ] the base URL for the Ollama API
31
+ # @return [URI, nil] the normalized base URL for the Ollama API
31
32
  def base_url
32
- ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
33
+ Ollama.base_url(ENV['OLLAMA_URL'] || ENV.fetch('OLLAMA_HOST'))
33
34
  end
34
35
 
35
36
  # The client_config method retrieves and merges client configuration settings.
data/bin/ollama_ps CHANGED
@@ -60,12 +60,12 @@ end
60
60
  # The base_url method returns the Ollama API base URL.
61
61
  #
62
62
  # It first checks for the OLLAMA_URL environment variable.
63
- # If not set, it defaults to 'http://' followed by the OLLAMA_HOST environment
64
- # variable.
63
+ # If not set, it falls back to the OLLAMA_HOST environment variable.
64
+ # The result is normalized via {Ollama.base_url}.
65
65
  #
66
- # @return [ String ] the base URL for the Ollama API
66
+ # @return [URI, nil] the normalized base URL for the Ollama API
67
67
  def base_url
68
- ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
68
+ Ollama.base_url(ENV['OLLAMA_URL'] || ENV.fetch('OLLAMA_HOST'))
69
69
  end
70
70
 
71
71
  # The format_bytes method formats a number of bytes into a human-readable
data/bin/ollama_update CHANGED
@@ -16,7 +16,7 @@ include Term::ANSIColor
16
16
  require 'ollama'
17
17
  include Ollama
18
18
 
19
- base_url = ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
19
+ base_url = Ollama.base_url(ENV['OLLAMA_URL'] || ENV.fetch('OLLAMA_HOST'))
20
20
  ollama = Client.new(base_url:)
21
21
  ollama.tags.models.each do |model|
22
22
  name, modified_at = model.name, Time.parse(model.modified_at)
@@ -0,0 +1,54 @@
1
+ # A module that provides URL normalization for the Ollama base URL.
2
+ #
3
+ # This module is extended into the Ollama namespace, making
4
+ # +Ollama.base_url+ the public entry point for resolving a
5
+ # user-supplied host specification into a fully-qualified
6
+ # {URI} suitable for HTTP(S) communication with an Ollama server.
7
+ #
8
+ # @example Resolving a bare host:port
9
+ # Ollama.base_url('127.0.0.1:11434')
10
+ # # => #<URI::HTTP http://127.0.0.1:11434>
11
+ #
12
+ # @example Resolving a fully-qualified URL (unchanged)
13
+ # Ollama.base_url('https://mybox:11434/v1')
14
+ # # => #<URI::HTTPS https://mybox:11434/v1>
15
+ module Ollama::BaseURL
16
+ # Normalizes a base URL specification into a {URI} object.
17
+ #
18
+ # Accepts either a {URI} instance or a String. If the String
19
+ # does not contain an explicit +http://+ or +https://+ scheme,
20
+ # one is prepended automatically.
21
+ #
22
+ # @param spec [URI, String] the host specification or full URL
23
+ # @param fallback [Boolean] when true (default), a missing or
24
+ # unrecognized scheme triggers an automatic +http://+ prepend.
25
+ # When false, unrecognized schemes return +nil+.
26
+ # @return [URI, nil] the normalized URI, or +nil+ if +fallback+
27
+ # is false and the scheme is not http/https.
28
+ #
29
+ # @example Bare IP:port (scheme prepended)
30
+ # base_url('127.0.0.1:11434')
31
+ # # => #<URI::HTTP http://127.0.0.1:11434>
32
+ #
33
+ # @example Fully-qualified URL (passed through)
34
+ # base_url('https://mybox:11434/v1')
35
+ # # => #<URI::HTTPS https://mybox:11434/v1>
36
+ def base_url(spec, fallback: true)
37
+ uri = nil
38
+ begin
39
+ uri = spec.is_a?(URI) ? spec : URI.parse(spec)
40
+ rescue URI::InvalidURIError
41
+ if fallback
42
+ return base_url('http://%s' % spec, fallback: false)
43
+ else
44
+ return
45
+ end
46
+ end
47
+ case
48
+ when uri&.scheme =~ /\Ahttps?\z/
49
+ uri
50
+ when fallback
51
+ base_url('http://%s' % spec, fallback: false)
52
+ end
53
+ end
54
+ end
@@ -1,6 +1,11 @@
1
+ # Version information for the Ollama gem.
2
+ #
3
+ # This module is auto-generated by GemHadar and exposes the
4
+ # current release version as a set of constants. Do not edit it
5
+ # by hand; it is rewritten on every `rake version` invocation.
1
6
  module Ollama
2
- # Ollama version
3
- VERSION = '1.25.0'
7
+ # The current version of the Ollama gem as a String.
8
+ VERSION = '1.26.0'
4
9
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
10
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
11
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/lib/ollama.rb CHANGED
@@ -23,8 +23,10 @@ module Ollama
23
23
  end
24
24
 
25
25
  require 'ollama/handlers'
26
+ require 'ollama/base_url'
26
27
  module Ollama
27
28
  include Ollama::Handlers
29
+ extend Ollama::BaseURL
28
30
  end
29
31
 
30
32
  require 'ollama/version'
data/ollama-ruby.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ollama-ruby 1.25.0 ruby lib
2
+ # stub: ollama-ruby 1.26.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama-ruby".freeze
6
- s.version = "1.25.0".freeze
6
+ s.version = "1.26.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]
@@ -12,19 +12,19 @@ Gem::Specification.new do |s|
12
12
  s.description = "Library that allows interacting with the Ollama API".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["ollama_console".freeze, "ollama_update".freeze, "ollama_cli".freeze, "ollama_browse".freeze, "ollama_ps".freeze]
15
- s.extra_rdoc_files = ["README.md".freeze, "lib/ollama.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/configuration/config.rb".freeze, "lib/ollama/client/doc.rb".freeze, "lib/ollama/commands/blob_exists.rb".freeze, "lib/ollama/commands/chat.rb".freeze, "lib/ollama/commands/copy.rb".freeze, "lib/ollama/commands/create.rb".freeze, "lib/ollama/commands/delete.rb".freeze, "lib/ollama/commands/embed.rb".freeze, "lib/ollama/commands/embeddings.rb".freeze, "lib/ollama/commands/generate.rb".freeze, "lib/ollama/commands/ps.rb".freeze, "lib/ollama/commands/pull.rb".freeze, "lib/ollama/commands/push.rb".freeze, "lib/ollama/commands/push_blob.rb".freeze, "lib/ollama/commands/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.rb".freeze, "lib/ollama/digester.rb".freeze, "lib/ollama/dto.rb".freeze, "lib/ollama/errors.rb".freeze, "lib/ollama/handlers.rb".freeze, "lib/ollama/handlers/collector.rb".freeze, "lib/ollama/handlers/concern.rb".freeze, "lib/ollama/handlers/dump_json.rb".freeze, "lib/ollama/handlers/dump_yaml.rb".freeze, "lib/ollama/handlers/markdown.rb".freeze, "lib/ollama/handlers/nop.rb".freeze, "lib/ollama/handlers/print.rb".freeze, "lib/ollama/handlers/progress.rb".freeze, "lib/ollama/handlers/say.rb".freeze, "lib/ollama/handlers/single.rb".freeze, "lib/ollama/image.rb".freeze, "lib/ollama/json_loader.rb".freeze, "lib/ollama/message.rb".freeze, "lib/ollama/options.rb".freeze, "lib/ollama/response.rb".freeze, "lib/ollama/tool.rb".freeze, "lib/ollama/tool/function.rb".freeze, "lib/ollama/tool/function/parameters.rb".freeze, "lib/ollama/tool/function/parameters/property.rb".freeze, "lib/ollama/version.rb".freeze]
16
- s.files = [".envrc".freeze, ".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_browse".freeze, "bin/ollama_cli".freeze, "bin/ollama_console".freeze, "bin/ollama_ps".freeze, "bin/ollama_update".freeze, "lib/ollama.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/configuration/config.rb".freeze, "lib/ollama/client/doc.rb".freeze, "lib/ollama/commands/blob_exists.rb".freeze, "lib/ollama/commands/chat.rb".freeze, "lib/ollama/commands/copy.rb".freeze, "lib/ollama/commands/create.rb".freeze, "lib/ollama/commands/delete.rb".freeze, "lib/ollama/commands/embed.rb".freeze, "lib/ollama/commands/embeddings.rb".freeze, "lib/ollama/commands/generate.rb".freeze, "lib/ollama/commands/ps.rb".freeze, "lib/ollama/commands/pull.rb".freeze, "lib/ollama/commands/push.rb".freeze, "lib/ollama/commands/push_blob.rb".freeze, "lib/ollama/commands/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.rb".freeze, "lib/ollama/digester.rb".freeze, "lib/ollama/dto.rb".freeze, "lib/ollama/errors.rb".freeze, "lib/ollama/handlers.rb".freeze, "lib/ollama/handlers/collector.rb".freeze, "lib/ollama/handlers/concern.rb".freeze, "lib/ollama/handlers/dump_json.rb".freeze, "lib/ollama/handlers/dump_yaml.rb".freeze, "lib/ollama/handlers/markdown.rb".freeze, "lib/ollama/handlers/nop.rb".freeze, "lib/ollama/handlers/print.rb".freeze, "lib/ollama/handlers/progress.rb".freeze, "lib/ollama/handlers/say.rb".freeze, "lib/ollama/handlers/single.rb".freeze, "lib/ollama/image.rb".freeze, "lib/ollama/json_loader.rb".freeze, "lib/ollama/message.rb".freeze, "lib/ollama/options.rb".freeze, "lib/ollama/response.rb".freeze, "lib/ollama/tool.rb".freeze, "lib/ollama/tool/function.rb".freeze, "lib/ollama/tool/function/parameters.rb".freeze, "lib/ollama/tool/function/parameters/property.rb".freeze, "lib/ollama/version.rb".freeze, "ollama-ruby.gemspec".freeze, "spec/assets/client.json".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/options.json".freeze, "spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_spec.rb".freeze, "spec/ollama/commands/blob_exists_spec.rb".freeze, "spec/ollama/commands/chat_spec.rb".freeze, "spec/ollama/commands/copy_spec.rb".freeze, "spec/ollama/commands/create_spec.rb".freeze, "spec/ollama/commands/delete_spec.rb".freeze, "spec/ollama/commands/embed_spec.rb".freeze, "spec/ollama/commands/embeddings_spec.rb".freeze, "spec/ollama/commands/generate_spec.rb".freeze, "spec/ollama/commands/ps_spec.rb".freeze, "spec/ollama/commands/pull_spec.rb".freeze, "spec/ollama/commands/push_blob_spec.rb".freeze, "spec/ollama/commands/push_spec.rb".freeze, "spec/ollama/commands/show_spec.rb".freeze, "spec/ollama/commands/tags_spec.rb".freeze, "spec/ollama/commands/version_spec.rb".freeze, "spec/ollama/digester_spec.rb".freeze, "spec/ollama/handlers/collector_spec.rb".freeze, "spec/ollama/handlers/dump_json_spec.rb".freeze, "spec/ollama/handlers/dump_yaml_spec.rb".freeze, "spec/ollama/handlers/markdown_spec.rb".freeze, "spec/ollama/handlers/nop_spec.rb".freeze, "spec/ollama/handlers/print_spec.rb".freeze, "spec/ollama/handlers/progress_spec.rb".freeze, "spec/ollama/handlers/say_spec.rb".freeze, "spec/ollama/handlers/single_spec.rb".freeze, "spec/ollama/image_spec.rb".freeze, "spec/ollama/message_spec.rb".freeze, "spec/ollama/options_spec.rb".freeze, "spec/ollama/tool_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/ollama.rb".freeze, "lib/ollama/base_url.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/configuration/config.rb".freeze, "lib/ollama/client/doc.rb".freeze, "lib/ollama/commands/blob_exists.rb".freeze, "lib/ollama/commands/chat.rb".freeze, "lib/ollama/commands/copy.rb".freeze, "lib/ollama/commands/create.rb".freeze, "lib/ollama/commands/delete.rb".freeze, "lib/ollama/commands/embed.rb".freeze, "lib/ollama/commands/embeddings.rb".freeze, "lib/ollama/commands/generate.rb".freeze, "lib/ollama/commands/ps.rb".freeze, "lib/ollama/commands/pull.rb".freeze, "lib/ollama/commands/push.rb".freeze, "lib/ollama/commands/push_blob.rb".freeze, "lib/ollama/commands/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.rb".freeze, "lib/ollama/digester.rb".freeze, "lib/ollama/dto.rb".freeze, "lib/ollama/errors.rb".freeze, "lib/ollama/handlers.rb".freeze, "lib/ollama/handlers/collector.rb".freeze, "lib/ollama/handlers/concern.rb".freeze, "lib/ollama/handlers/dump_json.rb".freeze, "lib/ollama/handlers/dump_yaml.rb".freeze, "lib/ollama/handlers/markdown.rb".freeze, "lib/ollama/handlers/nop.rb".freeze, "lib/ollama/handlers/print.rb".freeze, "lib/ollama/handlers/progress.rb".freeze, "lib/ollama/handlers/say.rb".freeze, "lib/ollama/handlers/single.rb".freeze, "lib/ollama/image.rb".freeze, "lib/ollama/json_loader.rb".freeze, "lib/ollama/message.rb".freeze, "lib/ollama/options.rb".freeze, "lib/ollama/response.rb".freeze, "lib/ollama/tool.rb".freeze, "lib/ollama/tool/function.rb".freeze, "lib/ollama/tool/function/parameters.rb".freeze, "lib/ollama/tool/function/parameters/property.rb".freeze, "lib/ollama/version.rb".freeze]
16
+ s.files = [".envrc".freeze, ".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_browse".freeze, "bin/ollama_cli".freeze, "bin/ollama_console".freeze, "bin/ollama_ps".freeze, "bin/ollama_update".freeze, "lib/ollama.rb".freeze, "lib/ollama/base_url.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/configuration/config.rb".freeze, "lib/ollama/client/doc.rb".freeze, "lib/ollama/commands/blob_exists.rb".freeze, "lib/ollama/commands/chat.rb".freeze, "lib/ollama/commands/copy.rb".freeze, "lib/ollama/commands/create.rb".freeze, "lib/ollama/commands/delete.rb".freeze, "lib/ollama/commands/embed.rb".freeze, "lib/ollama/commands/embeddings.rb".freeze, "lib/ollama/commands/generate.rb".freeze, "lib/ollama/commands/ps.rb".freeze, "lib/ollama/commands/pull.rb".freeze, "lib/ollama/commands/push.rb".freeze, "lib/ollama/commands/push_blob.rb".freeze, "lib/ollama/commands/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.rb".freeze, "lib/ollama/digester.rb".freeze, "lib/ollama/dto.rb".freeze, "lib/ollama/errors.rb".freeze, "lib/ollama/handlers.rb".freeze, "lib/ollama/handlers/collector.rb".freeze, "lib/ollama/handlers/concern.rb".freeze, "lib/ollama/handlers/dump_json.rb".freeze, "lib/ollama/handlers/dump_yaml.rb".freeze, "lib/ollama/handlers/markdown.rb".freeze, "lib/ollama/handlers/nop.rb".freeze, "lib/ollama/handlers/print.rb".freeze, "lib/ollama/handlers/progress.rb".freeze, "lib/ollama/handlers/say.rb".freeze, "lib/ollama/handlers/single.rb".freeze, "lib/ollama/image.rb".freeze, "lib/ollama/json_loader.rb".freeze, "lib/ollama/message.rb".freeze, "lib/ollama/options.rb".freeze, "lib/ollama/response.rb".freeze, "lib/ollama/tool.rb".freeze, "lib/ollama/tool/function.rb".freeze, "lib/ollama/tool/function/parameters.rb".freeze, "lib/ollama/tool/function/parameters/property.rb".freeze, "lib/ollama/version.rb".freeze, "ollama-ruby.gemspec".freeze, "spec/assets/client.json".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/options.json".freeze, "spec/ollama/base_url_spec.rb".freeze, "spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_spec.rb".freeze, "spec/ollama/commands/blob_exists_spec.rb".freeze, "spec/ollama/commands/chat_spec.rb".freeze, "spec/ollama/commands/copy_spec.rb".freeze, "spec/ollama/commands/create_spec.rb".freeze, "spec/ollama/commands/delete_spec.rb".freeze, "spec/ollama/commands/embed_spec.rb".freeze, "spec/ollama/commands/embeddings_spec.rb".freeze, "spec/ollama/commands/generate_spec.rb".freeze, "spec/ollama/commands/ps_spec.rb".freeze, "spec/ollama/commands/pull_spec.rb".freeze, "spec/ollama/commands/push_blob_spec.rb".freeze, "spec/ollama/commands/push_spec.rb".freeze, "spec/ollama/commands/show_spec.rb".freeze, "spec/ollama/commands/tags_spec.rb".freeze, "spec/ollama/commands/version_spec.rb".freeze, "spec/ollama/digester_spec.rb".freeze, "spec/ollama/handlers/collector_spec.rb".freeze, "spec/ollama/handlers/dump_json_spec.rb".freeze, "spec/ollama/handlers/dump_yaml_spec.rb".freeze, "spec/ollama/handlers/markdown_spec.rb".freeze, "spec/ollama/handlers/nop_spec.rb".freeze, "spec/ollama/handlers/print_spec.rb".freeze, "spec/ollama/handlers/progress_spec.rb".freeze, "spec/ollama/handlers/say_spec.rb".freeze, "spec/ollama/handlers/single_spec.rb".freeze, "spec/ollama/image_spec.rb".freeze, "spec/ollama/message_spec.rb".freeze, "spec/ollama/options_spec.rb".freeze, "spec/ollama/tool_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
17
17
  s.homepage = "https://github.com/flori/ollama-ruby".freeze
18
18
  s.licenses = ["MIT".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "Ollama-ruby - Interacting with the Ollama API".freeze, "--main".freeze, "README.md".freeze]
20
20
  s.required_ruby_version = Gem::Requirement.new(">= 3.1".freeze)
21
- s.rubygems_version = "4.0.22".freeze
21
+ s.rubygems_version = "4.0.20".freeze
22
22
  s.summary = "Interacting with the Ollama API".freeze
23
- s.test_files = ["spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_spec.rb".freeze, "spec/ollama/commands/blob_exists_spec.rb".freeze, "spec/ollama/commands/chat_spec.rb".freeze, "spec/ollama/commands/copy_spec.rb".freeze, "spec/ollama/commands/create_spec.rb".freeze, "spec/ollama/commands/delete_spec.rb".freeze, "spec/ollama/commands/embed_spec.rb".freeze, "spec/ollama/commands/embeddings_spec.rb".freeze, "spec/ollama/commands/generate_spec.rb".freeze, "spec/ollama/commands/ps_spec.rb".freeze, "spec/ollama/commands/pull_spec.rb".freeze, "spec/ollama/commands/push_blob_spec.rb".freeze, "spec/ollama/commands/push_spec.rb".freeze, "spec/ollama/commands/show_spec.rb".freeze, "spec/ollama/commands/tags_spec.rb".freeze, "spec/ollama/commands/version_spec.rb".freeze, "spec/ollama/digester_spec.rb".freeze, "spec/ollama/handlers/collector_spec.rb".freeze, "spec/ollama/handlers/dump_json_spec.rb".freeze, "spec/ollama/handlers/dump_yaml_spec.rb".freeze, "spec/ollama/handlers/markdown_spec.rb".freeze, "spec/ollama/handlers/nop_spec.rb".freeze, "spec/ollama/handlers/print_spec.rb".freeze, "spec/ollama/handlers/progress_spec.rb".freeze, "spec/ollama/handlers/say_spec.rb".freeze, "spec/ollama/handlers/single_spec.rb".freeze, "spec/ollama/image_spec.rb".freeze, "spec/ollama/message_spec.rb".freeze, "spec/ollama/options_spec.rb".freeze, "spec/ollama/tool_spec.rb".freeze, "spec/spec_helper.rb".freeze]
23
+ s.test_files = ["spec/ollama/base_url_spec.rb".freeze, "spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_spec.rb".freeze, "spec/ollama/commands/blob_exists_spec.rb".freeze, "spec/ollama/commands/chat_spec.rb".freeze, "spec/ollama/commands/copy_spec.rb".freeze, "spec/ollama/commands/create_spec.rb".freeze, "spec/ollama/commands/delete_spec.rb".freeze, "spec/ollama/commands/embed_spec.rb".freeze, "spec/ollama/commands/embeddings_spec.rb".freeze, "spec/ollama/commands/generate_spec.rb".freeze, "spec/ollama/commands/ps_spec.rb".freeze, "spec/ollama/commands/pull_spec.rb".freeze, "spec/ollama/commands/push_blob_spec.rb".freeze, "spec/ollama/commands/push_spec.rb".freeze, "spec/ollama/commands/show_spec.rb".freeze, "spec/ollama/commands/tags_spec.rb".freeze, "spec/ollama/commands/version_spec.rb".freeze, "spec/ollama/digester_spec.rb".freeze, "spec/ollama/handlers/collector_spec.rb".freeze, "spec/ollama/handlers/dump_json_spec.rb".freeze, "spec/ollama/handlers/dump_yaml_spec.rb".freeze, "spec/ollama/handlers/markdown_spec.rb".freeze, "spec/ollama/handlers/nop_spec.rb".freeze, "spec/ollama/handlers/print_spec.rb".freeze, "spec/ollama/handlers/progress_spec.rb".freeze, "spec/ollama/handlers/say_spec.rb".freeze, "spec/ollama/handlers/single_spec.rb".freeze, "spec/ollama/image_spec.rb".freeze, "spec/ollama/message_spec.rb".freeze, "spec/ollama/options_spec.rb".freeze, "spec/ollama/tool_spec.rb".freeze, "spec/spec_helper.rb".freeze]
24
24
 
25
25
  s.specification_version = 4
26
26
 
27
- s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.18.0".freeze])
27
+ s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.20.1".freeze])
28
28
  s.add_development_dependency(%q<all_images>.freeze, ["~> 0.12".freeze])
29
29
  s.add_development_dependency(%q<rspec>.freeze, ["~> 3.2".freeze])
30
30
  s.add_development_dependency(%q<kramdown>.freeze, ["~> 2.0".freeze])
@@ -0,0 +1,61 @@
1
+ describe Ollama do
2
+ describe '.base_url' do
3
+ context 'with a bare host:port string' do
4
+ it 'prepends http://' do
5
+ result = Ollama.base_url('127.0.0.1:11434')
6
+ expect(result).to be_a(URI::HTTP)
7
+ expect(result.to_s).to eq('http://127.0.0.1:11434')
8
+ end
9
+
10
+ it 'works with a hostname' do
11
+ result = Ollama.base_url('localhost:11434')
12
+ expect(result.to_s).to eq('http://localhost:11434')
13
+ end
14
+ end
15
+
16
+ context 'with a fully-qualified http URL' do
17
+ it 'returns the URI unchanged' do
18
+ result = Ollama.base_url('http://127.0.0.1:11434')
19
+ expect(result).to be_a(URI::HTTP)
20
+ expect(result.to_s).to eq('http://127.0.0.1:11434')
21
+ end
22
+
23
+ it 'preserves the path' do
24
+ result = Ollama.base_url('http://127.0.0.1:11434/v1')
25
+ expect(result.to_s).to eq('http://127.0.0.1:11434/v1')
26
+ end
27
+ end
28
+
29
+ context 'with a fully-qualified https URL' do
30
+ it 'returns the URI unchanged' do
31
+ result = Ollama.base_url('https://mybox.example.com:8443/v1')
32
+ expect(result).to be_a(URI::HTTPS)
33
+ expect(result.to_s).to eq('https://mybox.example.com:8443/v1')
34
+ end
35
+ end
36
+
37
+ context 'with a URI object' do
38
+ it 'returns the same object for http' do
39
+ uri = URI.parse('http://127.0.0.1:11434')
40
+ expect(Ollama.base_url(uri)).to be(uri)
41
+ end
42
+
43
+ it 'returns the same object for https' do
44
+ uri = URI.parse('https://secure.example.com')
45
+ expect(Ollama.base_url(uri)).to be(uri)
46
+ end
47
+ end
48
+
49
+ context 'with fallback: false' do
50
+ it 'returns nil when scheme is not http(s)' do
51
+ expect(Ollama.base_url('localhost:11434', fallback: false))
52
+ .to be_nil
53
+ end
54
+
55
+ it 'still returns the URI when scheme is http' do
56
+ result = Ollama.base_url('http://127.0.0.1:11434', fallback: false)
57
+ expect(result.to_s).to eq('http://127.0.0.1:11434')
58
+ end
59
+ end
60
+ end
61
+ end
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.25.0
4
+ version: 1.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 2.18.0
18
+ version: 2.20.1
19
19
  type: :development
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 2.18.0
25
+ version: 2.20.1
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: all_images
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -265,6 +265,7 @@ extensions: []
265
265
  extra_rdoc_files:
266
266
  - README.md
267
267
  - lib/ollama.rb
268
+ - lib/ollama/base_url.rb
268
269
  - lib/ollama/client.rb
269
270
  - lib/ollama/client/command.rb
270
271
  - lib/ollama/client/configuration/config.rb
@@ -322,6 +323,7 @@ files:
322
323
  - bin/ollama_ps
323
324
  - bin/ollama_update
324
325
  - lib/ollama.rb
326
+ - lib/ollama/base_url.rb
325
327
  - lib/ollama/client.rb
326
328
  - lib/ollama/client/command.rb
327
329
  - lib/ollama/client/configuration/config.rb
@@ -369,6 +371,7 @@ files:
369
371
  - spec/assets/client.json
370
372
  - spec/assets/kitten.jpg
371
373
  - spec/assets/options.json
374
+ - spec/ollama/base_url_spec.rb
372
375
  - spec/ollama/client/doc_spec.rb
373
376
  - spec/ollama/client_spec.rb
374
377
  - spec/ollama/commands/blob_exists_spec.rb
@@ -424,10 +427,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
424
427
  - !ruby/object:Gem::Version
425
428
  version: '0'
426
429
  requirements: []
427
- rubygems_version: 4.0.22
430
+ rubygems_version: 4.0.20
428
431
  specification_version: 4
429
432
  summary: Interacting with the Ollama API
430
433
  test_files:
434
+ - spec/ollama/base_url_spec.rb
431
435
  - spec/ollama/client/doc_spec.rb
432
436
  - spec/ollama/client_spec.rb
433
437
  - spec/ollama/commands/blob_exists_spec.rb