Support Xinference (#320)

### What problem does this PR solve?

Issue link:#299

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
KevinHuSh
2024-04-11 18:22:25 +08:00
committed by GitHub
parent cb2cbf500c
commit 91068edf16
14 changed files with 81 additions and 7 deletions

View File

@ -22,6 +22,7 @@ from werkzeug.wrappers.request import Request
from flask_cors import CORS
from api.db import StatusEnum
from api.db.db_models import close_connection
from api.db.services import UserService
from api.utils import CustomJSONEncoder
@ -42,7 +43,7 @@ for h in access_logger.handlers:
Request.json = property(lambda self: self.get_json(force=True, silent=True))
app = Flask(__name__)
CORS(app, supports_credentials=True,max_age = 2592000)
CORS(app, supports_credentials=True,max_age=2592000)
app.url_map.strict_slashes = False
app.json_encoder = CustomJSONEncoder
app.errorhandler(Exception)(server_error_response)
@ -94,8 +95,6 @@ client_urls_prefix = [
]
@login_manager.request_loader
def load_user(web_request):
jwt = Serializer(secret_key=SECRET_KEY)
@ -112,4 +111,9 @@ def load_user(web_request):
stat_logger.exception(e)
return None
else:
return None
return None
@app.teardown_request
def _db_close(exc):
close_connection()

View File

@ -360,6 +360,7 @@ def use_sql(question, field_map, tenant_id, chat_mdl):
"|" for r in tbl["rows"]]
rows = "\n".join([r + f" ##{ii}$$ |" for ii, r in enumerate(rows)])
rows = re.sub(r"T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+Z)?\|", "|", rows)
if not docid_idx or not docnm_idx:
chat_logger.warning("SQL missing field: " + sql)
return {