async-ollama 0.8.0 → 0.9.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: cf57f6eea0f76d479dd4775772fe20d43a85d70b3e06869ae842923fb9e7bb7f
4
- data.tar.gz: 18d439e6c5d24af612d67deaf2221b83485b401c8a39f2e49fe96c4540fe0829
3
+ metadata.gz: e3be9b447500c19efa6291703fffde4f69bf15843835ee407b245f32c3afb2d8
4
+ data.tar.gz: 58021a3c814a34f5e7a905d4fc39af14aa662bdd2fb826e8c02dd62e4ff5639d
5
5
  SHA512:
6
- metadata.gz: 9742560a8fc515088f6a9e15008892e001d84b0fb439af817a2a78885a9cfed4ef969ac73801e942e2bf6e830b2c844207f80a4a1af2889218207f0aa516ebf2
7
- data.tar.gz: 8a9d307856bfdf9bf883222a036f505e2e43f1dda370b7231ad84ffd2d5e2f1db8e03c3ddf488198b295e2254a1979b712fe966d9e82774775ebe11c5e4e149f
6
+ metadata.gz: c0d8201a8e2e1692d78453addd780c662f7ac9e0e0303a27618e855850a04da9d65808bfc21b69f2d8dc9a6d79293eb6cdc01ef3ccfc32939290956c9e350a18
7
+ data.tar.gz: '08a238788cdcc33a79a26b9f2eaffe842392c8f9d68730b6f3b6edcd18c9c5c3e10455fcb8c6906d173510e1f97683c653501c8237233b4eba3950fd4e207d54'
checksums.yaml.gz.sig CHANGED
Binary file
data/bake/async/ollama.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  def initialize(...)
7
7
  super
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024-2025, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  require "async/rest/representation"
7
7
  require_relative "wrapper"
@@ -12,7 +12,7 @@ module Async
12
12
  class Models < Async::REST::Representation[Wrapper]
13
13
  # @returns [Array(String)] The list of model names.
14
14
  def names
15
- self.value[:models].map {|model| model[:name]}
15
+ self.value[:models].map{|model| model[:name]}
16
16
  end
17
17
  end
18
18
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024-2025, by Samuel Williams.
4
+ # Copyright, 2025-2026, by Samuel Williams.
5
5
 
6
6
  require "async/rest/representation"
7
7
  require_relative "wrapper"
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
6
+ require_relative "client"
7
+
8
+ module Async
9
+ module Ollama
10
+ # Transforms file content using a local Ollama model.
11
+ #
12
+ # Useful for intelligently merging template changes into existing files,
13
+ # without overwriting user modifications.
14
+ #
15
+ # @example Transform a bake.rb to add missing release hooks:
16
+ # new_content = Async::Ollama::Transform.call(
17
+ # File.read("bake.rb"),
18
+ # instruction: "Add the after_gem_release hooks if they are not already present.",
19
+ # template: File.read(template_path)
20
+ # )
21
+ # File.write("bake.rb", new_content)
22
+ class Transform
23
+ SYSTEM_PROMPT = <<~PROMPT
24
+ You are a precise file transformation tool.
25
+ When given a file and instructions, you output ONLY the transformed file content.
26
+ Do not add any explanation, preamble, summary of changes, or markdown code fences.
27
+ Output the raw file content exactly as it should be written to disk.
28
+ Preserve all existing content unless the instructions explicitly require removal.
29
+ If a reference template is provided, use it as a structural guide for what to add or how to format new content — do not copy it verbatim or replace existing content with it.
30
+ PROMPT
31
+
32
+ # @parameter model [String] The Ollama model to use.
33
+ def initialize(model: MODEL)
34
+ @model = model
35
+ end
36
+
37
+ # Transform file content according to the given instruction.
38
+ #
39
+ # @parameter content [String] The current file content.
40
+ # @parameter instruction [String] What change to make.
41
+ # @parameter template [String | nil] An optional reference example showing the desired structure.
42
+ # @returns [String] The transformed file content.
43
+ def call(content, instruction:, template: nil)
44
+ messages = [
45
+ {role: "system", content: SYSTEM_PROMPT},
46
+ {role: "user", content: build_prompt(content, instruction, template)}
47
+ ]
48
+
49
+ Client.open do |client|
50
+ reply = client.chat(messages, model: @model)
51
+
52
+ reply.response
53
+ end
54
+ end
55
+
56
+ # Convenience class method.
57
+ #
58
+ # @parameter content [String] The current file content.
59
+ # @parameter options [Hash] Keyword arguments forwarded to {#call}.
60
+ # @returns [String] The transformed file content.
61
+ def self.call(content, **options)
62
+ new.call(content, **options)
63
+ end
64
+
65
+ private
66
+
67
+ def build_prompt(content, instruction, template = nil)
68
+ parts = []
69
+ parts << "## Current file\n\n```\n#{content}\n```"
70
+ parts << "## Change requested\n\n#{instruction}"
71
+
72
+ if template
73
+ parts << "## Reference template\n\n```\n#{template}\n```"
74
+ end
75
+
76
+ parts.join("\n\n")
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  module Async
7
7
  module Ollama
8
- VERSION = "0.8.0"
8
+ VERSION = "0.9.0"
9
9
  end
10
10
  end
data/lib/async/ollama.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024-2025, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "ollama/version"
7
7
  require_relative "ollama/client"
8
8
 
9
9
  require_relative "ollama/conversation"
10
+ require_relative "ollama/transform"
10
11
 
11
12
  # @namespace
12
13
  module Async
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2024-2025, by Samuel Williams.
3
+ Copyright, 2024-2026, by Samuel Williams.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -14,6 +14,10 @@ Please see the [project documentation](https://socketry.github.io/async-ollama/)
14
14
 
15
15
  Please see the [project releases](https://socketry.github.io/async-ollama/releases/index) for all releases.
16
16
 
17
+ ### v0.9.0
18
+
19
+ - Add `Async::Ollama::Transform` for intelligent code transformations using Ollama models. This can be used to implement features like automatic code updates based on instructions, while preserving user modifications and existing content.
20
+
17
21
  ### v0.5.0
18
22
 
19
23
  - Add `Async::Ollama::Conversation` for interactive real-time conversations. Includes support for summarization of chat history for large conversations.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.9.0
4
+
5
+ - Add `Async::Ollama::Transform` for intelligent code transformations using Ollama models. This can be used to implement features like automatic code updates based on instructions, while preserving user modifications and existing content.
6
+
3
7
  ## v0.5.0
4
8
 
5
9
  - Add `Async::Ollama::Conversation` for interactive real-time conversations. Includes support for summarization of chat history for large conversations.
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -79,6 +79,7 @@ files:
79
79
  - lib/async/ollama/models.rb
80
80
  - lib/async/ollama/pull.rb
81
81
  - lib/async/ollama/toolbox.rb
82
+ - lib/async/ollama/transform.rb
82
83
  - lib/async/ollama/version.rb
83
84
  - lib/async/ollama/wrapper.rb
84
85
  - license.md
@@ -97,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
98
  requirements:
98
99
  - - ">="
99
100
  - !ruby/object:Gem::Version
100
- version: '3.2'
101
+ version: '3.3'
101
102
  required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubygems_version: 3.6.7
108
+ rubygems_version: 4.0.3
108
109
  specification_version: 4
109
110
  summary: A asynchronous interface to the ollama chat service
110
111
  test_files: []
metadata.gz.sig CHANGED
Binary file