Class: Ollama::Handlers::Print

Inherits:
Object
  • Object
show all
Includes:
Concern
Defined in:
lib/ollama/handlers/print.rb

Instance Attribute Summary

Attributes included from Concern

#output, #result

Instance Method Summary collapse

Methods included from Concern

#to_proc

Constructor Details

#initialize(output: $stdout) ⇒ Print

Returns a new instance of Print.



4
5
6
7
# File 'lib/ollama/handlers/print.rb', line 4

def initialize(output: $stdout)
  super
  @output.sync = true
end

Instance Method Details

#call(response) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/ollama/handlers/print.rb', line 9

def call(response)
  if content = response.response || response.message&.content
    @output.print content
  end
  response.done and @output.puts
  self
end