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_retry(ex, attempt) ⇒ 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 24 |
# File 'lib/llm/repl/stream.rb', line 18 def initialize(repl, queue) @repl = repl @agent = @repl.agent @_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
62 63 64 |
# File 'lib/llm/repl/stream.rb', line 62 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.
30 31 32 33 |
# File 'lib/llm/repl/stream.rb', line 30 def on_content(chars) @buffer << chars @_queue.push [:stream, @buffer] end |
#on_retry(ex, attempt) ⇒ 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.
47 48 49 |
# File 'lib/llm/repl/stream.rb', line 47 def on_retry(ex, attempt) @_queue.push [:status, retry_error(ex, attempt)] 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.
38 39 40 41 |
# File 'lib/llm/repl/stream.rb', line 38 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.
55 56 57 |
# File 'lib/llm/repl/stream.rb', line 55 def on_tool_return(tool, result) @tools.delete(tool.name) end |