Class: DebugAgent::SseCallback
- Inherits:
-
ChatCallback
- Object
- ChatCallback
- DebugAgent::SseCallback
- Defined in:
- lib/debug_agent/middleware.rb
Overview
SSE callback that bridges engine to SSE response lines
Instance Method Summary collapse
- #events ⇒ Object
-
#initialize ⇒ SseCallback
constructor
A new instance of SseCallback.
- #on_complete ⇒ Object
- #on_content(chunk) ⇒ Object
- #on_context_compressed(original, compressed, removed_rounds) ⇒ Object
- #on_error(message) ⇒ Object
- #on_tool_result(tool_name, result) ⇒ Object
- #on_tool_start(tool_name, args) ⇒ Object
Constructor Details
#initialize ⇒ SseCallback
Returns a new instance of SseCallback.
7 8 9 |
# File 'lib/debug_agent/middleware.rb', line 7 def initialize @events = [] end |
Instance Method Details
#events ⇒ Object
11 12 13 |
# File 'lib/debug_agent/middleware.rb', line 11 def events @events end |
#on_complete ⇒ Object
27 28 29 |
# File 'lib/debug_agent/middleware.rb', line 27 def on_complete @events << ['done', ''] end |
#on_content(chunk) ⇒ Object
15 16 17 |
# File 'lib/debug_agent/middleware.rb', line 15 def on_content(chunk) @events << ['content', JSON.generate(chunk)] end |
#on_context_compressed(original, compressed, removed_rounds) ⇒ Object
35 36 37 38 |
# File 'lib/debug_agent/middleware.rb', line 35 def on_context_compressed(original, compressed, removed_rounds) info = JSON.generate({ originalTokens: original, compressedTokens: compressed, removedRounds: removed_rounds }) @events << ['context_compressed', info] end |
#on_error(message) ⇒ Object
31 32 33 |
# File 'lib/debug_agent/middleware.rb', line 31 def on_error() @events << ['error', ] end |
#on_tool_result(tool_name, result) ⇒ Object
23 24 25 |
# File 'lib/debug_agent/middleware.rb', line 23 def on_tool_result(tool_name, result) @events << ['tool_result', "#{tool_name}: #{result}"] end |
#on_tool_start(tool_name, args) ⇒ Object
19 20 21 |
# File 'lib/debug_agent/middleware.rb', line 19 def on_tool_start(tool_name, args) @events << ['tool_start', tool_name] end |