From cf9d9bd48e20ef828695b9e86fc069c2a274b51f Mon Sep 17 00:00:00 2001 From: yhjun1026 <460342015@qq.com> Date: Fri, 15 Sep 2023 18:17:07 +0800 Subject: [PATCH] fix(ChatExcel): ChatExcel OutParse Bug Fix 1.ChatExcel OutParse Bug Fix 2 --- pilot/scene/chat_dashboard/out_parser.py | 5 ++++- pilot/scene/chat_data/chat_excel/excel_reader.py | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pilot/scene/chat_dashboard/out_parser.py b/pilot/scene/chat_dashboard/out_parser.py index cc31fe2bd..bf0fedef4 100644 --- a/pilot/scene/chat_dashboard/out_parser.py +++ b/pilot/scene/chat_dashboard/out_parser.py @@ -30,7 +30,10 @@ class ChatDashboardOutputParser(BaseOutputParser): for item in response: chart_items.append( ChartItem( - item["sql"].replace("\\", " "), item["title"], item["thoughts"], item["showcase"] + item["sql"].replace("\\", " "), + item["title"], + item["thoughts"], + item["showcase"], ) ) return chart_items diff --git a/pilot/scene/chat_data/chat_excel/excel_reader.py b/pilot/scene/chat_data/chat_excel/excel_reader.py index 4f373c8f9..1cd02564b 100644 --- a/pilot/scene/chat_data/chat_excel/excel_reader.py +++ b/pilot/scene/chat_data/chat_excel/excel_reader.py @@ -45,8 +45,12 @@ def deep_quotes(token, column_names=[]): if __name__ == "__main__": sql = "SELECT `地区`, (`2021年人口` - `2001年人口`) / `2001年人口` * 100 AS `Population_Growth_Rate` FROM Generated_by_ChatExcel_table1 (2)" if f'"Generated_by_ChatExcel_table1 (2)"' not in sql: - sql = sql.replace('Generated_by_ChatExcel_table1 (2)', f'"Generated_by_ChatExcel_table1 (2)"') - sql = add_quotes_ex(sql, ['地区', '地区代码', '2001年人口', '2006年人口', '2011年人口', '2016年人口', '2021年人口']) + sql = sql.replace( + "Generated_by_ChatExcel_table1 (2)", f'"Generated_by_ChatExcel_table1 (2)"' + ) + sql = add_quotes_ex( + sql, ["地区", "地区代码", "2001年人口", "2006年人口", "2011年人口", "2016年人口", "2021年人口"] + ) print(f"excute sql:{sql}")