Class: DebugAgent::EngineStreamHandler
- Inherits:
-
StreamHandler
- Object
- StreamHandler
- DebugAgent::EngineStreamHandler
- Defined in:
- lib/debug_agent/engine.rb
Overview
StreamHandler implementation used internally by the engine
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#had_error ⇒ Object
readonly
Returns the value of attribute had_error.
-
#tool_calls ⇒ Object
readonly
Returns the value of attribute tool_calls.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(callback) ⇒ EngineStreamHandler
constructor
A new instance of EngineStreamHandler.
- #on_complete(tool_calls, finish_reason, usage) ⇒ Object
- #on_content(chunk) ⇒ Object
- #on_error(error) ⇒ Object
Constructor Details
#initialize(callback) ⇒ EngineStreamHandler
Returns a new instance of EngineStreamHandler.
8 9 10 11 12 13 14 |
# File 'lib/debug_agent/engine.rb', line 8 def initialize(callback) @callback = callback @tool_calls = [] @usage = nil @had_error = false @content = +'' end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/debug_agent/engine.rb', line 6 def content @content end |
#had_error ⇒ Object (readonly)
Returns the value of attribute had_error.
6 7 8 |
# File 'lib/debug_agent/engine.rb', line 6 def had_error @had_error end |
#tool_calls ⇒ Object (readonly)
Returns the value of attribute tool_calls.
6 7 8 |
# File 'lib/debug_agent/engine.rb', line 6 def tool_calls @tool_calls end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
6 7 8 |
# File 'lib/debug_agent/engine.rb', line 6 def usage @usage end |
Instance Method Details
#on_complete(tool_calls, finish_reason, usage) ⇒ Object
21 22 23 24 |
# File 'lib/debug_agent/engine.rb', line 21 def on_complete(tool_calls, finish_reason, usage) @tool_calls = tool_calls @usage = usage end |
#on_content(chunk) ⇒ Object
16 17 18 19 |
# File 'lib/debug_agent/engine.rb', line 16 def on_content(chunk) @content << chunk @callback.on_content(chunk) end |
#on_error(error) ⇒ Object
26 27 28 29 |
# File 'lib/debug_agent/engine.rb', line 26 def on_error(error) @had_error = true @callback.on_error("LLM API error: #{error.}") end |