Class: Relay::Routes::Websocket::Stream
- Inherits:
-
LLM::Stream
- Object
- LLM::Stream
- Relay::Routes::Websocket::Stream
- Defined in:
- app/routes/websocket/stream.rb
Instance Method Summary collapse
-
#initialize(conn, sock) ⇒ Stream
constructor
A new instance of Stream.
-
#on_compaction(ctx, compactor) ⇒ void
Reports compaction start in the chat status bar.
-
#on_compaction_finish(ctx, compactor) ⇒ void
Reports compaction completion with refreshed usage details.
-
#on_content(chunk) ⇒ void
Writes a streamed text chunk.
-
#on_tool_call(tool, error) ⇒ void
On tool call.
Constructor Details
#initialize(conn, sock) ⇒ Stream
Returns a new instance of Stream.
10 11 12 13 |
# File 'app/routes/websocket/stream.rb', line 10 def initialize(conn, sock) @conn = conn @sock = sock end |
Instance Method Details
#on_compaction(ctx, compactor) ⇒ void
This method returns an undefined value.
Reports compaction start in the chat status bar.
35 36 37 |
# File 'app/routes/websocket/stream.rb', line 35 def on_compaction(ctx, compactor) @sock.write(@conn, @sock.fragment(:status, @sock.(status: "Compacting...", ctx:))) end |
#on_compaction_finish(ctx, compactor) ⇒ void
This method returns an undefined value.
Reports compaction completion with refreshed usage details.
42 43 44 |
# File 'app/routes/websocket/stream.rb', line 42 def on_compaction_finish(ctx, compactor) @sock.write(@conn, @sock.fragment(:status, @sock.(status: "Compaction finished", ctx:))) end |
#on_content(chunk) ⇒ void
This method returns an undefined value.
Writes a streamed text chunk
20 21 22 |
# File 'app/routes/websocket/stream.rb', line 20 def on_content(chunk) @sock.stream(@conn, chunk.to_s) end |
#on_tool_call(tool, error) ⇒ void
This method returns an undefined value.
On tool call
27 28 29 30 |
# File 'app/routes/websocket/stream.rb', line 27 def on_tool_call(tool, error) @sock.report_tool_status(@conn, tool) queue << (error || tool.spawn(:task)) end |