Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -32,16 +32,19 @@ async def send_chat_message(LLM_URL, LLM_API, user_input):
|
|
32 |
# Handle the stream of events
|
33 |
full_response = []
|
34 |
async for line in response.content:
|
35 |
-
line = line.decode('utf-8')
|
36 |
-
if line:
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
45 |
|
46 |
if full_response:
|
47 |
return ''.join(full_response).strip()
|
|
|
32 |
# Handle the stream of events
|
33 |
full_response = []
|
34 |
async for line in response.content:
|
35 |
+
line = line.decode('utf-8').strip()
|
36 |
+
if not line:
|
37 |
+
continue
|
38 |
+
if "data: " not in line:
|
39 |
+
continue
|
40 |
+
try:
|
41 |
+
print("Received line:", line) # Debug information
|
42 |
+
data = json.loads(line.split("data: ")[1])
|
43 |
+
if "answer" in data:
|
44 |
+
full_response.append(data["answer"])
|
45 |
+
except (IndexError, json.JSONDecodeError) as e:
|
46 |
+
print(f"Error parsing line: {line}, error: {e}") # Debug information
|
47 |
+
continue
|
48 |
|
49 |
if full_response:
|
50 |
return ''.join(full_response).strip()
|