Update api/utils.py
Browse files- api/utils.py +2 -2
api/utils.py
CHANGED
@@ -102,7 +102,7 @@ async def process_streaming_response(request: ChatRequest):
|
|
102 |
async for line in response.aiter_lines():
|
103 |
timestamp = int(datetime.now().timestamp())
|
104 |
if line:
|
105 |
-
content = line + "\n"
|
106 |
if "https://www.blackbox.ai" in content:
|
107 |
validate.getHid(True)
|
108 |
content = "Hid has been refreshed; feel free to restart the conversation.\n"
|
@@ -161,7 +161,7 @@ async def process_non_streaming_response(request: ChatRequest):
|
|
161 |
method="POST", url=f"{BASE_URL}/api/chat", headers=headers, json=json_data
|
162 |
) as response:
|
163 |
async for chunk in response.aiter_text():
|
164 |
-
full_response += chunk
|
165 |
if "https://www.blackbox.ai" in full_response:
|
166 |
validate.getHid(True)
|
167 |
full_response = "Hid has been refreshed; feel free to restart the conversation."
|
|
|
102 |
async for line in response.aiter_lines():
|
103 |
timestamp = int(datetime.now().timestamp())
|
104 |
if line:
|
105 |
+
content = line if line.endswith("\n") else line + "\n"
|
106 |
if "https://www.blackbox.ai" in content:
|
107 |
validate.getHid(True)
|
108 |
content = "Hid has been refreshed; feel free to restart the conversation.\n"
|
|
|
161 |
method="POST", url=f"{BASE_URL}/api/chat", headers=headers, json=json_data
|
162 |
) as response:
|
163 |
async for chunk in response.aiter_text():
|
164 |
+
full_response += chunk if chunk.endswith("\n") else chunk + "\n"
|
165 |
if "https://www.blackbox.ai" in full_response:
|
166 |
validate.getHid(True)
|
167 |
full_response = "Hid has been refreshed; feel free to restart the conversation."
|