bugfix(ChatData): ChatData Use AntV Table

1.Merge ChatData and ChatDB
This commit is contained in:
yhjun1026 2023-11-10 11:36:57 +08:00
parent ad7964f4ab
commit 74a3f6edb5
2 changed files with 11 additions and 8 deletions

View File

@ -228,6 +228,7 @@ async def dialogue_scenes():
scene_vos: List[ChatSceneVo] = []
new_modes: List[ChatScene] = [
ChatScene.ChatWithDbExecute,
# ChatScene.ChatWithDbQA,
ChatScene.ChatExcel,
ChatScene.ChatKnowledge,
ChatScene.ChatDashboard,

View File

@ -37,6 +37,7 @@ class DbChatOutputParser(BaseOutputParser):
param = {}
api_call_element = ET.Element("chart-view")
err_msg = None
try:
df = data(prompt_response.sql)
param["type"] = "response_table"
@ -44,17 +45,18 @@ class DbChatOutputParser(BaseOutputParser):
param["data"] = json.loads(df.to_json(orient='records', date_format='iso', date_unit='s'))
view_json_str = json.dumps(param, default=serialize)
except Exception as e:
err_param ={}
param["sql"] = prompt_response.sql
logger.error("parse_view_response error!" + str(e))
err_param = {}
err_param["sql"] = f'{prompt_response.sql}'
err_param["type"] = "response_table"
err_param["err_msg"] = str(e)
err_param["data"] = []
err_msg = str(e)
view_json_str = json.dumps(err_param, default=serialize)
api_call_element.text = view_json_str
result = ET.tostring(api_call_element, encoding="utf-8")
return speak + "\n" + result.decode("utf-8")
if err_msg:
return f"""{speak} \\n <span style=\"color:red\">ERROR!</span>{err_msg} \n {result.decode("utf-8")}"""
else:
return speak + "\n" + result.decode("utf-8")