Class: LLM::Repl::Stream Private
- Inherits:
-
Stream
- Object
- Stream
- LLM::Repl::Stream
- Defined in:
- lib/llm/repl/stream.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::Stream class manages the stream for the LLM::Repl class. This class has defined hooks that receive text, tool calls, and tool returns.
Instance Method Summary collapse
-
#empty! ⇒ void
private
Empty the accumulated buffer.
- #initialize(repl, queue) ⇒ LLM::Repl::Stream constructor private
- #on_content(chars) ⇒ void private
- #on_tool_call(tool) ⇒ void private
- #on_tool_return(_tool, result) ⇒ void private
Constructor Details
#initialize(repl, queue) ⇒ LLM::Repl::Stream
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.
14 15 16 17 18 |
# File 'lib/llm/repl/stream.rb', line 14 def initialize(repl, queue) @repl = repl @_queue = queue @buffer = +"" end |
Instance Method Details
#empty! ⇒ void
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.
This method returns an undefined value.
Empty the accumulated buffer
47 48 49 |
# File 'lib/llm/repl/stream.rb', line 47 def empty! @buffer.clear end |
#on_content(chars) ⇒ void
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.
This method returns an undefined value.
24 25 26 27 |
# File 'lib/llm/repl/stream.rb', line 24 def on_content(chars) @buffer << chars @_queue.push [:stream, @buffer] end |
#on_tool_call(tool) ⇒ void
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.
This method returns an undefined value.
32 33 34 |
# File 'lib/llm/repl/stream.rb', line 32 def on_tool_call(tool) @_queue.push [:status, "#{tool.name}(#{format_args(tool)})"] end |
#on_tool_return(_tool, result) ⇒ void
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.
This method returns an undefined value.
40 41 42 |
# File 'lib/llm/repl/stream.rb', line 40 def on_tool_return(_tool, result) @_queue.push [:status, @repl.thinking_text] end |