ollama-ruby 1.3.0 → 1.4.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 +4 -4
- data/CHANGES.md +18 -0
- data/README.md +28 -5
- data/bin/ollama_browse +41 -0
- data/lib/ollama/client/configuration/config.rb +35 -0
- data/lib/ollama/client.rb +2 -0
- data/lib/ollama/json_loader.rb +6 -0
- data/lib/ollama/options.rb +3 -0
- data/lib/ollama/version.rb +1 -1
- data/ollama-ruby.gemspec +4 -4
- data/spec/assets/client.json +4 -0
- data/spec/assets/options.json +8 -0
- data/spec/ollama/client_spec.rb +21 -0
- data/spec/ollama/options_spec.rb +11 -0
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7010b648d380dea2bb5fcfd89597af4abbb37e064905dce4e393162d9896ef5
|
4
|
+
data.tar.gz: ea8df217db7e0ddd70df548820c3abc73c7efa233af56ccde171dbaa087a9a92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ac32ac4fd527aa94f11b50fe72c0d22a4d326368d2d7655d090a4af9e3fea466f478574c2c0ce2d70ef1394e7f3da8709ee5f76fdbf9672004d91850d45245d
|
7
|
+
data.tar.gz: cfe22940814d91e3755cfc0d83b662db4ff505ac7b00980915eeaa51f63ff3b06a8a240cd926dbcf798d27c558c20c768a6f19e99119497e220c1e8fd1fd30f9
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2025-07-17 v1.4.0
|
4
|
+
|
5
|
+
* **New CLI Tool**: Added `bin/ollama_browse` for exploring model tags and
|
6
|
+
metadata.
|
7
|
+
* **JSON Configuration Support**:
|
8
|
+
- Introduced `lib/ollama/json_loader.rb` to load configurations from JSON
|
9
|
+
files.
|
10
|
+
- Enhanced `Config` and `Options` classes with JSON parsing capabilities.
|
11
|
+
* **Client Customization**:
|
12
|
+
- Added `configure_with` method in `Ollama::Client` for initializing clients
|
13
|
+
using `Config` objects.
|
14
|
+
* **Documentation Updates**: Included detailed usage examples for basic setups
|
15
|
+
and configurations.
|
16
|
+
* **Testing Improvements**: Expanded test coverage for JSON file parsing and
|
17
|
+
configuration handling.
|
18
|
+
* **Output Enhancements**: Refined formatting in `ollama_browse` to display
|
19
|
+
file size and context size.
|
20
|
+
|
3
21
|
## 2025-07-06 v1.3.0
|
4
22
|
|
5
23
|
* Added toggleable streaming in Markdown handler:
|
data/README.md
CHANGED
@@ -28,18 +28,41 @@ to your Gemfile and run `bundle install` in your terminal.
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
In your own software the library can be used as shown in
|
31
|
+
In your own software the library can be used as shown in these examples:
|
32
|
+
|
33
|
+
### Basic Usage
|
32
34
|
|
33
35
|
```ruby
|
34
36
|
require 'ollama'
|
35
37
|
include Ollama
|
36
38
|
|
39
|
+
# Call directly with settings as keywords
|
37
40
|
ollama = Client.new(base_url: 'http://localhost:11434')
|
41
|
+
|
42
|
+
messages = Message.new(role: 'user', content: 'Why is the sky blue?')
|
43
|
+
ollama.chat(model: 'llama3.1', stream: true, messages:, &Print)
|
44
|
+
```
|
45
|
+
|
46
|
+
### Using Configuration Object
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
require 'ollama'
|
50
|
+
include Ollama
|
51
|
+
|
52
|
+
# Create a configuration object with desired settings
|
53
|
+
config = Client::Config[
|
54
|
+
base_url: 'http://localhost:11434',
|
55
|
+
output: $stdout,
|
56
|
+
connect_timeout: 15,
|
57
|
+
read_timeout: 300
|
58
|
+
]
|
59
|
+
# Or config = Client::Config.load_from_json('path/to/client.json')
|
60
|
+
|
61
|
+
# Initialize client using the configuration
|
62
|
+
ollama = Client.configure_with(config)
|
63
|
+
|
38
64
|
messages = Message.new(role: 'user', content: 'Why is the sky blue?')
|
39
|
-
ollama.chat(model: 'llama3.1', stream: true, messages:, &Print)
|
40
|
-
print ollama.chat(model: 'llama3.1', stream: true, messages:).lazy.map { |response|
|
41
|
-
response.message.content
|
42
|
-
}
|
65
|
+
ollama.chat(model: 'llama3.1', stream: true, messages:, &Print)
|
43
66
|
```
|
44
67
|
|
45
68
|
## Try out things in ollama\_console
|
data/bin/ollama_browse
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'term/ansicolor'
|
4
|
+
include Term::ANSIColor
|
5
|
+
require 'ollama'
|
6
|
+
include Ollama
|
7
|
+
require 'excon'
|
8
|
+
require 'nokogiri'
|
9
|
+
|
10
|
+
model = ARGV.shift or fail 'model name as first argument is required'
|
11
|
+
url_prefix = 'https://ollama.com/library'
|
12
|
+
tags_url = '%s/%s/tags' % [ url_prefix, model ]
|
13
|
+
result = Excon.get(tags_url)
|
14
|
+
if result.status >= 400
|
15
|
+
STDERR.puts 'Model %s cannot be browsed, HTTP result code %u' % [ model, result.status ]
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
body = result.body
|
19
|
+
doc = Nokogiri::HTML(body)
|
20
|
+
|
21
|
+
# They are never permitted to change the structure of this HTML…
|
22
|
+
css = 'section div div .group.px-4.py-3'
|
23
|
+
tags = (doc / css).map do |element|
|
24
|
+
tagged_name = (element / 'a div div div span').text
|
25
|
+
file_size, context_size = (element / 'p').map(&:text)
|
26
|
+
hash = (element / 'a .text-neutral-500 span .font-mono').text
|
27
|
+
[ tagged_name, file_size, context_size, hash ]
|
28
|
+
end.group_by(&:last)
|
29
|
+
|
30
|
+
puts bold('Model: ') + hyperlink(tags_url) { model }
|
31
|
+
tags.each do |hash, tagged_blobs|
|
32
|
+
print bold(hash)
|
33
|
+
first_blob = true
|
34
|
+
tagged_blobs.each do |(tag, _), file_size, context_size|
|
35
|
+
if first_blob
|
36
|
+
puts ' ' + [ file_size, context_size ] * ' '
|
37
|
+
first_blob = false
|
38
|
+
end
|
39
|
+
puts ' · ' + hyperlink('%s/%s' % [ url_prefix, tag ]) { blue(tag) }
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ollama/json_loader'
|
2
|
+
|
3
|
+
module Ollama::Client::Configuration
|
4
|
+
class Config
|
5
|
+
extend Ollama::JSONLoader
|
6
|
+
|
7
|
+
def initialize(**attributes)
|
8
|
+
attributes.each { |k, v| send("#{k}=", v) }
|
9
|
+
self.output ||= $stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.[](value)
|
13
|
+
new(**value.to_h)
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_accessor :base_url, :output, :connect_timeout, :read_timeout,
|
17
|
+
:write_timeout, :debug, :user_agent
|
18
|
+
end
|
19
|
+
|
20
|
+
extend Tins::Concern
|
21
|
+
|
22
|
+
module ClassMethods
|
23
|
+
def configure_with(config)
|
24
|
+
new(
|
25
|
+
base_url: config.base_url,
|
26
|
+
output: config.output,
|
27
|
+
connect_timeout: config.connect_timeout,
|
28
|
+
read_timeout: config.read_timeout,
|
29
|
+
write_timeout: config.write_timeout,
|
30
|
+
debug: config.debug,
|
31
|
+
user_agent: config.user_agent
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/ollama/client.rb
CHANGED
@@ -2,10 +2,12 @@ class Ollama::Client
|
|
2
2
|
end
|
3
3
|
require 'ollama/client/doc'
|
4
4
|
require 'ollama/client/command'
|
5
|
+
require 'ollama/client/configuration/config'
|
5
6
|
|
6
7
|
class Ollama::Client
|
7
8
|
include Tins::Annotate
|
8
9
|
include Ollama::Handlers
|
10
|
+
include Ollama::Client::Configuration
|
9
11
|
include Ollama::Client::Command
|
10
12
|
|
11
13
|
annotate :doc
|
data/lib/ollama/options.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
require 'ollama/json_loader'
|
2
|
+
|
1
3
|
# Options are explained in the parameters for the modelfile:
|
2
4
|
# https://github.com/ollama/ollama/blob/main/docs/modelfile.md#parameter
|
3
5
|
class Ollama::Options
|
4
6
|
include Ollama::DTO
|
7
|
+
extend Ollama::JSONLoader
|
5
8
|
|
6
9
|
@@types = {
|
7
10
|
numa: [ false, true ],
|
data/lib/ollama/version.rb
CHANGED
data/ollama-ruby.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: ollama-ruby 1.
|
2
|
+
# stub: ollama-ruby 1.4.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ollama-ruby".freeze
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.4.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,8 +12,8 @@ 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]
|
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/doc.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/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.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/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 = [".yardopts".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_cli".freeze, "bin/ollama_console".freeze, "bin/ollama_update".freeze, "lib/ollama.rb".freeze, "lib/ollama/client.rb".freeze, "lib/ollama/client/command.rb".freeze, "lib/ollama/client/doc.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/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.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/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/kitten.jpg".freeze, "spec/ollama/client/doc_spec.rb".freeze, "spec/ollama/client_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_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/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/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/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/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.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 = [".yardopts".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_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/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/show.rb".freeze, "lib/ollama/commands/tags.rb".freeze, "lib/ollama/commands/version.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/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_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/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]
|
data/spec/ollama/client_spec.rb
CHANGED
@@ -13,6 +13,27 @@ RSpec.describe Ollama::Client do
|
|
13
13
|
expect(ollama).to be_a described_class
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'can be instantiated with config' do
|
17
|
+
config = Ollama::Client::Config[base_url: base_url]
|
18
|
+
client = described_class.configure_with(config)
|
19
|
+
expect(client).to be_a described_class
|
20
|
+
expect(client.base_url.to_s).to eq base_url
|
21
|
+
expect(client.output).to be $stdout
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'can be instantiated with config loaded from JSON' do
|
25
|
+
config = Ollama::Client::Config.load_from_json(asset('client.json'))
|
26
|
+
config.base_url = base_url
|
27
|
+
expect(config.read_timeout).to eq 3_600
|
28
|
+
expect(config.connect_timeout).to eq 60
|
29
|
+
client = described_class.configure_with(config)
|
30
|
+
expect(client).to be_a described_class
|
31
|
+
expect(client.base_url.to_s).to eq base_url
|
32
|
+
expect(client.output).to be $stdout
|
33
|
+
expect(client.instance_variable_get(:@connect_timeout)).to eq 60
|
34
|
+
expect(client.instance_variable_get(:@read_timeout)).to eq 3_600
|
35
|
+
end
|
36
|
+
|
16
37
|
it 'can be configured via environment variable' do
|
17
38
|
expect { described_class.new }.to raise_error(ArgumentError)
|
18
39
|
ENV['OLLAMA_URL'] = base_url
|
data/spec/ollama/options_spec.rb
CHANGED
@@ -13,6 +13,17 @@ RSpec.describe Ollama::Options do
|
|
13
13
|
expect(options).to be_a described_class
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'can be configured by loading from JSON' do
|
17
|
+
options = described_class.load_from_json(asset('options.json'))
|
18
|
+
expect(options).to be_a described_class
|
19
|
+
expect(options.num_ctx).to eq(16384)
|
20
|
+
expect(options.seed).to eq(-1)
|
21
|
+
expect(options.num_predict).to eq(1024)
|
22
|
+
expect(options.temperature).to be_within(1E-6).of(0.666)
|
23
|
+
expect(options.top_p).to be_within(0.001).of(0.95)
|
24
|
+
expect(options.min_p).to be_within(0.001).of(0.1)
|
25
|
+
end
|
26
|
+
|
16
27
|
it 'can be empty' do
|
17
28
|
expect(described_class.new).to be_empty
|
18
29
|
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.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -223,6 +223,7 @@ extra_rdoc_files:
|
|
223
223
|
- lib/ollama.rb
|
224
224
|
- lib/ollama/client.rb
|
225
225
|
- lib/ollama/client/command.rb
|
226
|
+
- lib/ollama/client/configuration/config.rb
|
226
227
|
- lib/ollama/client/doc.rb
|
227
228
|
- lib/ollama/commands/chat.rb
|
228
229
|
- lib/ollama/commands/copy.rb
|
@@ -251,6 +252,7 @@ extra_rdoc_files:
|
|
251
252
|
- lib/ollama/handlers/say.rb
|
252
253
|
- lib/ollama/handlers/single.rb
|
253
254
|
- lib/ollama/image.rb
|
255
|
+
- lib/ollama/json_loader.rb
|
254
256
|
- lib/ollama/message.rb
|
255
257
|
- lib/ollama/options.rb
|
256
258
|
- lib/ollama/response.rb
|
@@ -266,12 +268,14 @@ files:
|
|
266
268
|
- LICENSE
|
267
269
|
- README.md
|
268
270
|
- Rakefile
|
271
|
+
- bin/ollama_browse
|
269
272
|
- bin/ollama_cli
|
270
273
|
- bin/ollama_console
|
271
274
|
- bin/ollama_update
|
272
275
|
- lib/ollama.rb
|
273
276
|
- lib/ollama/client.rb
|
274
277
|
- lib/ollama/client/command.rb
|
278
|
+
- lib/ollama/client/configuration/config.rb
|
275
279
|
- lib/ollama/client/doc.rb
|
276
280
|
- lib/ollama/commands/chat.rb
|
277
281
|
- lib/ollama/commands/copy.rb
|
@@ -300,6 +304,7 @@ files:
|
|
300
304
|
- lib/ollama/handlers/say.rb
|
301
305
|
- lib/ollama/handlers/single.rb
|
302
306
|
- lib/ollama/image.rb
|
307
|
+
- lib/ollama/json_loader.rb
|
303
308
|
- lib/ollama/message.rb
|
304
309
|
- lib/ollama/options.rb
|
305
310
|
- lib/ollama/response.rb
|
@@ -309,7 +314,9 @@ files:
|
|
309
314
|
- lib/ollama/tool/function/parameters/property.rb
|
310
315
|
- lib/ollama/version.rb
|
311
316
|
- ollama-ruby.gemspec
|
317
|
+
- spec/assets/client.json
|
312
318
|
- spec/assets/kitten.jpg
|
319
|
+
- spec/assets/options.json
|
313
320
|
- spec/ollama/client/doc_spec.rb
|
314
321
|
- spec/ollama/client_spec.rb
|
315
322
|
- spec/ollama/commands/chat_spec.rb
|