ollama-ruby 0.15.0 → 0.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 +4 -4
- data/CHANGES.md +11 -0
- data/bin/ollama_cli +45 -3
- data/lib/ollama/version.rb +1 -1
- data/ollama-ruby.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96d3c8afe0962abc4938b2e2d6cea5dd773e224ac05e87f819b371429083d79d
|
4
|
+
data.tar.gz: 6e293ec73919c33eede640b9043b9adfff00f5d9761c1d2759f022016a2b6daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c11223503b8ff33ed77c0629f52ea5eb703ac8fc838b6a258e27e07eda297c66ad40ec672fccf1e5dd9e00f432754b219196114dd1bed93bacdd7760451d88db
|
7
|
+
data.tar.gz: 2d089cfaaeccced65a17dbe622ec9f621238241c25c24b6504815310e3bc157f3a7baba95747275d4300292722dc5df2a74fa6cef581a7997af65e9bd86613cb
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2025-02-17 v0.16.0
|
4
|
+
|
5
|
+
* Updated Ollama CLI with new handler that allows saving of chat and
|
6
|
+
continuation with `ollama_chat`:
|
7
|
+
* Added `require 'tins/xt/secure_write'` and `require 'tmpdir'`.
|
8
|
+
* Created a new `ChatStart` class that handles chat responses.
|
9
|
+
* Updated options parsing to use `ChatStart` as the default handler.
|
10
|
+
* Changed code to handle `ChatStart` instances.
|
11
|
+
* Added secure write functionality for chat conversation in tmpdir.
|
12
|
+
* Added `yaml-dev` to `apk add` command in `.all_images.yml`
|
13
|
+
|
3
14
|
## 2025-02-12 v0.15.0
|
4
15
|
|
5
16
|
* Added "version" command to display version of the ollama server:
|
data/bin/ollama_cli
CHANGED
@@ -4,7 +4,30 @@ require 'ollama'
|
|
4
4
|
include Ollama
|
5
5
|
require 'tins'
|
6
6
|
include Tins::GO
|
7
|
+
require 'tins/xt/secure_write'
|
7
8
|
require 'json'
|
9
|
+
require 'tmpdir'
|
10
|
+
|
11
|
+
class ChatStart
|
12
|
+
include Ollama::Handlers::Concern
|
13
|
+
|
14
|
+
def initialize(output: $stdout)
|
15
|
+
super
|
16
|
+
@output.sync = true
|
17
|
+
@content = ''
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :content
|
21
|
+
|
22
|
+
def call(response)
|
23
|
+
if content = response.response
|
24
|
+
@content << content
|
25
|
+
@output << content
|
26
|
+
end
|
27
|
+
response.done and @output.puts
|
28
|
+
self
|
29
|
+
end
|
30
|
+
end
|
8
31
|
|
9
32
|
# Returns the contents of a file or string, or a default value if neither is provided.
|
10
33
|
#
|
@@ -49,7 +72,7 @@ def usage
|
|
49
72
|
-p PROMPT the user prompt to use as a file, $OLLAMA_PROMPT
|
50
73
|
if it contains %{stdin} it is substituted by stdin input
|
51
74
|
-P VARIABLE sets prompt var %{foo} to "bar" if VARIABLE is foo=bar
|
52
|
-
-H HANDLER the handler to use for the response, defaults to
|
75
|
+
-H HANDLER the handler to use for the response, defaults to ChatStart
|
53
76
|
-S use streaming for generation
|
54
77
|
-h this help
|
55
78
|
|
@@ -57,7 +80,7 @@ def usage
|
|
57
80
|
exit 0
|
58
81
|
end
|
59
82
|
|
60
|
-
opts = go 'u:m:M:s:p:P:H:Sh', defaults: { ?H => '
|
83
|
+
opts = go 'u:m:M:s:p:P:H:Sh', defaults: { ?H => 'ChatStart', ?M => '{}' }
|
61
84
|
|
62
85
|
opts[?h] and usage
|
63
86
|
|
@@ -91,11 +114,30 @@ if ENV['DEBUG'].to_i == 1
|
|
91
114
|
EOT
|
92
115
|
end
|
93
116
|
|
117
|
+
handler = Object.const_get(opts[?H])
|
118
|
+
handler == ChatStart and handler = handler.new
|
119
|
+
|
94
120
|
Client.new(base_url:, read_timeout: 120).generate(
|
95
121
|
model:,
|
96
122
|
system:,
|
97
123
|
prompt:,
|
98
124
|
options:,
|
99
125
|
stream: !!opts[?S],
|
100
|
-
&
|
126
|
+
&handler
|
101
127
|
)
|
128
|
+
|
129
|
+
if handler.is_a?(ChatStart)
|
130
|
+
filename = File.join(Dir.tmpdir, 'chat_start_%u.json' % $$)
|
131
|
+
File.secure_write(filename) do |out|
|
132
|
+
JSON.dump(
|
133
|
+
[
|
134
|
+
Message.new(role: 'user', content: prompt),
|
135
|
+
Message.new(role: 'assistant', content: handler.content),
|
136
|
+
],
|
137
|
+
out
|
138
|
+
)
|
139
|
+
end
|
140
|
+
if STDERR.tty?
|
141
|
+
STDERR.puts "\nContinue the chat with: ollama_chat -c '%s'" % filename
|
142
|
+
end
|
143
|
+
end
|
data/lib/ollama/version.rb
CHANGED
data/ollama-ruby.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: ollama-ruby 0.
|
2
|
+
# stub: ollama-ruby 0.16.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ollama-ruby".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.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]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2025-02-
|
11
|
+
s.date = "2025-02-17"
|
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]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ollama-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-17 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: gem_hadar
|