diff --git a/aiserver.py b/aiserver.py index 7a89980b..a91a6657 100644 --- a/aiserver.py +++ b/aiserver.py @@ -494,6 +494,7 @@ from flask import Flask, render_template, Response, request, copy_current_reques from flask_socketio import SocketIO, emit, join_room, leave_room from flask_socketio import emit as _emit from flask_session import Session +from flask_compress import Compress import secrets from werkzeug.exceptions import HTTPException, NotFound, InternalServerError import secrets @@ -501,6 +502,7 @@ app = Flask(__name__, root_path=os.getcwd()) app.secret_key = secrets.token_hex() app.config['SESSION_TYPE'] = 'filesystem' app.config['TEMPLATES_AUTO_RELOAD'] = True +Compress(app) socketio = SocketIO(app, async_method="eventlet", manage_session=False, cors_allowed_origins='*', max_http_buffer_size=10_000_000) #socketio = SocketIO(app, async_method="eventlet", manage_session=False, cors_allowed_origins='*', max_http_buffer_size=10_000_000, logger=logger, engineio_logger=True) logger.add(UI_2_log_history, serialize=True, colorize=True, enqueue=True, level="INFO") diff --git a/environments/huggingface.yml b/environments/huggingface.yml index dbaab0dc..4521a783 100644 --- a/environments/huggingface.yml +++ b/environments/huggingface.yml @@ -31,4 +31,5 @@ dependencies: - accelerate - flask-session - python-socketio[client] - - ansi2html \ No newline at end of file + - ansi2html + - flask_compress \ No newline at end of file diff --git a/environments/rocm.yml b/environments/rocm.yml index cae3d0ff..677d16d3 100644 --- a/environments/rocm.yml +++ b/environments/rocm.yml @@ -30,3 +30,4 @@ dependencies: - transformers>=4.20.1 - accelerate - ansi2html + - flask_compress diff --git a/requirements.txt b/requirements.txt index 67b09e76..fa2504cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,4 +19,5 @@ loguru Pillow diffusers psutil -ansi2html \ No newline at end of file +ansi2html +flask_compress \ No newline at end of file diff --git a/requirements_mtj.txt b/requirements_mtj.txt index 16683125..73fac413 100644 --- a/requirements_mtj.txt +++ b/requirements_mtj.txt @@ -23,4 +23,5 @@ loguru Pillow diffusers psutil -ansi2html \ No newline at end of file +ansi2html +flask_compress \ No newline at end of file diff --git a/static/koboldai.js b/static/koboldai.js index 985fb55c..c0f04108 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2511,7 +2511,11 @@ function autoResize(element) { } function token_length(text) { - return encode(text).length; + if (typeof encode === 'function') { + return encode(text).length; + } else { + return 0; + } } function calc_token_usage() { diff --git a/templates/index_new.html b/templates/index_new.html index 755210dc..9c413c8a 100644 --- a/templates/index_new.html +++ b/templates/index_new.html @@ -14,8 +14,8 @@ - - + + <