Merge pull request #858 from khoj-ai/use-sse-instead-of-websocket

Use Single HTTP API for Robust, Generalizable Chat Streaming
This commit is contained in:
sabaimran
2024-07-26 07:11:54 -07:00
committed by GitHub
17 changed files with 996 additions and 1261 deletions

View File

@@ -67,10 +67,8 @@ def test_chat_with_online_content(client_offline_chat):
# Act
q = "/online give me the link to paul graham's essay how to do great work"
encoded_q = quote(q, safe="")
response = client_offline_chat.get(f"/api/chat?q={encoded_q}&stream=true")
response_message = response.content.decode("utf-8")
response_message = response_message.split("### compiled references")[0]
response = client_offline_chat.get(f"/api/chat?q={encoded_q}")
response_message = response.json()["response"]
# Assert
expected_responses = [
@@ -91,10 +89,8 @@ def test_chat_with_online_webpage_content(client_offline_chat):
# Act
q = "/online how many firefighters were involved in the great chicago fire and which year did it take place?"
encoded_q = quote(q, safe="")
response = client_offline_chat.get(f"/api/chat?q={encoded_q}&stream=true")
response_message = response.content.decode("utf-8")
response_message = response_message.split("### compiled references")[0]
response = client_offline_chat.get(f"/api/chat?q={encoded_q}")
response_message = response.json()["response"]
# Assert
expected_responses = ["185", "1871", "horse"]