async-ollama 0.5.1 → 0.7.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: 0a1e184fa4a7d73adb1dda49cf25837a4190a1774a92b32289845d00bfe45c6f
4
- data.tar.gz: 10de9be19b93771d181630058916310746be94155807375e8887d970da040566
3
+ metadata.gz: ea205e7dc0418f74e20575287b89c71e46e3a92322352043bea8ebb93134f629
4
+ data.tar.gz: e0254ec2f71b7e2539eee9315d0134716cd1a00494324ad3727d2f7b81129145
5
5
  SHA512:
6
- metadata.gz: 1904a23e98d954b45803b8615de72eb87faaf91c45165a4a82679b75f99d9589a9db0b095f3a2a2ea8c4eec1b1a3447c84a2c80afa9f34be967155d9c4e71179
7
- data.tar.gz: b82a1dfa1b2f1f51efaea9345065749c68546383f30ae026b27086981c2c7c4fb2e2494124bda2b0aa701ce3fb5a6a2e55e0ada92cc1c1c18f073a659108d38d
6
+ metadata.gz: 50c4ac988c537de057a6b87cf8183f40572f9fb9b3136686e75604643c4aa70e5fac398e3492053d2f10e2229d205f6ec9992fac15ac30bcc8716c0a3d429ce2
7
+ data.tar.gz: fc74eb93e1d69f1378571c47a95d9aafe53b1aa888da1091e293e915cbcfe48a138f434e00bbaf8941b8c4cb93d5ae057639b447bf6368adfe7bb5db781e7370
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
6
+ def initialize(...)
7
+ super
8
+
9
+ require "async/ollama/client"
10
+ end
11
+
12
+ def models
13
+ Async::Ollama::Client.open do |client|
14
+ client.models.names
15
+ end
16
+ end
17
+
18
+ # Pulls the specified models from the Ollama API. If no models are specified, but there is a default model, it will pull that one.
19
+ # @parameter models [Array(String)] The names of the models to pull.
20
+ def pull(models)
21
+ if models.empty?
22
+ models = [Async::Ollama::Client.default_model]
23
+ end
24
+
25
+ Async::Ollama::Client.open do |client|
26
+ models.each do |model|
27
+ client.pull(model) do |response|
28
+ response.each do |line|
29
+ puts line
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -15,6 +15,7 @@ module Async
15
15
  self.value[:message]
16
16
  end
17
17
 
18
+ # @returns [String | nil] The content of the message, or nil if not present.
18
19
  def response
19
20
  if message = self.message
20
21
  message[:content]
@@ -8,6 +8,7 @@ require "async/rest/resource"
8
8
  require_relative "generate"
9
9
  require_relative "chat"
10
10
  require_relative "models"
11
+ require_relative "pull"
11
12
 
12
13
  module Async
13
14
  module Ollama
@@ -57,6 +58,16 @@ module Async
57
58
  def models
58
59
  Models.get(self.with(path: "/api/tags"))
59
60
  end
61
+
62
+ def pull(model)
63
+ Pull.post(self.with(path: "/api/pull"), model: model) do |resource, response|
64
+ if block_given?
65
+ yield response
66
+ end
67
+
68
+ Pull.new(resource, value: response.read, metadata: response.headers)
69
+ end
70
+ end
60
71
  end
61
72
  end
62
73
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
+
6
+ require "async/rest/representation"
7
+ require_relative "wrapper"
8
+
9
+ module Async
10
+ module Ollama
11
+ # Represents the response from pulling models from the Ollama API.
12
+ class Pull < Async::REST::Representation[Wrapper]
13
+ end
14
+ end
15
+ end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Ollama
8
- VERSION = "0.5.1"
8
+ VERSION = "0.7.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-ollama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -70,12 +70,14 @@ executables: []
70
70
  extensions: []
71
71
  extra_rdoc_files: []
72
72
  files:
73
+ - bake/async/ollama.rb
73
74
  - lib/async/ollama.rb
74
75
  - lib/async/ollama/chat.rb
75
76
  - lib/async/ollama/client.rb
76
77
  - lib/async/ollama/conversation.rb
77
78
  - lib/async/ollama/generate.rb
78
79
  - lib/async/ollama/models.rb
80
+ - lib/async/ollama/pull.rb
79
81
  - lib/async/ollama/toolbox.rb
80
82
  - lib/async/ollama/version.rb
81
83
  - lib/async/ollama/wrapper.rb
metadata.gz.sig CHANGED
Binary file