diff --git a/pilot/openapi/api_v1/api_v1.py b/pilot/openapi/api_v1/api_v1.py index f552b8dc0..ad8d56712 100644 --- a/pilot/openapi/api_v1/api_v1.py +++ b/pilot/openapi/api_v1/api_v1.py @@ -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, diff --git a/pilot/scene/chat_db/auto_execute/out_parser.py b/pilot/scene/chat_db/auto_execute/out_parser.py index 382bda3da..e49d45d65 100644 --- a/pilot/scene/chat_db/auto_execute/out_parser.py +++ b/pilot/scene/chat_db/auto_execute/out_parser.py @@ -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 ERROR!{err_msg} \n {result.decode("utf-8")}""" + else: + return speak + "\n" + result.decode("utf-8")