Merge cluster to master #3
|
@ -2,8 +2,11 @@ from llm_server.cluster.cluster_config import cluster_config
|
||||||
from llm_server.custom_redis import redis
|
from llm_server.custom_redis import redis
|
||||||
|
|
||||||
|
|
||||||
def format_sillytavern_err(msg: str, backend_url: str = 'none', error_type: str = 'info'):
|
def format_sillytavern_err(msg: str, backend_url: str = None, error_type: str = 'info'):
|
||||||
|
if backend_url:
|
||||||
cluster_backend_hash = cluster_config.get_backend(backend_url)['hash']
|
cluster_backend_hash = cluster_config.get_backend(backend_url)['hash']
|
||||||
|
else:
|
||||||
|
cluster_backend_hash = 'none'
|
||||||
http_host = redis.get('http_host', dtype=str)
|
http_host = redis.get('http_host', dtype=str)
|
||||||
return f"""```
|
return f"""```
|
||||||
=== MESSAGE FROM LLM MIDDLEWARE AT {http_host} ===
|
=== MESSAGE FROM LLM MIDDLEWARE AT {http_host} ===
|
||||||
|
|
|
@ -3,15 +3,16 @@ from flask import Blueprint, jsonify
|
||||||
from llm_server.custom_redis import redis
|
from llm_server.custom_redis import redis
|
||||||
from llm_server.routes.helpers.client import format_sillytavern_err
|
from llm_server.routes.helpers.client import format_sillytavern_err
|
||||||
|
|
||||||
bp = Blueprint('old_v1', __name__)
|
old_v1_bp = Blueprint('v1', __name__)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<first>')
|
@old_v1_bp.route('/', defaults={'path': ''}, methods=['GET', 'POST'])
|
||||||
@bp.route('/<first>/<path:rest>')
|
@old_v1_bp.route('/<path:path>', methods=['GET', 'POST'])
|
||||||
def fallback(first=None, rest=None):
|
def fallback(path):
|
||||||
base_client_api = redis.get('base_client_api', dtype=str)
|
base_client_api = redis.get('base_client_api', dtype=str)
|
||||||
error_msg = f'The /v1/ endpoint has been depreciated. Please see [{base_client_api}]({base_client_api}) for the new endpoint.'
|
error_msg = f'The /v1/ endpoint has been depreciated. Please visit {base_client_api} for more information.'
|
||||||
response_msg = format_sillytavern_err(error_msg, error_type='API')
|
response_msg = format_sillytavern_err(error_msg, error_type='API')
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'results': [{'text': response_msg}]
|
'results': [{'text': response_msg}],
|
||||||
|
'result': base_client_api
|
||||||
}), 200 # return 200 so we don't trigger an error message in the client's ST
|
}), 200 # return 200 so we don't trigger an error message in the client's ST
|
||||||
|
|
|
@ -3,7 +3,7 @@ from flask import Blueprint
|
||||||
from ..request_handler import before_request
|
from ..request_handler import before_request
|
||||||
from ..server_error import handle_server_error
|
from ..server_error import handle_server_error
|
||||||
|
|
||||||
bp = Blueprint('v1', __name__)
|
bp = Blueprint('v2', __name__)
|
||||||
|
|
||||||
|
|
||||||
@bp.before_request
|
@bp.before_request
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from llm_server.routes.v1 import old_v1_bp
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import gevent.monkey
|
import gevent.monkey
|
||||||
|
|
||||||
|
@ -70,6 +72,7 @@ from llm_server.routes.v2.generate_stats import generate_stats
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
init_socketio(app)
|
init_socketio(app)
|
||||||
app.register_blueprint(bp, url_prefix='/api/v2/')
|
app.register_blueprint(bp, url_prefix='/api/v2/')
|
||||||
|
app.register_blueprint(old_v1_bp, url_prefix='/api/v1/')
|
||||||
app.register_blueprint(openai_bp, url_prefix='/api/openai/v1/')
|
app.register_blueprint(openai_bp, url_prefix='/api/openai/v1/')
|
||||||
flask_cache.init_app(app)
|
flask_cache.init_app(app)
|
||||||
flask_cache.clear()
|
flask_cache.clear()
|
||||||
|
|
Reference in New Issue