mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-17 15:58:25 +00:00
fix: Fix ChatExcel error
This commit is contained in:
parent
367ffe986c
commit
7a2ae64f83
@ -216,7 +216,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))
|
||||
@ -279,7 +279,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)
|
||||
|
||||
|
||||
|
@ -244,7 +244,7 @@ class BaseChat(ABC):
|
||||
else:
|
||||
return self._blocking_nostream_call()
|
||||
|
||||
def prepare(self):
|
||||
async def prepare(self):
|
||||
pass
|
||||
|
||||
def generate_llm_text(self) -> str:
|
||||
|
@ -81,7 +81,7 @@ class ChatExcel(BaseChat):
|
||||
}
|
||||
return input_values
|
||||
|
||||
def prepare(self):
|
||||
async def prepare(self):
|
||||
logger.info(f"{self.chat_mode} prepare start!")
|
||||
if len(self.history_message) > 0:
|
||||
return None
|
||||
@ -93,7 +93,7 @@ class ChatExcel(BaseChat):
|
||||
"excel_reader": self.excel_reader,
|
||||
}
|
||||
learn_chat = ExcelLearning(**chat_param)
|
||||
result = learn_chat.nostream_call()
|
||||
result = await learn_chat.nostream_call()
|
||||
return result
|
||||
|
||||
def do_action(self, prompt_response):
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user