Skip to content

Commit bce02f4

Browse files
fix: ensure valid chunk text before yielding response in ChatService
1 parent cf4219a commit bce02f4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/api/services/chat_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ async def stream_openai_text(self, conversation_id: str, query: str) -> Streamin
157157
citations.extend(content.annotations)
158158

159159
if first_chunk:
160-
yield "{ \"answer\": " + str(chunk.text)
161-
first_chunk = False
160+
if chunk is not None and chunk.text != "":
161+
first_chunk = False
162+
yield "{ \"answer\": " + str(chunk.text)
162163
else:
163164
complete_response += str(chunk.text)
164165
yield str(chunk.text)

0 commit comments

Comments
 (0)