Continue...
This commit is contained in:
parent
4e7498b0c4
commit
f7ce5e6050
2 changed files with 10 additions and 4 deletions
|
|
@ -21,13 +21,13 @@ from api.db.services.tenant_llm_service import TenantLLMService
|
||||||
from api.db.services.user_service import TenantService
|
from api.db.services.user_service import TenantService
|
||||||
from common.misc_utils import get_uuid
|
from common.misc_utils import get_uuid
|
||||||
from common.constants import RetCode, StatusEnum
|
from common.constants import RetCode, StatusEnum
|
||||||
from api.utils.api_utils import check_duplicate_ids, get_error_data_result, get_result, token_required
|
from api.utils.api_utils import check_duplicate_ids, get_error_data_result, get_result, token_required, request_json
|
||||||
|
|
||||||
|
|
||||||
@manager.route("/chats", methods=["POST"]) # noqa: F821
|
@manager.route("/chats", methods=["POST"]) # noqa: F821
|
||||||
@token_required
|
@token_required
|
||||||
async def create(tenant_id):
|
async def create(tenant_id):
|
||||||
req = await request.json
|
req = await request_json()
|
||||||
ids = [i for i in req.get("dataset_ids", []) if i]
|
ids = [i for i in req.get("dataset_ids", []) if i]
|
||||||
for kb_id in ids:
|
for kb_id in ids:
|
||||||
kbs = KnowledgebaseService.accessible(kb_id=kb_id, user_id=tenant_id)
|
kbs = KnowledgebaseService.accessible(kb_id=kb_id, user_id=tenant_id)
|
||||||
|
|
@ -146,7 +146,7 @@ async def create(tenant_id):
|
||||||
async def update(tenant_id, chat_id):
|
async def update(tenant_id, chat_id):
|
||||||
if not DialogService.query(tenant_id=tenant_id, id=chat_id, status=StatusEnum.VALID.value):
|
if not DialogService.query(tenant_id=tenant_id, id=chat_id, status=StatusEnum.VALID.value):
|
||||||
return get_error_data_result(message="You do not own the chat")
|
return get_error_data_result(message="You do not own the chat")
|
||||||
req = await request.json
|
req = await request_json()
|
||||||
ids = req.get("dataset_ids", [])
|
ids = req.get("dataset_ids", [])
|
||||||
if "show_quotation" in req:
|
if "show_quotation" in req:
|
||||||
req["do_refer"] = req.pop("show_quotation")
|
req["do_refer"] = req.pop("show_quotation")
|
||||||
|
|
@ -229,7 +229,7 @@ async def update(tenant_id, chat_id):
|
||||||
async def delete_chats(tenant_id):
|
async def delete_chats(tenant_id):
|
||||||
errors = []
|
errors = []
|
||||||
success_count = 0
|
success_count = 0
|
||||||
req = await request.json
|
req = await request_json()
|
||||||
if not req:
|
if not req:
|
||||||
ids = None
|
ids = None
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,12 @@ from common import settings
|
||||||
requests.models.complexjson.dumps = functools.partial(json.dumps, cls=CustomJSONEncoder)
|
requests.models.complexjson.dumps = functools.partial(json.dumps, cls=CustomJSONEncoder)
|
||||||
|
|
||||||
|
|
||||||
|
async def request_json():
|
||||||
|
try:
|
||||||
|
return await request.json
|
||||||
|
except:
|
||||||
|
return {}
|
||||||
|
|
||||||
def serialize_for_json(obj):
|
def serialize_for_json(obj):
|
||||||
"""
|
"""
|
||||||
Recursively serialize objects to make them JSON serializable.
|
Recursively serialize objects to make them JSON serializable.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue