Class: Relay::Routes::Websocket
- Includes:
- Hooks::RequireUser, Connection, Interrupt, Tools
- Defined in:
- app/routes/websocket.rb,
app/routes/websocket/stream.rb,
app/routes/websocket/interrupt.rb,
app/routes/websocket/connection.rb
Defined Under Namespace
Modules: Connection, Interrupt Classes: Stream
Instance Method Summary collapse
Methods included from Connection
#attachment_from_payload, #build_prompt, #dispatch, #fragment, #on_connect, #on_message, #parse_message, #pause, #request_in_flight?, #resolve_functions, #stream, #talk, #vars, #wait_with_heartbeat, #write, #yield_tools
Methods included from Interrupt
#interrupt!, #interrupt?, #on_interrupt
Methods inherited from Base
#cache, #htmx?, #params, #root
Methods included from Concerns::View
#cancellable?, #context_window, #format_cost, #format_name, #initials, #markdown, #status_bar, #theme, #theme_href
Methods included from Concerns::Roda
#initialize, #method_missing, #r, #respond_to_missing?
Methods included from Concerns::Context
#contexts, #ctx, #current_context, #default_context, #default_model, #llm, #llms, #mcps, #model, #models, #normalize_model, #provider, #sync_context!, #user, #valid_model?
Methods included from Concerns::Attachment
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Relay::Concerns::Roda
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/routes/websocket.rb', line 15 def call Async::WebSocket::Adapters::Rack.open(request.env) do |conn| context = ctx stream = Relay::Routes::Websocket::Stream.new(conn, self) params = {model: context[:model], stream:, tools: []} on_connect conn, context.llm, context, params end || upgrade_required end |
#report_tool_status(conn, tool) ⇒ Object
30 31 32 |
# File 'app/routes/websocket.rb', line 30 def report_tool_status(conn, tool) write(conn, fragment(:status, (status: tool_status([tool])))) end |
#tool_status(functions) ⇒ Object
24 25 26 27 28 |
# File 'app/routes/websocket.rb', line 24 def tool_status(functions) names = functions.filter_map(&:name).reject(&:empty?).uniq return "Running tools…" if names.empty? "Running #{names.join(", ")}…" end |