Niansuh commited on
Commit
f9f806c
·
verified ·
1 Parent(s): 1fe1d3e

Update api/utils.py

Browse files
Files changed (1) hide show
  1. api/utils.py +2 -2
api/utils.py CHANGED
@@ -177,8 +177,8 @@ async def process_streaming_response(request: ChatRequest):
177
  yield f"data: {json.dumps(create_chat_completion_data(cleaned_content, request.model, timestamp))}\n\n"
178
  response_content += cleaned_content # Collect the full response content
179
 
180
- # After all chunks are processed, add the advertisement text at the end
181
- if ADVERTISEMENT_TEXT:
182
  response_content += "\n\n" + ADVERTISEMENT_TEXT
183
  yield f"data: {json.dumps(create_chat_completion_data(response_content, request.model, timestamp, 'stop'))}\n\n"
184
 
 
177
  yield f"data: {json.dumps(create_chat_completion_data(cleaned_content, request.model, timestamp))}\n\n"
178
  response_content += cleaned_content # Collect the full response content
179
 
180
+ # After all chunks are processed, add the advertisement text at the end only if it's not already present
181
+ if ADVERTISEMENT_TEXT and ADVERTISEMENT_TEXT not in response_content:
182
  response_content += "\n\n" + ADVERTISEMENT_TEXT
183
  yield f"data: {json.dumps(create_chat_completion_data(response_content, request.model, timestamp, 'stop'))}\n\n"
184