diff --git a/chat/views.py b/chat/views.py index 1ca282a..0b366e2 100644 --- a/chat/views.py +++ b/chat/views.py @@ -1,6 +1,7 @@ import os import json import openai +import time import datetime import tiktoken from .models import Conversation, Message, Setting, Prompt @@ -256,7 +257,14 @@ def stream_content(): 'conversationId': conversation_obj.id }) - return StreamingHttpResponse(stream_content(), content_type='text/event-stream') + response = StreamingHttpResponse( + stream_content(), + content_type='text/event-stream' + ) + response['X-Accel-Buffering'] = 'no' + response['Cache-Control'] = 'no-cache' + return response + def build_messages(model, conversation_obj, web_search_params, frugal_mode = False): diff --git a/docker-compose.yml b/docker-compose.yml index 4e464b5..f5eb640 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,16 +6,20 @@ services: target: wsgi-server environment: APP_DOMAIN: localhost:9000 + WORKER_TIMEOUT: 180 DJANGO_SUPERUSER_USERNAME: admin # default superuser name DJANGO_SUPERUSER_PASSWORD: password # default superuser password DJANGO_SUPERUSER_EMAIL: admin@example.com # default superuser email ACCOUNT_EMAIL_VERIFICATION: ${ACCOUNT_EMAIL_VERIFICATION:-none} # Determines the e-mail verification method during signup – choose one of "none", "optional", or "mandatory". Default is "optional". If you don't need to verify the email, you can set it to "none". # DEBUG: True # DB_URL: postgres://postgres:postgrespw@localhost:49153/chatgpt + ports: + - '8000:8000' networks: - chatgpt_network web-server: - image: wongsaang/chatgpt-ui-web-server:latest + build: + context: . environment: - BACKEND_URL=http://wsgi-server:8000 ports: diff --git a/entrypoint.sh b/entrypoint.sh index f3e8f40..2493811 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,4 +6,6 @@ python manage.py createsuperuser --no-input export WORKERS=${SERVER_WORKERS:-3} -exec gunicorn chatgpt_ui_server.wsgi --workers=$WORKERS --timeout 60 --bind 0.0.0.0:8000 --access-logfile - \ No newline at end of file +export TIMEOUT=${WORKER_TIMEOUT:-180} + +exec gunicorn chatgpt_ui_server.wsgi --workers=$WORKERS --timeout $TIMEOUT --bind 0.0.0.0:8000 --access-logfile - \ No newline at end of file