Skip to content

Commit 15ee1db

Browse files
committed
Add environment variable WORKER_TIMEOUT and conversation response headers
1 parent 5041587 commit 15ee1db

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

chat/views.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import json
33
import openai
4+
import time
45
import datetime
56
import tiktoken
67
from .models import Conversation, Message, Setting, Prompt
@@ -256,7 +257,14 @@ def stream_content():
256257
'conversationId': conversation_obj.id
257258
})
258259

259-
return StreamingHttpResponse(stream_content(), content_type='text/event-stream')
260+
response = StreamingHttpResponse(
261+
stream_content(),
262+
content_type='text/event-stream'
263+
)
264+
response['X-Accel-Buffering'] = 'no'
265+
response['Cache-Control'] = 'no-cache'
266+
return response
267+
260268

261269

262270
def build_messages(model, conversation_obj, web_search_params, frugal_mode = False):

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ services:
66
target: wsgi-server
77
environment:
88
APP_DOMAIN: localhost:9000
9+
WORKER_TIMEOUT: 180
910
DJANGO_SUPERUSER_USERNAME: admin # default superuser name
1011
DJANGO_SUPERUSER_PASSWORD: password # default superuser password
1112
DJANGO_SUPERUSER_EMAIL: [email protected] # default superuser email
1213
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".
1314
# DEBUG: True
1415
# DB_URL: postgres://postgres:postgrespw@localhost:49153/chatgpt
16+
ports:
17+
- '8000:8000'
1518
networks:
1619
- chatgpt_network
1720
web-server:
18-
image: wongsaang/chatgpt-ui-web-server:latest
21+
build:
22+
context: .
1923
environment:
2024
- BACKEND_URL=http://wsgi-server:8000
2125
ports:

entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ python manage.py createsuperuser --no-input
66

77
export WORKERS=${SERVER_WORKERS:-3}
88

9-
exec gunicorn chatgpt_ui_server.wsgi --workers=$WORKERS --timeout 60 --bind 0.0.0.0:8000 --access-logfile -
9+
export TIMEOUT=${WORKER_TIMEOUT:-180}
10+
11+
exec gunicorn chatgpt_ui_server.wsgi --workers=$WORKERS --timeout $TIMEOUT --bind 0.0.0.0:8000 --access-logfile -

0 commit comments

Comments
 (0)