Class: Ollama::Handlers::Progress
- Inherits:
-
Object
- Object
- Ollama::Handlers::Progress
- Includes:
- Concern, Term::ANSIColor
- Defined in:
- lib/ollama/handlers/progress.rb
Instance Attribute Summary
Attributes included from Concern
Instance Method Summary collapse
- #call(response) ⇒ Object
-
#initialize(output: $stdout) ⇒ Progress
constructor
A new instance of Progress.
Methods included from Concern
Constructor Details
#initialize(output: $stdout) ⇒ Progress
Returns a new instance of Progress.
8 9 10 11 12 13 |
# File 'lib/ollama/handlers/progress.rb', line 8 def initialize(output: $stdout) super @current = 0 @total = nil @last_status = nil end |
Instance Method Details
#call(response) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ollama/handlers/progress.rb', line 15 def call(response) .display.output = @output if status = response.status .label = status end if response.total && response.completed if !@last_status or @last_status != status @last_status and .newline @last_status = status @current = 0 @total = response.total .counter.reset(total: @total, current: @current) end .counter.progress(by: response.completed - @current) @current = response.completed .update( message: (response.completed, response.total), force: true ) end if error = response.error .puts bold { "Error: " } + red { error } end self end |