Class: Async::Ollama::Transform
- Inherits:
-
Object
- Object
- Async::Ollama::Transform
- Defined in:
- lib/async/ollama/transform.rb
Overview
Transforms file content using a local Ollama model.
Useful for intelligently merging template changes into existing files, without overwriting user modifications.
Constant Summary collapse
- SYSTEM_PROMPT =
<<~PROMPT You are a precise file transformation tool. When given a file and instructions, you output ONLY the transformed file content. Do not add any explanation, preamble, summary of changes, or markdown code fences. Output the raw file content exactly as it should be written to disk. Preserve all existing content unless the instructions explicitly require removal. 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. PROMPT
Class Method Summary collapse
-
.call(content, **options) ⇒ Object
Convenience class method.
Instance Method Summary collapse
-
#call(content, instruction:, template: nil) ⇒ Object
Transform file content according to the given instruction.
-
#initialize(model: MODEL) ⇒ Transform
constructor
A new instance of Transform.
Constructor Details
Class Method Details
.call(content, **options) ⇒ Object
Convenience class method.
61 62 63 |
# File 'lib/async/ollama/transform.rb', line 61 def self.call(content, **) new.call(content, **) end |
Instance Method Details
#call(content, instruction:, template: nil) ⇒ Object
Transform file content according to the given instruction.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/async/ollama/transform.rb', line 43 def call(content, instruction:, template: nil) = [ {role: "system", content: SYSTEM_PROMPT}, {role: "user", content: build_prompt(content, instruction, template)} ] Client.open do |client| reply = client.chat(, model: @model) reply.response end end |