ollama-ruby 1.8.1 → 1.10.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 +28 -0
- data/README.md +5 -1
- data/Rakefile +7 -2
- data/bin/ollama_browse +9 -1
- data/bin/ollama_cli +24 -0
- data/bin/ollama_console +17 -0
- data/bin/ollama_ps +127 -0
- data/bin/ollama_update +10 -0
- data/lib/ollama/commands/embed.rb +10 -4
- data/lib/ollama/version.rb +1 -1
- data/ollama-ruby.gemspec +7 -5
- data/spec/ollama/commands/embed_spec.rb +25 -0
- data/spec/ollama/handlers/say_spec.rb +6 -1
- metadata +33 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 43410ed3f73c25f595c4911157b8cda7135fe47ee25ae897845f3f5af4f52f83
|
|
4
|
+
data.tar.gz: 5b4ad79b29c61394f9b42d6d0a70cd20a03be733173d860aa26236c682611d30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a82d59d98c2f0f4230bb830fbc0327e349cd4a399ea4e9aa45423f5a5319e39ff8ba4cf8a82113225c12ba08f3c7714ddc6e26162dd66f8743a120166cfa427
|
|
7
|
+
data.tar.gz: 174b3426b0830fe6609470c412f960693ddede0a6a309aa9530f53d9a16370010839e77fdac162e8d4204b24778948f2d4df2c928af74acbe4a49664970019fd
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2025-10-20 v1.9.0
|
|
4
|
+
|
|
5
|
+
- Added `dimensions` parameter to `Ollama::Commands::Embed#initialize`
|
|
6
|
+
- Added `attr_reader :dimensions` for accessing the `dimensions` parameter
|
|
7
|
+
- Updated JSON serialization to include `dimensions` field
|
|
8
|
+
- Added specs for `dimensions` parameter instantiation and JSON conversion
|
|
9
|
+
- Parameter defaults to `nil` following same pattern as other optional params
|
|
10
|
+
- Supports truncating output embeddings to specified dimensions as per Ollama API
|
|
11
|
+
- Maintains backward compatibility with existing code
|
|
12
|
+
- Parameter type documented as `Integer, nil` in YARD comments
|
|
13
|
+
- Added new GitHub Actions workflow file `.github/workflows/static.yml`
|
|
14
|
+
- Configured workflow to deploy static content to GitHub Pages
|
|
15
|
+
- Set up Ruby environment with version **3.4** for documentation generation
|
|
16
|
+
- Added steps to install `gem_hadar`, run `bundle install`, and execute `rake doc`
|
|
17
|
+
- Updated `README.md` to include documentation link at
|
|
18
|
+
https://flori.github.io/ollama-ruby/
|
|
19
|
+
- Updated comment style guideline for `initialize` methods
|
|
20
|
+
- Skip `say` handler tests on non-macOS systems
|
|
21
|
+
- Add conditional check for `say` command availability using `File.executable?`
|
|
22
|
+
- Skip `Ollama::Handlers::Say` tests when `say` command is not found
|
|
23
|
+
- Use `skip: skip_reason` metadata to control test execution
|
|
24
|
+
- Update CI configuration
|
|
25
|
+
- Add `openssl-dev` and `ghostscript` dependencies to Dockerfile
|
|
26
|
+
- Change test command from `rake test` to `rake spec`
|
|
27
|
+
- Enable `fail_fast: true` in CI configuration
|
|
28
|
+
- Remove `rm -f Gemfile.lock` step from CI script
|
|
29
|
+
- Update `build-base` and `yaml-dev` apk packages in Dockerfile
|
|
30
|
+
|
|
3
31
|
## 2025-09-13 v1.8.1
|
|
4
32
|
|
|
5
33
|
- Added `.yardopts` and `tmp` to `package_ignore` in `Rakefile`
|
data/README.md
CHANGED
|
@@ -6,6 +6,10 @@ Ollama is a Ruby library gem that provides a client interface to interact with
|
|
|
6
6
|
an ollama server via the
|
|
7
7
|
[Ollama API](https://github.com/ollama/ollama/blob/main/docs/api.md).
|
|
8
8
|
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
Complete API documentation is available at: [GitHub.io](https://flori.github.io/ollama-ruby/)
|
|
12
|
+
|
|
9
13
|
## Installation (gem & bundler)
|
|
10
14
|
|
|
11
15
|
To install Ollama, you can use the following methods:
|
|
@@ -484,7 +488,7 @@ The homepage of this library is located at
|
|
|
484
488
|
|
|
485
489
|
## License
|
|
486
490
|
|
|
487
|
-
This software is licensed under the
|
|
491
|
+
This software is licensed under the [MIT License](./LICENSE).
|
|
488
492
|
|
|
489
493
|
---
|
|
490
494
|
|
data/Rakefile
CHANGED
|
@@ -13,14 +13,17 @@ GemHadar do
|
|
|
13
13
|
description 'Library that allows interacting with the Ollama API'
|
|
14
14
|
test_dir 'spec'
|
|
15
15
|
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.AppleDouble', '.bundle',
|
|
16
|
-
'.yardoc', 'doc', 'tags', 'errors.lst', 'cscope.out', 'coverage', 'tmp'
|
|
17
|
-
'yard'
|
|
16
|
+
'.yardoc', 'doc', 'tags', 'errors.lst', 'cscope.out', 'coverage', 'tmp'
|
|
18
17
|
package_ignore '.all_images.yml', '.tool-versions', '.gitignore', 'VERSION',
|
|
19
18
|
'.rspec', '.github', '.contexts', '.yardopts'
|
|
20
19
|
readme 'README.md'
|
|
21
20
|
|
|
22
21
|
executables << 'ollama_console' << 'ollama_update' << 'ollama_cli' << 'ollama_browse'
|
|
23
22
|
|
|
23
|
+
github_workflows(
|
|
24
|
+
'static.yml' => {}
|
|
25
|
+
)
|
|
26
|
+
|
|
24
27
|
required_ruby_version '~> 3.1'
|
|
25
28
|
|
|
26
29
|
dependency 'excon', '~> 1.0'
|
|
@@ -30,6 +33,8 @@ GemHadar do
|
|
|
30
33
|
dependency 'term-ansicolor', '~> 1.11'
|
|
31
34
|
dependency 'kramdown-ansi', '~> 0.0', '>= 0.0.1'
|
|
32
35
|
dependency 'ostruct', '~> 0.0'
|
|
36
|
+
dependency 'tabulo', '~> 3.0'
|
|
37
|
+
dependency 'nokogiri', '~> 1.0'
|
|
33
38
|
development_dependency 'all_images', '~> 0.6'
|
|
34
39
|
development_dependency 'rspec', '~> 3.2'
|
|
35
40
|
development_dependency 'kramdown', '~> 2.0'
|
data/bin/ollama_browse
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# Browse Ollama model tags and their metadata from the official registry.
|
|
4
|
+
#
|
|
5
|
+
# This script fetches and displays information about available tags for a
|
|
6
|
+
# specified Ollama model from the official Ollama library. It shows file sizes,
|
|
7
|
+
# context sizes, and hash information for each tag, making it easy to compare
|
|
8
|
+
# different model variants.
|
|
2
9
|
|
|
3
10
|
require 'term/ansicolor'
|
|
4
11
|
include Term::ANSIColor
|
|
@@ -21,7 +28,7 @@ doc = Nokogiri::HTML(body)
|
|
|
21
28
|
# They are never permitted to change the structure of this HTML…
|
|
22
29
|
css = 'section div div .group.px-4.py-3'
|
|
23
30
|
tags = (doc / css).map do |element|
|
|
24
|
-
tagged_name = (element / 'a div div div span').text
|
|
31
|
+
tagged_name = (element / 'a div div div span').first&.text
|
|
25
32
|
file_size, context_size = (element / 'p').map(&:text)
|
|
26
33
|
hash = (element / 'a .text-neutral-500 span .font-mono').text
|
|
27
34
|
[ tagged_name, file_size, context_size, hash ]
|
|
@@ -29,6 +36,7 @@ end.group_by(&:last)
|
|
|
29
36
|
|
|
30
37
|
puts bold('Model: ') + hyperlink(tags_url) { model }
|
|
31
38
|
tags.each do |hash, tagged_blobs|
|
|
39
|
+
hash = hash.strip
|
|
32
40
|
print bold(hash)
|
|
33
41
|
first_blob = true
|
|
34
42
|
tagged_blobs.each do |(tag, _), file_size, context_size|
|
data/bin/ollama_cli
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# Ollama CLI tool for interacting with Ollama models via command line.
|
|
4
|
+
#
|
|
5
|
+
# This script provides a command-line interface to communicate with Ollama
|
|
6
|
+
# models, supporting chat sessions, prompt templating, and various
|
|
7
|
+
# configuration options. It can be used for both interactive and automated
|
|
8
|
+
# model interactions.
|
|
9
|
+
#
|
|
10
|
+
# Features:
|
|
11
|
+
# - Chat sessions with model responses
|
|
12
|
+
# - Prompt templating with variable substitution
|
|
13
|
+
# - Streaming and thinking modes
|
|
14
|
+
# - Configuration via environment variables or command-line options
|
|
15
|
+
# - JSON-based chat history persistence
|
|
16
|
+
#
|
|
17
|
+
# Environment Variables:
|
|
18
|
+
# - OLLAMA_URL: Base URL for Ollama server (default: 'http://localhost')
|
|
19
|
+
# - OLLAMA_HOST: Hostname for Ollama server (used when OLLAMA_URL not set)
|
|
20
|
+
# - OLLAMA_CLIENT: JSON configuration for client
|
|
21
|
+
# - OLLAMA_MODEL: Default model to use (default: 'llama3.1')
|
|
22
|
+
# - OLLAMA_MODEL_OPTIONS: JSON model options
|
|
23
|
+
# - OLLAMA_SYSTEM: Default system prompt
|
|
24
|
+
# - OLLAMA_PROMPT: Default user prompt
|
|
25
|
+
# - DEBUG: Set to 1 for verbose output
|
|
2
26
|
|
|
3
27
|
require 'ollama'
|
|
4
28
|
include Ollama
|
data/bin/ollama_console
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# A console interface for interacting with the Ollama API.
|
|
4
|
+
#
|
|
5
|
+
# This script provides an interactive Ruby console (IRB) pre-configured with an
|
|
6
|
+
# Ollama client instance, enabling direct experimentation with the Ollama API.
|
|
7
|
+
# It automatically loads the Ollama client with the appropriate base URL, which
|
|
8
|
+
# can be configured via environment variables.
|
|
9
|
+
#
|
|
10
|
+
# Environment Variables:
|
|
11
|
+
# - OLLAMA_URL: The base URL of the Ollama API server (e.g., 'http://localhost:11434').
|
|
12
|
+
# - OLLAMA_HOST: Fallback host for constructing the base URL if OLLAMA_URL is not set.
|
|
13
|
+
#
|
|
14
|
+
# The script will:
|
|
15
|
+
# - Initialize an Ollama client with the configured base URL
|
|
16
|
+
# - Start an IRB session with the client available as the `ollama` variable
|
|
17
|
+
# - Display version and connection information
|
|
18
|
+
# - Show available API methods via `ollama.help`
|
|
2
19
|
|
|
3
20
|
require 'ollama'
|
|
4
21
|
include Ollama
|
data/bin/ollama_ps
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# A utility script that displays information about running Ollama models in a
|
|
4
|
+
# formatted table.
|
|
5
|
+
#
|
|
6
|
+
# This script queries the Ollama API's /api/ps endpoint and presents running
|
|
7
|
+
# models with detailed information including:
|
|
8
|
+
#
|
|
9
|
+
# * Model name and ID
|
|
10
|
+
# * Memory usage (size and processor allocation)
|
|
11
|
+
# * Context window length
|
|
12
|
+
# * Parameter count and quantization level
|
|
13
|
+
# * Time until expiration
|
|
14
|
+
#
|
|
15
|
+
# == Usage
|
|
16
|
+
#
|
|
17
|
+
# ollama_ps
|
|
18
|
+
#
|
|
19
|
+
# The script uses the OLLAMA_URL environment variable for the API endpoint,
|
|
20
|
+
# defaulting to 'http://' + OLLAMA_HOST if not set.
|
|
21
|
+
#
|
|
22
|
+
# == Output
|
|
23
|
+
#
|
|
24
|
+
# Displays a formatted table with columns:
|
|
25
|
+
# * NAME - Model name
|
|
26
|
+
# * ID - Truncated model digest
|
|
27
|
+
# * SIZE - Human-readable model size
|
|
28
|
+
# * PROCESSOR - CPU/GPU allocation percentage
|
|
29
|
+
# * CONTEXT - Context window size
|
|
30
|
+
# * PARAMS - Parameter count (e.g., 30.5B, 23M)
|
|
31
|
+
# * QUANT - Quantization level (e.g., Q4_K_M, F16)
|
|
32
|
+
# * UNTIL - Time until model expiration
|
|
33
|
+
|
|
34
|
+
require 'ollama'
|
|
35
|
+
include Ollama
|
|
36
|
+
require 'tabulo'
|
|
37
|
+
|
|
38
|
+
# The base_url method returns the Ollama API base URL.
|
|
39
|
+
#
|
|
40
|
+
# It first checks for the OLLAMA_URL environment variable.
|
|
41
|
+
# If not set, it defaults to 'http://' followed by the OLLAMA_HOST environment
|
|
42
|
+
# variable.
|
|
43
|
+
#
|
|
44
|
+
# @return [ String ] the base URL for the Ollama API
|
|
45
|
+
def base_url
|
|
46
|
+
ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The format_bytes method formats a number of bytes into a human-readable
|
|
50
|
+
# string with units.
|
|
51
|
+
#
|
|
52
|
+
# @param bytes [ Integer ] the number of bytes to format
|
|
53
|
+
#
|
|
54
|
+
# @return [ String ] a formatted string representing the byte value with
|
|
55
|
+
# appropriate units
|
|
56
|
+
def format_bytes(bytes)
|
|
57
|
+
Tins::Unit.format(bytes, format: '%.2f %U', unit: ?B)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The format_expiry method converts an expiration time into a formatted
|
|
61
|
+
# duration string.
|
|
62
|
+
#
|
|
63
|
+
# This method takes an expiration timestamp, calculates the time difference
|
|
64
|
+
# from the current time, and formats it into a human-readable duration string
|
|
65
|
+
# showing days, hours, minutes, and seconds.
|
|
66
|
+
#
|
|
67
|
+
# @param expires_at [ String ] the expiration timestamp to be formatted
|
|
68
|
+
#
|
|
69
|
+
# @return [ String ] a formatted duration string representing the time until
|
|
70
|
+
# expiration
|
|
71
|
+
def format_expiry(expires_at)
|
|
72
|
+
Tins::Duration.new(Time.parse(expires_at) - Time.now).format('%S%d+%h:%m:%s')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# The format_processor method computes a CPU/GPU usage string based on memory
|
|
76
|
+
# sizes.
|
|
77
|
+
#
|
|
78
|
+
# This method takes two memory size parameters and calculates the percentage of
|
|
79
|
+
# GPU and CPU usage, returning a formatted string that indicates the
|
|
80
|
+
# distribution of resources. It handles special cases where all memory is on
|
|
81
|
+
# GPU or CPU, and calculates the percentage for mixed scenarios.
|
|
82
|
+
#
|
|
83
|
+
# @param size_vram [ Integer ] the amount of VRAM allocated
|
|
84
|
+
# @param size_total [ Integer ] the total amount of memory available
|
|
85
|
+
#
|
|
86
|
+
# @return [ String ] a formatted string indicating CPU/GPU usage percentage
|
|
87
|
+
# or special cases like "100% GPU" or "100% CPU"
|
|
88
|
+
def format_processor(size_vram, size_total)
|
|
89
|
+
if size_vram == size_total
|
|
90
|
+
"100% GPU"
|
|
91
|
+
elsif size_vram == 0
|
|
92
|
+
"100% CPU"
|
|
93
|
+
else
|
|
94
|
+
cpu_percent = ((size_total - size_vram) * 100.0 / size_total).round(0)
|
|
95
|
+
gpu_percent = 100 - cpu_percent
|
|
96
|
+
"#{cpu_percent}%/#{gpu_percent}% CPU/GPU"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# The ps method retrieves and displays information about running models in a
|
|
101
|
+
# formatted table.
|
|
102
|
+
#
|
|
103
|
+
# This method creates a new Ollama client instance, fetches the list of running
|
|
104
|
+
# models, and presents the information in a structured table format showing
|
|
105
|
+
# model details such as name, ID, size, processor information, context length,
|
|
106
|
+
# parameters, quantization level, and expiration time.
|
|
107
|
+
#
|
|
108
|
+
# @param base_url [ String, nil ] the base URL of the Ollama API endpoint, defaults to nil
|
|
109
|
+
def ps
|
|
110
|
+
ollama = Client.new(base_url:)
|
|
111
|
+
result = ollama.ps
|
|
112
|
+
models = result.models
|
|
113
|
+
|
|
114
|
+
table = Tabulo::Table.new(models, border: :modern) do |t|
|
|
115
|
+
t.add_column("NAME", &:name)
|
|
116
|
+
t.add_column("ID") { |model| model.digest[0, 12] }
|
|
117
|
+
t.add_column("SIZE", align_body: :right) { |model| format_bytes(model.size) }
|
|
118
|
+
t.add_column("PROCESSOR") { |model| format_processor(model.size_vram, model.size) }
|
|
119
|
+
t.add_column("CONTEXT") { |model| format_bytes(model.context_length) }
|
|
120
|
+
t.add_column("PARAMS", align_body: :right) { |model| model.details&.parameter_size || 'n/a' }
|
|
121
|
+
t.add_column("QUANT", align_body: :right) { |model| model.details&.quantization_level || 'n/a' }
|
|
122
|
+
t.add_column("UNTIL") { |model| format_expiry(model.expires_at) }
|
|
123
|
+
end
|
|
124
|
+
puts table.pack
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
ps
|
data/bin/ollama_update
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# Updates all Ollama models to their latest versions.
|
|
4
|
+
#
|
|
5
|
+
# This script fetches all available models from the configured Ollama instance
|
|
6
|
+
# and pulls the latest version of each model. It handles errors gracefully,
|
|
7
|
+
# continuing to update remaining models even if one fails.
|
|
8
|
+
#
|
|
9
|
+
# Environment Variables:
|
|
10
|
+
# - OLLAMA_HOST: Hostname for the Ollama server (default: 'localhost')
|
|
11
|
+
# - OLLAMA_URL: Full URL for the Ollama server (overrides OLLAMA_HOST)
|
|
2
12
|
|
|
3
13
|
require 'time'
|
|
4
14
|
require 'term/ansicolor'
|
|
@@ -36,9 +36,10 @@ class Ollama::Commands::Embed
|
|
|
36
36
|
# @param options [ Ollama::Options, nil ] optional configuration parameters for the model
|
|
37
37
|
# @param truncate [ Boolean, nil ] whether to truncate the input if it exceeds context length
|
|
38
38
|
# @param keep_alive [ String, nil ] duration to keep the model loaded in memory
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
# @param dimensions [ Integer, nil ] truncates the output embedding to the specified dimension.
|
|
40
|
+
def initialize(model:, input:, options: nil, truncate: nil, keep_alive: nil, dimensions: nil)
|
|
41
|
+
@model, @input, @options, @truncate, @keep_alive, @dimensions =
|
|
42
|
+
model, input, options, truncate, keep_alive, dimensions
|
|
42
43
|
@stream = false
|
|
43
44
|
end
|
|
44
45
|
|
|
@@ -67,6 +68,12 @@ class Ollama::Commands::Embed
|
|
|
67
68
|
# @return [ String, nil ] duration to keep the model loaded in memory
|
|
68
69
|
attr_reader :keep_alive
|
|
69
70
|
|
|
71
|
+
# The dimensions attribute reader returns the dimensions associated with the
|
|
72
|
+
# object.
|
|
73
|
+
#
|
|
74
|
+
# @return [ Integer, nil ] the dimensions value stored in the instance variable
|
|
75
|
+
attr_reader :dimensions
|
|
76
|
+
|
|
70
77
|
# The stream attribute reader returns the streaming behavior setting
|
|
71
78
|
# associated with the object.
|
|
72
79
|
#
|
|
@@ -74,7 +81,6 @@ class Ollama::Commands::Embed
|
|
|
74
81
|
# streaming is enabled for the command execution (always false for embed commands)
|
|
75
82
|
attr_reader :stream
|
|
76
83
|
|
|
77
|
-
|
|
78
84
|
# The client attribute writer allows setting the client instance associated
|
|
79
85
|
# with the object.
|
|
80
86
|
#
|
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.10.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.10.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]
|
|
@@ -13,18 +13,18 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["ollama_console".freeze, "ollama_update".freeze, "ollama_cli".freeze, "ollama_browse".freeze]
|
|
15
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 = ["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]
|
|
16
|
+
s.files = ["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/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]
|
|
20
20
|
s.required_ruby_version = Gem::Requirement.new("~> 3.1".freeze)
|
|
21
|
-
s.rubygems_version = "3.
|
|
21
|
+
s.rubygems_version = "3.7.2".freeze
|
|
22
22
|
s.summary = "Interacting with the Ollama API".freeze
|
|
23
23
|
s.test_files = ["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]
|
|
24
24
|
|
|
25
25
|
s.specification_version = 4
|
|
26
26
|
|
|
27
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.
|
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.8".freeze])
|
|
28
28
|
s.add_development_dependency(%q<all_images>.freeze, ["~> 0.6".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])
|
|
@@ -39,4 +39,6 @@ Gem::Specification.new do |s|
|
|
|
39
39
|
s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.11".freeze])
|
|
40
40
|
s.add_runtime_dependency(%q<kramdown-ansi>.freeze, ["~> 0.0".freeze, ">= 0.0.1".freeze])
|
|
41
41
|
s.add_runtime_dependency(%q<ostruct>.freeze, ["~> 0.0".freeze])
|
|
42
|
+
s.add_runtime_dependency(%q<tabulo>.freeze, ["~> 3.0".freeze])
|
|
43
|
+
s.add_runtime_dependency(%q<nokogiri>.freeze, ["~> 1.0".freeze])
|
|
42
44
|
end
|
|
@@ -36,6 +36,31 @@ describe Ollama::Commands::Embed do
|
|
|
36
36
|
)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
it 'can be instantiated with dimensions' do
|
|
40
|
+
embed = described_class.new(
|
|
41
|
+
model: 'all-minilm',
|
|
42
|
+
input: 'Why is the sky blue?',
|
|
43
|
+
dimensions: 128
|
|
44
|
+
)
|
|
45
|
+
expect(embed).to be_a described_class
|
|
46
|
+
expect(embed.dimensions).to eq(128)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'can be converted to JSON with dimensions' do
|
|
50
|
+
embed = described_class.new(
|
|
51
|
+
model: 'all-minilm',
|
|
52
|
+
input: 'Why is the sky blue?',
|
|
53
|
+
dimensions: 128
|
|
54
|
+
)
|
|
55
|
+
expect(embed.as_json).to include(
|
|
56
|
+
model: 'all-minilm',
|
|
57
|
+
input: 'Why is the sky blue?',
|
|
58
|
+
dimensions: 128
|
|
59
|
+
)
|
|
60
|
+
expect(embed.to_json).to eq(
|
|
61
|
+
'{"model":"all-minilm","input":"Why is the sky blue?","dimensions":128,"stream":false}'
|
|
62
|
+
)
|
|
63
|
+
end
|
|
39
64
|
|
|
40
65
|
it 'can perform' do
|
|
41
66
|
embed = described_class.new(
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
skip_reason = nil
|
|
4
|
+
unless File.executable?(`which say`.chomp)
|
|
5
|
+
skip_reason = 'Command say not in path'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe Ollama::Handlers::Say, skip: skip_reason do
|
|
4
9
|
let :say do
|
|
5
10
|
described_class.new
|
|
6
11
|
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.10.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
|
+
version: '2.8'
|
|
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.
|
|
25
|
+
version: '2.8'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: all_images
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -225,6 +225,34 @@ dependencies:
|
|
|
225
225
|
- - "~>"
|
|
226
226
|
- !ruby/object:Gem::Version
|
|
227
227
|
version: '0.0'
|
|
228
|
+
- !ruby/object:Gem::Dependency
|
|
229
|
+
name: tabulo
|
|
230
|
+
requirement: !ruby/object:Gem::Requirement
|
|
231
|
+
requirements:
|
|
232
|
+
- - "~>"
|
|
233
|
+
- !ruby/object:Gem::Version
|
|
234
|
+
version: '3.0'
|
|
235
|
+
type: :runtime
|
|
236
|
+
prerelease: false
|
|
237
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
238
|
+
requirements:
|
|
239
|
+
- - "~>"
|
|
240
|
+
- !ruby/object:Gem::Version
|
|
241
|
+
version: '3.0'
|
|
242
|
+
- !ruby/object:Gem::Dependency
|
|
243
|
+
name: nokogiri
|
|
244
|
+
requirement: !ruby/object:Gem::Requirement
|
|
245
|
+
requirements:
|
|
246
|
+
- - "~>"
|
|
247
|
+
- !ruby/object:Gem::Version
|
|
248
|
+
version: '1.0'
|
|
249
|
+
type: :runtime
|
|
250
|
+
prerelease: false
|
|
251
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
252
|
+
requirements:
|
|
253
|
+
- - "~>"
|
|
254
|
+
- !ruby/object:Gem::Version
|
|
255
|
+
version: '1.0'
|
|
228
256
|
description: Library that allows interacting with the Ollama API
|
|
229
257
|
email: flori@ping.de
|
|
230
258
|
executables:
|
|
@@ -285,6 +313,7 @@ files:
|
|
|
285
313
|
- bin/ollama_browse
|
|
286
314
|
- bin/ollama_cli
|
|
287
315
|
- bin/ollama_console
|
|
316
|
+
- bin/ollama_ps
|
|
288
317
|
- bin/ollama_update
|
|
289
318
|
- lib/ollama.rb
|
|
290
319
|
- lib/ollama/client.rb
|
|
@@ -383,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
383
412
|
- !ruby/object:Gem::Version
|
|
384
413
|
version: '0'
|
|
385
414
|
requirements: []
|
|
386
|
-
rubygems_version: 3.
|
|
415
|
+
rubygems_version: 3.7.2
|
|
387
416
|
specification_version: 4
|
|
388
417
|
summary: Interacting with the Ollama API
|
|
389
418
|
test_files:
|