Merge branch 'main' into TY_08_DEV_NEW

This commit is contained in:
yhjun1026 2023-09-01 09:41:32 +08:00
commit 06f705b22c
2 changed files with 7 additions and 6 deletions

View File

@ -238,7 +238,7 @@ async def params_load(conv_uid: str, chat_mode: str, doc_file: UploadFile = File
conv_uid=conv_uid, chat_mode=chat_mode, select_param=doc_file.filename
)
chat: BaseChat = get_chat_instance(dialogue)
resp = chat.prepare()
resp = await chat.prepare()
### refresh messages
return Result.succ(get_hist_messages(conv_uid))
@ -301,7 +301,7 @@ async def chat_prepare(dialogue: ConversationVo = Body()):
chat: BaseChat = get_chat_instance(dialogue)
if len(chat.history_message) > 0:
return Result.succ(None)
resp = chat.prepare()
resp = await chat.prepare()
return Result.succ(resp)

View File

@ -135,12 +135,13 @@ def pretty_print_semaphore(semaphore):
def get_or_create_event_loop() -> asyncio.BaseEventLoop:
loop = None
try:
loop = asyncio.get_event_loop()
except Exception as e:
assert loop is not None
return loop
except RuntimeError as e:
if not "no running event loop" in str(e):
raise e
logging.warning("Cant not get running event loop, create new event loop now")
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
return loop
return asyncio.get_event_loop_policy().get_event_loop()