From eeaf95a5d2b2319e2fc8c57ab86029b8f29770e2 Mon Sep 17 00:00:00 2001 From: ericggzhang Date: Thu, 7 Dec 2023 16:10:11 +0800 Subject: [PATCH] notes: 1) move the function _generate_numbered_list from excel_analyze/chat.py to base_chat.py --- pilot/scene/base_chat.py | 50 ++++++++++++++++++- .../chat_excel/excel_analyze/chat.py | 43 ---------------- pilot/scene/chat_db/auto_execute/chat.py | 43 ---------------- 3 files changed, 49 insertions(+), 87 deletions(-) diff --git a/pilot/scene/base_chat.py b/pilot/scene/base_chat.py index 070c27b76..5837fee1b 100644 --- a/pilot/scene/base_chat.py +++ b/pilot/scene/base_chat.py @@ -458,6 +458,54 @@ class BaseChat(ABC): else: return prompt_define_response + def _generate_numbered_list(self) -> str: + """this function is moved from excel_analyze/chat.py,and used by subclass. + Returns: + + """ + antv_charts = [ + {"response_line_chart": "used to display comparative trend analysis data"}, + { + "response_pie_chart": "suitable for scenarios such as proportion and distribution statistics" + }, + { + "response_table": "suitable for display with many display columns or non-numeric columns" + }, + # {"response_data_text":" the default display method, suitable for single-line or simple content display"}, + { + "response_scatter_plot": "Suitable for exploring relationships between variables, detecting outliers, etc." + }, + { + "response_bubble_chart": "Suitable for relationships between multiple variables, highlighting outliers or special situations, etc." + }, + { + "response_donut_chart": "Suitable for hierarchical structure representation, category proportion display and highlighting key categories, etc." + }, + { + "response_area_chart": "Suitable for visualization of time series data, comparison of multiple groups of data, analysis of data change trends, etc." + }, + { + "response_heatmap": "Suitable for visual analysis of time series data, large-scale data sets, distribution of classified data, etc." + }, + ] + + # command_strings = [] + # if CFG.command_disply: + # for name, item in CFG.command_disply.commands.items(): + # if item.enabled: + # command_strings.append(f"{name}:{item.description}") + # command_strings += [ + # str(item) + # for item in CFG.command_disply.commands.values() + # if item.enabled + # ] + return "\n".join( + f"{key}:{value}" + for dict_item in antv_charts + for key, value in dict_item.items() + ) + + def _build_model_operator( is_stream: bool = False, dag_name: str = "llm_model_dag" @@ -665,4 +713,4 @@ def _load_history_messages( ModelMessage(role=message_type, content=message_content) ) - return history_text if str_message else history_messages + return history_text if str_message else history_messages \ No newline at end of file diff --git a/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py b/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py index bede9bc40..f281150f9 100644 --- a/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py +++ b/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py @@ -50,49 +50,6 @@ class ChatExcel(BaseChat): self.api_call = ApiCall(display_registry=CFG.command_disply) super().__init__(chat_param=chat_param) - def _generate_numbered_list(self) -> str: - antv_charts = [ - {"response_line_chart": "used to display comparative trend analysis data"}, - { - "response_pie_chart": "suitable for scenarios such as proportion and distribution statistics" - }, - { - "response_table": "suitable for display with many display columns or non-numeric columns" - }, - # {"response_data_text":" the default display method, suitable for single-line or simple content display"}, - { - "response_scatter_plot": "Suitable for exploring relationships between variables, detecting outliers, etc." - }, - { - "response_bubble_chart": "Suitable for relationships between multiple variables, highlighting outliers or special situations, etc." - }, - { - "response_donut_chart": "Suitable for hierarchical structure representation, category proportion display and highlighting key categories, etc." - }, - { - "response_area_chart": "Suitable for visualization of time series data, comparison of multiple groups of data, analysis of data change trends, etc." - }, - { - "response_heatmap": "Suitable for visual analysis of time series data, large-scale data sets, distribution of classified data, etc." - }, - ] - - # command_strings = [] - # if CFG.command_disply: - # for name, item in CFG.command_disply.commands.items(): - # if item.enabled: - # command_strings.append(f"{name}:{item.description}") - # command_strings += [ - # str(item) - # for item in CFG.command_disply.commands.values() - # if item.enabled - # ] - return "\n".join( - f"{key}:{value}" - for dict_item in antv_charts - for key, value in dict_item.items() - ) - @trace() async def generate_input_values(self) -> Dict: input_values = { diff --git a/pilot/scene/chat_db/auto_execute/chat.py b/pilot/scene/chat_db/auto_execute/chat.py index a95bbc216..ef6601b9e 100644 --- a/pilot/scene/chat_db/auto_execute/chat.py +++ b/pilot/scene/chat_db/auto_execute/chat.py @@ -89,46 +89,3 @@ class ChatWithDbAutoExecute(BaseChat): def do_action(self, prompt_response): print(f"do_action:{prompt_response}") return self.database.run_to_df - - def _generate_numbered_list(self) -> str: - antv_charts = [ - {"response_line_chart": "used to display comparative trend analysis data"}, - { - "response_pie_chart": "suitable for scenarios such as proportion and distribution statistics" - }, - { - "response_table": "suitable for display with many display columns or non-numeric columns" - }, - # {"response_data_text":" the default display method, suitable for single-line or simple content display"}, - { - "response_scatter_plot": "Suitable for exploring relationships between variables, detecting outliers, etc." - }, - { - "response_bubble_chart": "Suitable for relationships between multiple variables, highlighting outliers or special situations, etc." - }, - { - "response_donut_chart": "Suitable for hierarchical structure representation, category proportion display and highlighting key categories, etc." - }, - { - "response_area_chart": "Suitable for visualization of time series data, comparison of multiple groups of data, analysis of data change trends, etc." - }, - { - "response_heatmap": "Suitable for visual analysis of time series data, large-scale data sets, distribution of classified data, etc." - }, - ] - - # command_strings = [] - # if CFG.command_disply: - # for name, item in CFG.command_disply.commands.items(): - # if item.enabled: - # command_strings.append(f"{name}:{item.description}") - # command_strings += [ - # str(item) - # for item in CFG.command_disply.commands.values() - # if item.enabled - # ] - return "\n".join( - f"{key}:{value}" - for dict_item in antv_charts - for key, value in dict_item.items() - )