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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/async/ollama.rb +1 -1
- data/lib/async/ollama/models.rb +2 -2
- data/lib/async/ollama/pull.rb +1 -1
- data/lib/async/ollama/transform.rb +80 -0
- data/lib/async/ollama/version.rb +2 -2
- data/lib/async/ollama.rb +2 -1
- data/license.md +1 -1
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +4 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3be9b447500c19efa6291703fffde4f69bf15843835ee407b245f32c3afb2d8
|
|
4
|
+
data.tar.gz: 58021a3c814a34f5e7a905d4fc39af14aa662bdd2fb826e8c02dd62e4ff5639d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0d8201a8e2e1692d78453addd780c662f7ac9e0e0303a27618e855850a04da9d65808bfc21b69f2d8dc9a6d79293eb6cdc01ef3ccfc32939290956c9e350a18
|
|
7
|
+
data.tar.gz: '08a238788cdcc33a79a26b9f2eaffe842392c8f9d68730b6f3b6edcd18c9c5c3e10455fcb8c6906d173510e1f97683c653501c8237233b4eba3950fd4e207d54'
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/bake/async/ollama.rb
CHANGED
data/lib/async/ollama/models.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2024-
|
|
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
|
|
15
|
+
self.value[:models].map{|model| model[:name]}
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
data/lib/async/ollama/pull.rb
CHANGED
|
@@ -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
|
data/lib/async/ollama/version.rb
CHANGED
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-
|
|
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
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.
|
|
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.
|
|
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:
|
|
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
|