mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-08 11:47:44 +00:00
bugfix(ChatData): ChatData Use AntV Table
1.Merge ChatData and ChatDB
This commit is contained in:
parent
440a3e955f
commit
940edcdab1
@ -269,36 +269,18 @@ class ApiCall:
|
|||||||
api_status = self.plugin_status_map.get(api_context)
|
api_status = self.plugin_status_map.get(api_context)
|
||||||
if api_status is not None:
|
if api_status is not None:
|
||||||
if display_mode:
|
if display_mode:
|
||||||
if api_status.api_result:
|
all_context = self.__deal_error_md_tags(
|
||||||
all_context = self.__deal_error_md_tags(
|
all_context, api_context
|
||||||
all_context, api_context
|
)
|
||||||
|
if Status.FAILED.value == api_status.status:
|
||||||
|
all_context = all_context.replace(
|
||||||
|
api_context, "\n" + api_status.err_msg + self.to_view_antv_vis(api_status)
|
||||||
)
|
)
|
||||||
# all_context = all_context.replace(
|
else:
|
||||||
# api_context, api_status.api_result
|
|
||||||
# )
|
|
||||||
|
|
||||||
all_context = all_context.replace(
|
all_context = all_context.replace(
|
||||||
api_context, self.to_view_antv_vis(api_status)
|
api_context, self.to_view_antv_vis(api_status)
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
if api_status.status == Status.FAILED.value:
|
|
||||||
all_context = self.__deal_error_md_tags(
|
|
||||||
all_context, api_context
|
|
||||||
)
|
|
||||||
all_context = all_context.replace(
|
|
||||||
api_context,
|
|
||||||
f"""\n<span style=\"color:red\">ERROR!</span>{api_status.err_msg}\n """,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
cost = (api_status.end_time - self.start_time) / 1000
|
|
||||||
cost_str = "{:.2f}".format(cost)
|
|
||||||
all_context = self.__deal_error_md_tags(
|
|
||||||
all_context, api_context
|
|
||||||
)
|
|
||||||
all_context = all_context.replace(
|
|
||||||
api_context,
|
|
||||||
f'\n<span style="color:green">Waiting...{cost_str}S</span>\n',
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
all_context = self.__deal_error_md_tags(
|
all_context = self.__deal_error_md_tags(
|
||||||
all_context, api_context, False
|
all_context, api_context, False
|
||||||
@ -359,7 +341,7 @@ class ApiCall:
|
|||||||
|
|
||||||
if api_status.api_result:
|
if api_status.api_result:
|
||||||
param["result"] = api_status.api_result
|
param["result"] = api_status.api_result
|
||||||
return json.dumps(param, default=serialize)
|
return json.dumps(param, default=serialize, ensure_ascii=False)
|
||||||
|
|
||||||
def to_view_text(self, api_status: PluginStatus):
|
def to_view_text(self, api_status: PluginStatus):
|
||||||
api_call_element = ET.Element("dbgpt-view")
|
api_call_element = ET.Element("dbgpt-view")
|
||||||
@ -385,15 +367,14 @@ class ApiCall:
|
|||||||
if api_status.name:
|
if api_status.name:
|
||||||
param["type"] = api_status.name
|
param["type"] = api_status.name
|
||||||
if api_status.args:
|
if api_status.args:
|
||||||
param["sql"] = api_status.args["sql"]
|
param["sql"] = api_status.args["sql"].replace(',', '\\,')
|
||||||
|
|
||||||
if api_status.err_msg:
|
if api_status.err_msg:
|
||||||
param["err_msg"] = api_status.err_msg
|
param["err_msg"] = api_status.err_msg
|
||||||
|
|
||||||
if api_status.api_result:
|
if api_status.api_result:
|
||||||
param["data"] = api_status.api_result
|
param["data"] = api_status.api_result
|
||||||
|
|
||||||
return json.dumps(param, default=serialize)
|
return json.dumps(param, default=serialize, ensure_ascii=False)
|
||||||
|
|
||||||
def run(self, llm_text):
|
def run(self, llm_text):
|
||||||
if self.__is_need_wait_plugin_call(llm_text):
|
if self.__is_need_wait_plugin_call(llm_text):
|
||||||
|
@ -10,7 +10,7 @@ class PluginAction(NamedTuple):
|
|||||||
|
|
||||||
|
|
||||||
class PluginChatOutputParser(BaseOutputParser):
|
class PluginChatOutputParser(BaseOutputParser):
|
||||||
def parse_view_response(self, speak, data) -> str:
|
def parse_view_response(self, speak, data, prompt_response) -> str:
|
||||||
### tool out data to table view
|
### tool out data to table view
|
||||||
print(f"parse_view_response:{speak},{str(data)}")
|
print(f"parse_view_response:{speak},{str(data)}")
|
||||||
view_text = f"##### {speak}" + "\n" + str(data)
|
view_text = f"##### {speak}" + "\n" + str(data)
|
||||||
|
@ -38,7 +38,7 @@ class ChatDashboardOutputParser(BaseOutputParser):
|
|||||||
)
|
)
|
||||||
return chart_items
|
return chart_items
|
||||||
|
|
||||||
def parse_view_response(self, speak, data) -> str:
|
def parse_view_response(self, speak, data, prompt_response) -> str:
|
||||||
return json.dumps(data.prepare_dict())
|
return json.dumps(data.prepare_dict())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -50,15 +50,15 @@ class ChatExcel(BaseChat):
|
|||||||
super().__init__(chat_param=chat_param)
|
super().__init__(chat_param=chat_param)
|
||||||
|
|
||||||
def _generate_numbered_list(self) -> str:
|
def _generate_numbered_list(self) -> str:
|
||||||
antv_charts = [{"line_chart":"used to display comparative trend analysis data"},
|
antv_charts = [{"response_line_chart":"used to display comparative trend analysis data"},
|
||||||
{"pie_chart":"suitable for scenarios such as proportion and distribution statistics"},
|
{"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_table":"suitable for display with many display columns or non-numeric columns"},
|
||||||
{"data_text":" the default display method, suitable for single-line or simple content display"},
|
# {"response_data_text":" the default display method, suitable for single-line or simple content display"},
|
||||||
{"scatter_plot":"Suitable for exploring relationships between variables, detecting outliers, etc."},
|
{"response_scatter_plot":"Suitable for exploring relationships between variables, detecting outliers, etc."},
|
||||||
{"bubble_chart":"Suitable for relationships between multiple variables, highlighting outliers or special situations, etc."},
|
{"response_bubble_chart":"Suitable for relationships between multiple variables, highlighting outliers or special situations, etc."},
|
||||||
{"donut_chart":"Suitable for hierarchical structure representation, category proportion display and highlighting key categories, etc."},
|
{"response_donut_chart":"Suitable for hierarchical structure representation, category proportion display and highlighting key categories, etc."},
|
||||||
{"area_chart":"Suitable for visualization of time series data, comparison of multiple groups of data, analysis of data change trends, etc."},
|
{"response_area_chart":"Suitable for visualization of time series data, comparison of multiple groups of data, analysis of data change trends, etc."},
|
||||||
{"heatmap":"Suitable for visual analysis of time series data, large-scale data sets, distribution of classified data, etc."}
|
{"response_heatmap":"Suitable for visual analysis of time series data, large-scale data sets, distribution of classified data, etc."}
|
||||||
]
|
]
|
||||||
|
|
||||||
# command_strings = []
|
# command_strings = []
|
||||||
|
@ -36,6 +36,6 @@ class ChatExcelOutputParser(BaseOutputParser):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"LLM Response Can't Parser! \n")
|
raise ValueError(f"LLM Response Can't Parser! \n")
|
||||||
|
|
||||||
def parse_view_response(self, speak, data) -> str:
|
def parse_view_response(self, speak, data, prompt_response) -> str:
|
||||||
### tool out data to table view
|
### tool out data to table view
|
||||||
return data
|
return data
|
||||||
|
@ -41,7 +41,7 @@ class LearningExcelOutputParser(BaseOutputParser):
|
|||||||
return ExcelResponse(desciption=model_out_text, clounms=self.data_schema, plans=None)
|
return ExcelResponse(desciption=model_out_text, clounms=self.data_schema, plans=None)
|
||||||
|
|
||||||
|
|
||||||
def parse_view_response(self, speak, data) -> str:
|
def parse_view_response(self, speak, data, prompt_response) -> str:
|
||||||
if data and not isinstance(data, str):
|
if data and not isinstance(data, str):
|
||||||
### tool out data to table view
|
### tool out data to table view
|
||||||
html_title = f"### **Data Summary**\n{data.desciption} "
|
html_title = f"### **Data Summary**\n{data.desciption} "
|
||||||
|
@ -35,7 +35,7 @@ class PluginChatOutputParser(BaseOutputParser):
|
|||||||
speak = response[key]
|
speak = response[key]
|
||||||
return PluginAction(command, speak, thoughts)
|
return PluginAction(command, speak, thoughts)
|
||||||
|
|
||||||
def parse_view_response(self, speak, data) -> str:
|
def parse_view_response(self, speak, data, prompt_response) -> str:
|
||||||
### tool out data to table view
|
### tool out data to table view
|
||||||
print(f"parse_view_response:{speak},{str(data)}")
|
print(f"parse_view_response:{speak},{str(data)}")
|
||||||
view_text = f"##### {speak}" + "\n" + str(data)
|
view_text = f"##### {speak}" + "\n" + str(data)
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user