Update api/utils.py
Browse files147 unmodified lines1481491501511521531541551569 unmodified lines166167168169170171147 unmodified lines# Yield the cleaned chunk as part of the streamyield f"data: {json.dumps(create_chat_completion_data(cleaned_content, request.model, timestamp))}\n\n"# Only add the advertisement once, after the entire stream is processedif ADVERTISEMENT_TEXT and not advertisement_added:response_content += "\n\n" + ADVERTISEMENT_TEXT # Line break added hereadvertisement_added = True# Yield the final chunk with the advertisement text appended at the end9 unmodified lineslogger.error(f"Error occurred during request for Request ID {request_id}: {e}")raise HTTPException(status_code=500, detail=str(e))# Process non-streaming response with headers from config.pyasync def process_non_streaming_response(request: ChatRequest):request_id = f"chatcmpl-{uuid.uuid4()}"147 unmodified lines1481491501511521531541551569 unmodified lines166167168169170171172147 unmodified lines# Yield the cleaned chunk as part of the streamyield f"data: {json.dumps(create_chat_completion_data(cleaned_content, request.model, timestamp))}\n\n"# Ensure that the advertisement is added after the full response is processedif ADVERTISEMENT_TEXT and not advertisement_added:response_content += "\n\n" + ADVERTISEMENT_TEXT # Add line break hereadvertisement_added = True# Yield the final chunk with the advertisement text appended at the end9 unmodified lineslogger.error(f"Error occurred during request for Request ID {request_id}: {e}")raise HTTPException(status_code=500, detail=str(e))# Process non-streaming response with headers from config.pyasync def process_non_streaming_response(request: ChatRequest):request_id = f"chatcmpl-{uuid.uuid4()}"
api/utils.py+3-2