Class: TokenReel::Config
- Inherits:
-
Object
- Object
- TokenReel::Config
- 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
-
#cols ⇒ Object
Returns the value of attribute cols.
-
#cursor_char ⇒ Object
Returns the value of attribute cursor_char.
-
#font ⇒ Object
Returns the value of attribute font.
-
#font_size ⇒ Object
Returns the value of attribute font_size.
-
#fps ⇒ Object
Returns the value of attribute fps.
-
#hold ⇒ Object
Returns the value of attribute hold.
-
#keep_frames ⇒ Object
Returns the value of attribute keep_frames.
-
#label ⇒ Object
Returns the value of attribute label.
-
#loop_count ⇒ Object
Returns the value of attribute loop_count.
-
#out ⇒ Object
Returns the value of attribute out.
-
#prompt ⇒ Object
Returns the value of attribute prompt.
-
#prompt_tps ⇒ Object
Returns the value of attribute prompt_tps.
-
#reasoning ⇒ Object
Returns the value of attribute reasoning.
-
#reasoning_tps ⇒ Object
Returns the value of attribute reasoning_tps.
-
#response ⇒ Object
Returns the value of attribute response.
-
#rows ⇒ Object
Returns the value of attribute rows.
-
#seed ⇒ Object
Returns the value of attribute seed.
-
#theme ⇒ Object
Returns the value of attribute theme.
-
#thinking_label ⇒ Object
Returns the value of attribute thinking_label.
-
#title ⇒ Object
Returns the value of attribute title.
-
#tps ⇒ Object
Returns the value of attribute tps.
-
#ttft ⇒ Object
Returns the value of attribute ttft.
-
#unit ⇒ Object
Returns the value of attribute unit.
-
#variability ⇒ Object
Returns the value of attribute variability.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
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 40 41 |
# File 'lib/token_reel/config.rb', line 15 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 @variability = false # jitter each token's delay by a random +/-10/20/30% (normal distribution) @seed = nil # RNG seed for --variability; nil = a fresh random seed each run end |
Instance Attribute Details
#cols ⇒ Object
Returns the value of attribute cols.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def cols @cols end |
#cursor_char ⇒ Object
Returns the value of attribute cursor_char.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def cursor_char @cursor_char end |
#font ⇒ Object
Returns the value of attribute font.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def font @font end |
#font_size ⇒ Object
Returns the value of attribute font_size.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def font_size @font_size end |
#fps ⇒ Object
Returns the value of attribute fps.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def fps @fps end |
#hold ⇒ Object
Returns the value of attribute hold.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def hold @hold end |
#keep_frames ⇒ Object
Returns the value of attribute keep_frames.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def keep_frames @keep_frames end |
#label ⇒ Object
Returns the value of attribute label.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def label @label end |
#loop_count ⇒ Object
Returns the value of attribute loop_count.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def loop_count @loop_count end |
#out ⇒ Object
Returns the value of attribute out.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def out @out end |
#prompt ⇒ Object
Returns the value of attribute prompt.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def prompt @prompt end |
#prompt_tps ⇒ Object
Returns the value of attribute prompt_tps.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def prompt_tps @prompt_tps end |
#reasoning ⇒ Object
Returns the value of attribute reasoning.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def reasoning @reasoning end |
#reasoning_tps ⇒ Object
Returns the value of attribute reasoning_tps.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def reasoning_tps @reasoning_tps end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def response @response end |
#rows ⇒ Object
Returns the value of attribute rows.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def rows @rows end |
#seed ⇒ Object
Returns the value of attribute seed.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def seed @seed end |
#theme ⇒ Object
Returns the value of attribute theme.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def theme @theme end |
#thinking_label ⇒ Object
Returns the value of attribute thinking_label.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def thinking_label @thinking_label end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def title @title end |
#tps ⇒ Object
Returns the value of attribute tps.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def tps @tps end |
#ttft ⇒ Object
Returns the value of attribute ttft.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def ttft @ttft end |
#unit ⇒ Object
Returns the value of attribute unit.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def unit @unit end |
#variability ⇒ Object
Returns the value of attribute variability.
7 8 9 |
# File 'lib/token_reel/config.rb', line 7 def variability @variability end |
Instance Method Details
#validate! ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/token_reel/config.rb', line 43 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 |