Streaming
Using WebSockets provides the ability to stream responses back to a client in order to allow partial results for certain requests. This improves the perceived responsiveness of applications and offers a better user experience.
The WebSocket url is https://api.lingoblocks.com
.
Message Streaming
Stream a message response back to a client as it's being generated.
WebSocket URL:
https://api.lingoblocks.com
Requirements:
accessToken
: The existing access token for the session (see Authentication).socket.io-client
: WebSocket client library (see npm package).
Setup and Connection
Import
socket.io-client
to create a WebSocket connection.
Initialize socket connection.
Receiving Messages
Listen for messages on the
message
event.Filter messages by checking if the event data matches
chatbot.responseGenerated
.Process the streamed message data.
Last updated