Skip to content

Commit 84df085

Browse files
committed
edit order of finish reason to be compatible with gcp gateway
1 parent 66c03d3 commit 84df085

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/rag_system.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ def answer_query_stream(self, query):
148148
)
149149

150150
collected_messages = []
151-
for chunk in stream:
152-
if chunk['choices'][0]['finish_reason'] is not None:
153-
break
151+
for chunk in stream:
154152
content = chunk['choices'][0]['delta'].get('content', '')
155153
collected_messages.append(content)
156154
yield content
155+
if chunk['choices'][0].get('finish_reason') is not None:
156+
break
157157

158158
if len(citations) > 0:
159159
yield "\n\nReferences:\n" + "\n".join(citations)

0 commit comments

Comments
 (0)