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 Attribute Summary collapse
- #tools ⇒ Hash<Symbol, LLM::Tool> readonly private
Instance Method Summary collapse
-
#clear ⇒ void
private
Clear 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.
18 19 20 21 22 23 |
# File 'lib/llm/repl/stream.rb', line 18 def initialize(repl, queue) @repl = repl @_queue = queue @buffer = +"" @tools = {} end |
Instance Attribute Details
#tools ⇒ Hash<Symbol, LLM::Tool> (readonly)
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.
13 14 15 |
# File 'lib/llm/repl/stream.rb', line 13 def tools @tools end |
Instance Method Details
#clear ⇒ 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.
Clear the accumulated buffer
53 54 55 |
# File 'lib/llm/repl/stream.rb', line 53 def clear @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.
29 30 31 32 |
# File 'lib/llm/repl/stream.rb', line 29 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.
37 38 39 40 |
# File 'lib/llm/repl/stream.rb', line 37 def on_tool_call(tool) @tools[tool.name] = tool @_queue.push [:status, [" ", lambda, " • #{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.
46 47 48 |
# File 'lib/llm/repl/stream.rb', line 46 def on_tool_return(tool, result) @tools.delete(tool.name) end |