Class: LLM::Repl::Status Private
- Inherits:
-
Object
- Object
- LLM::Repl::Status
- Defined in:
- lib/llm/repl/status.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The LLM::Repl::Status class stores the small status line shown at the top of the REPL.
The status text can be a plain String, a single LLM::Repl::Node (text plus curses attributes), or an Array of either. Attributes on nodes are applied when the window draws the status line.
Instance Method Summary collapse
- #context_bar ⇒ String private
- #cost ⇒ String private
- #initialize(repl) ⇒ LLM::Repl::Status constructor private
-
#nodes ⇒ Array<LLM::Repl::Node>
private
The nodes making up the status line.
- #text ⇒ String (also: #to_s) private
-
#text=(value) ⇒ Array<LLM::Repl::Node>
private
Sets the status text.
Constructor Details
#initialize(repl) ⇒ LLM::Repl::Status
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 |
# File 'lib/llm/repl/status.rb', line 17 def initialize(repl) @agent = repl.agent @provider = @agent.llm.name @nodes = [Node.new("idle")] end |
Instance Method Details
#context_bar ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/llm/repl/status.rb', line 25 def LLM::Repl::Bar.new( ## # After compaction the used context is unknown until the next # response, so the bar renders an unknown state instead of a # stale percentage. used: @agent.compacted? ? nil : @agent.usage.total_tokens, total: @agent.context_window ).to_s end |
#cost ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/llm/repl/status.rb', line 38 def cost "$#{@agent.cost}" end |
#nodes ⇒ Array<LLM::Repl::Node>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The nodes making up the status line.
68 69 70 71 72 73 74 |
# File 'lib/llm/repl/status.rb', line 68 def nodes if @agent.compacted? [Node.new("Context compacted")] else @nodes end end |
#text ⇒ String Also known as: to_s
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/llm/repl/status.rb', line 57 def text @nodes.map(&:text).join end |
#text=(value) ⇒ Array<LLM::Repl::Node>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the status text.
46 47 48 49 50 51 52 53 |
# File 'lib/llm/repl/status.rb', line 46 def text=(value) @nodes = case value when Node then [value] when Array then value.map { |node| Node === node ? node : Node.new(node) } else [Node.new(value)] end end |