19 lines
861 B
Python
19 lines
861 B
Python
from flask import Blueprint, jsonify
|
|
|
|
from llm_server.custom_redis import redis
|
|
from llm_server.routes.helpers.client import format_sillytavern_err
|
|
|
|
old_v1_bp = Blueprint('v1', __name__)
|
|
|
|
|
|
@old_v1_bp.route('/', defaults={'path': ''}, methods=['GET', 'POST'])
|
|
@old_v1_bp.route('/<path:path>', methods=['GET', 'POST'])
|
|
def fallback(path):
|
|
base_client_api = redis.get('base_client_api', dtype=str)
|
|
error_msg = f'The /v1/ endpoint has been depreciated. Please visit {base_client_api} for more information.\nAlso, you must enable "Relaxed API URLS" in settings.'
|
|
response_msg = format_sillytavern_err(error_msg, error_type='API')
|
|
return jsonify({
|
|
'results': [{'text': response_msg}],
|
|
'result': f'Wrong API path, visit {base_client_api} for more info.'
|
|
}), 200 # return 200 so we don't trigger an error message in the client's ST
|