mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Use websocket chat api endpoint to communicate from web app
- Use websocket library to handle setup, reconnection from web app Use react-use-websocket library to handle websocket connection and reconnection logic. Previously connection wasn't re-established on disconnects. - Send interrupt messages with ws to update research, operator trajectory Previously we were using the abort and send new POST /api/chat mechanism. But now we can use the websocket's bi-directional messaging capability to send users messages in the middle of a research, operator run. This change should 1. Allow for a faster, more interactive interruption to shift the research direction without breaking the conversation flow. As previously we were using the DB to communicate interrupts across workers, this would take time and feel sluggish on the UX. 2. Be a more robust interrupt mechanism that'll work in multi worker setups. As same worker is interacted with to send interrupt messages instead of potentially new worker receiving the POST /api/chat with the interrupt user message. On the server we're using an asyncio Queue to pass messages down from websocket api to researcher via event generator. This can be extended to pass to other iterative agents like operator.
This commit is contained in:
@@ -4542,6 +4542,11 @@ react-style-singleton@^2.2.2, react-style-singleton@^2.2.3:
|
||||
get-nonce "^1.0.0"
|
||||
tslib "^2.0.0"
|
||||
|
||||
react-use-websocket@^4.13.0:
|
||||
version "4.13.0"
|
||||
resolved "https://registry.yarnpkg.com/react-use-websocket/-/react-use-websocket-4.13.0.tgz#9db1dbac6dc8ba2fdc02a5bba06205fbf6406736"
|
||||
integrity sha512-anMuVoV//g2N76Wxqvqjjo1X48r9Np3y1/gMl7arX84tAPXdy5R7sB5lO5hvCzQRYjqXwV8XMAiEBOUbyrZFrw==
|
||||
|
||||
react@^18:
|
||||
version "18.3.1"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891"
|
||||
@@ -4894,6 +4899,7 @@ string-argv@^0.3.2:
|
||||
integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==
|
||||
|
||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
|
||||
name string-width-cjs
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
|
||||
Reference in New Issue
Block a user