You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: app/channels/llama_bot_rails/chat_channel.rb
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,34 @@
4
4
5
5
require'json'# Ensure JSON is required if not already
6
6
7
+
# Why support both a websocket connection, (chat_channel.rb), and a non-websocket SSE connection? %>
8
+
# Rails 6 wasn’t working with our ActionCable websocket connection, so I wanted to implement SSE as well.
9
+
10
+
# We want to support a generic HTML interface that isn’t dependent on rails. (In case the Rails server goes down for whatever reason, we don’t lose access to LlamaBot).
11
+
# Why have chat_channel.rb at all?
12
+
13
+
# Because Ruby on Rails lacks good tooling to handle real-time interaction, that isn’t through ActionCable.
14
+
# For “cancel” requests. Websocket is a 2 way connection, so we can send a ‘cancel’ in.
15
+
# To support legacy LlamaPress stuff.
16
+
# We chose to implement it with ActionCable plus Async Websockets.
17
+
# But, it’s Ruby on Rails specific, and is best for UI/UX experiences.
18
+
19
+
# SSE is better for other clients that aren’t Ruby on Rails specific, and if you want to handle just a simple SSE approach.
20
+
# This does add some complexity though.
21
+
22
+
# We now have 2 different paradigms of front-end JavaScript consuming from LlamaBot
#The user is responsible for creating a custom AgentStateBuilder if they want to use a custom agent. Otherwise, we default to LlamaBotRails::AgentStateBuilder.
0 commit comments