Class: TokenReel::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/token_reel/config.rb

Overview

All the knobs that control a render. Build one directly, or via TokenReel::CLI.parse(ARGV).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/token_reel/config.rb', line 14

def initialize
  @prompt         = ""
  @response       = ""
  @reasoning      = ""      # optional; shown streaming during the "thinking" pause, then replaced by the response
  @tps            = 8.0     # response tokens revealed per second
  @ttft           = 0.6     # seconds of "thinking" before first token
  @prompt_tps     = 0       # 0 = prompt appears instantly, fully typed
  @reasoning_tps  = 0       # 0 = same rate as tps
  @unit           = :word   # :word or :char
  @cols           = 80      # console width, in characters (classic terminal default: 80x25)
  @rows           = 25      # console height, in lines -- once content grows past this, the
                             # window scrolls (oldest lines drop off the top), like a real terminal
  @font           = nil     # nil = auto-detect an available monospace font, see Fonts
  @font_size      = 20
  @fps            = 12
  @theme          = :dark
  @hold           = 1.5     # seconds to hold the final frame
  @loop_count     = 0       # 0 = loop forever
  @label          = "\u276F " # "❯ "
  @thinking_label = "thinking"
  @title          = "assistant"
  @cursor_char    = "\u258A" # "▊"
  @out            = "token_reel.gif"
  @keep_frames    = false
end

Instance Attribute Details

#colsObject

Returns the value of attribute cols.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def cols
  @cols
end

#cursor_charObject

Returns the value of attribute cursor_char.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def cursor_char
  @cursor_char
end

#fontObject

Returns the value of attribute font.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def font
  @font
end

#font_sizeObject

Returns the value of attribute font_size.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def font_size
  @font_size
end

#fpsObject

Returns the value of attribute fps.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def fps
  @fps
end

#holdObject

Returns the value of attribute hold.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def hold
  @hold
end

#keep_framesObject

Returns the value of attribute keep_frames.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def keep_frames
  @keep_frames
end

#labelObject

Returns the value of attribute label.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def label
  @label
end

#loop_countObject

Returns the value of attribute loop_count.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def loop_count
  @loop_count
end

#outObject

Returns the value of attribute out.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def out
  @out
end

#promptObject

Returns the value of attribute prompt.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def prompt
  @prompt
end

#prompt_tpsObject

Returns the value of attribute prompt_tps.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def prompt_tps
  @prompt_tps
end

#reasoningObject

Returns the value of attribute reasoning.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def reasoning
  @reasoning
end

#reasoning_tpsObject

Returns the value of attribute reasoning_tps.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def reasoning_tps
  @reasoning_tps
end

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def response
  @response
end

#rowsObject

Returns the value of attribute rows.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def rows
  @rows
end

#themeObject

Returns the value of attribute theme.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def theme
  @theme
end

#thinking_labelObject

Returns the value of attribute thinking_label.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def thinking_label
  @thinking_label
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def title
  @title
end

#tpsObject

Returns the value of attribute tps.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def tps
  @tps
end

#ttftObject

Returns the value of attribute ttft.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def ttft
  @ttft
end

#unitObject

Returns the value of attribute unit.



7
8
9
# File 'lib/token_reel/config.rb', line 7

def unit
  @unit
end

Instance Method Details

#validate!Object

Raises:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/token_reel/config.rb', line 40

def validate!
  raise ConfigError, "prompt can't be blank" if prompt.to_s.empty?
  raise ConfigError, "response can't be blank" if response.to_s.empty?
  raise ConfigError, "tps must be > 0" unless tps.to_f.positive?
  raise ConfigError, "ttft can't be negative" if ttft.to_f.negative?
  raise ConfigError, "prompt_tps can't be negative" if prompt_tps.to_f.negative?
  raise ConfigError, "reasoning_tps can't be negative" if reasoning_tps.to_f.negative?
  raise ConfigError, "cols must be >= 20" if cols.to_i < 20
  raise ConfigError, "rows must be >= 3" if rows.to_i < 3
  raise ConfigError, "fps must be between 1 and 50" unless (1..50).cover?(fps.to_i)
  raise ConfigError, "font_size must be >= 8" if font_size.to_i < 8
  raise ConfigError, "hold can't be negative" if hold.to_f.negative?

  self
end