From 248c1369b56b6f5d959b8a8478b526301ef13c5b Mon Sep 17 00:00:00 2001
From: yhjun1026 <460342015@qq.com>
Date: Thu, 31 Aug 2023 19:20:22 +0800
Subject: [PATCH 1/7] feat(editor): ChatExcel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🔥ChatExcel Mode Operation Manual
---
.../connections/manages/connection_manager.py | 26 +++++++++++++++++++
pilot/connections/rdbms/base.py | 16 +++++++-----
pilot/openapi/api_v1/api_v1.py | 26 +++++++++++++++++--
3 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/pilot/connections/manages/connection_manager.py b/pilot/connections/manages/connection_manager.py
index f7184858e..711f1d6db 100644
--- a/pilot/connections/manages/connection_manager.py
+++ b/pilot/connections/manages/connection_manager.py
@@ -1,4 +1,5 @@
import threading
+import asyncio
from pilot.configs.config import Config
from pilot.connections.manages.connect_storage_duckdb import DuckdbConnectConfig
@@ -138,6 +139,27 @@ class ConnectManager:
host=db_host, port=db_port, user=db_user, pwd=db_pwd, db_name=db_name
)
+ def test_connect(self, db_info: DBConfig):
+ try:
+ db_type = DBType.of_db_type(db_info.db_type)
+ connect_instance = self.get_cls_by_dbtype(db_type.value())
+ if db_type.is_file_db():
+ db_path = db_info.db_path
+ return connect_instance.from_file_path(db_path)
+ else:
+ db_name = db_info.db_name
+ db_host = db_info.db_host
+ db_port = db_info.db_port
+ db_user = db_info.db_user
+ db_pwd = db_info.db_pwd
+ return connect_instance.from_uri_db(
+ host=db_host, port=db_port, user=db_user, pwd=db_pwd, db_name=db_name
+ )
+ except Exception as e:
+ print(f'{db_info.db_name} Test connect Failure!{str(e)}')
+ raise ValueError(f'{db_info.db_name} Test connect Failure!{str(e)}')
+
+
def get_db_list(self):
return self.storage.get_db_list()
@@ -159,6 +181,10 @@ class ConnectManager:
db_info.comment,
)
+ async def async_db_summary_embedding(self, db_name, db_type):
+ # 在这里执行需要异步运行的代码
+ self.db_summary_client.db_summary_embedding(db_name, db_type)
+
def add_db(self, db_info: DBConfig):
print(f"add_db:{db_info.__dict__}")
try:
diff --git a/pilot/connections/rdbms/base.py b/pilot/connections/rdbms/base.py
index 51d70d386..4ed276283 100644
--- a/pilot/connections/rdbms/base.py
+++ b/pilot/connections/rdbms/base.py
@@ -1,5 +1,5 @@
from __future__ import annotations
-
+from urllib.parse import quote
import warnings
import sqlparse
import regex as re
@@ -95,9 +95,9 @@ class RDBMSDatabase(BaseConnect):
db_url: str = (
cls.driver
+ "://"
- + user
+ + quote(user)
+ ":"
- + pwd
+ + quote(pwd)
+ "@"
+ host
+ ":"
@@ -493,9 +493,13 @@ class RDBMSDatabase(BaseConnect):
def get_users(self):
"""Get user info."""
- cursor = self.session.execute(text(f"SELECT user, host FROM mysql.user"))
- users = cursor.fetchall()
- return [(user[0], user[1]) for user in users]
+ try:
+ cursor = self.session.execute(text(f"SELECT user, host FROM mysql.user"))
+ users = cursor.fetchall()
+ return [(user[0], user[1]) for user in users]
+ except Exception as e:
+ return []
+
def get_table_comments(self, db_name):
cursor = self.session.execute(
diff --git a/pilot/openapi/api_v1/api_v1.py b/pilot/openapi/api_v1/api_v1.py
index 33e226468..f4b555e68 100644
--- a/pilot/openapi/api_v1/api_v1.py
+++ b/pilot/openapi/api_v1/api_v1.py
@@ -38,6 +38,7 @@ from pilot.common.schema import DBType
from pilot.memory.chat_history.duckdb_history import DuckdbHistoryMemory
from pilot.scene.message import OnceConversation
from pilot.configs.model_config import LLM_MODEL_CONFIG, KNOWLEDGE_UPLOAD_ROOT_PATH
+from pilot.summary.db_summary_client import DBSummaryClient
router = APIRouter()
CFG = Config()
@@ -108,9 +109,29 @@ async def db_connect_delete(db_name: str = None):
return Result.succ(CFG.LOCAL_DB_MANAGE.delete_db(db_name))
+async def async_db_summary_embedding(db_name, db_type):
+ # 在这里执行需要异步运行的代码
+ db_summary_client = DBSummaryClient()
+ db_summary_client.db_summary_embedding(db_name, db_type)
+
+
+@router.post("/v1/chat/db/test/connect", response_model=Result[bool])
+async def test_connect(db_config: DBConfig = Body()):
+ try:
+ CFG.LOCAL_DB_MANAGE.test_connect(db_config)
+ return Result.succ(True)
+ except Exception as e:
+ return Result.faild(code="E1001", msg=str(e))
+
+
+@router.post("/v1/chat/db/summary", response_model=Result[bool])
+async def db_summary(db_name: str, db_type: str):
+ async_db_summary_embedding(db_name, db_type)
+ return Result.succ(True)
+
+
@router.get("/v1/chat/db/support/type", response_model=Result[DbTypeInfo])
async def db_support_types():
-
support_types = CFG.LOCAL_DB_MANAGE.get_all_completed_types()
db_type_infos = []
for type in support_types:
@@ -229,7 +250,8 @@ async def dialogue_delete(con_uid: str):
history_mem.delete()
return Result.succ(None)
-def get_hist_messages(conv_uid:str):
+
+def get_hist_messages(conv_uid: str):
message_vos: List[MessageVo] = []
history_mem = DuckdbHistoryMemory(conv_uid)
history_messages: List[OnceConversation] = history_mem.get_messages()
From 502c9df3bf2ab3a8448268240e024870f00b82ae Mon Sep 17 00:00:00 2001
From: yhjun1026 <460342015@qq.com>
Date: Thu, 31 Aug 2023 19:54:42 +0800
Subject: [PATCH 2/7] feat(editor): ChatExcel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🔥ChatExcel Mode Operation Manual
---
.../chat_excel/excel_analyze/prompt.py | 4 +-
.../chat_excel/excel_learning/out_parser.py | 60 ++++++++++---------
pilot/server/dbgpt_server.py | 2 +-
3 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/pilot/scene/chat_data/chat_excel/excel_analyze/prompt.py b/pilot/scene/chat_data/chat_excel/excel_analyze/prompt.py
index 7b4b7f1dc..9d7b35228 100644
--- a/pilot/scene/chat_data/chat_excel/excel_analyze/prompt.py
+++ b/pilot/scene/chat_data/chat_excel/excel_analyze/prompt.py
@@ -16,7 +16,7 @@ Please use the data structure information of the above historical dialogue, make
According to the user goal: {user_input},give the correct duckdb SQL for data analysis.
Use the table name: {table_name}
-According to the analysis SQL obtained by the user's goal, select the best one from the following display forms, if it cannot be determined, use Text as the display.
+According to the analysis SQL obtained by the user's goal, select the best one from the following display forms, if it cannot be determined, use Text as the display,Just need to return the type name into the result.
Display type:
{disply_type}
@@ -31,7 +31,7 @@ _DEFAULT_TEMPLATE_ZH = """
请确保不要使用不在数据结构中的列名。
SQL中需要使用的表名是: {table_name}
-根据用户目标得到的分析SQL,请从以下显示类型中选择最合适的一种用来展示结果数据,如果无法确定,则使用'Text'作为显示。
+根据用户目标得到的分析SQL,请从以下显示类型中选择最合适的一种用来展示结果数据,如果无法确定,则使用'Text'作为显示, 只需要将类型名称返回到结果中。
显示类型如下:
{disply_type}
diff --git a/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py b/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py
index ff63aa362..c583e958d 100644
--- a/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py
+++ b/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py
@@ -27,33 +27,39 @@ class LearningExcelOutputParser(BaseOutputParser):
def parse_prompt_response(self, model_out_text):
clean_str = super().parse_prompt_response(model_out_text)
print("clean prompt response:", clean_str)
- response = json.loads(clean_str)
- for key in sorted(response):
- if key.strip() == "DataAnalysis":
- desciption = response[key]
- if key.strip() == "ColumnAnalysis":
- clounms = response[key]
- if key.strip() == "AnalysisProgram":
- plans = response[key]
- return ExcelResponse(desciption=desciption, clounms=clounms, plans=plans)
+ try:
+ response = json.loads(clean_str)
+ for key in sorted(response):
+ if key.strip() == "DataAnalysis":
+ desciption = response[key]
+ if key.strip() == "ColumnAnalysis":
+ clounms = response[key]
+ if key.strip() == "AnalysisProgram":
+ plans = response[key]
+ return ExcelResponse(desciption=desciption, clounms=clounms, plans=plans)
+ except Exception as e:
+ return model_out_text
def parse_view_response(self, speak, data) -> str:
- ### tool out data to table view
- html_title = f"### **数据简介**\n{data.desciption} "
- html_colunms = f"### **数据结构**\n"
- column_index = 0
- for item in data.clounms:
- column_index += 1
- keys = item.keys()
- for key in keys:
- html_colunms = (
- html_colunms + f"- **{column_index}.[{key}]** _{item[key]}_\n"
- )
+ if data:
+ ### tool out data to table view
+ html_title = f"### **数据简介**\n{data.desciption} "
+ html_colunms = f"### **数据结构**\n"
+ column_index = 0
+ for item in data.clounms:
+ column_index += 1
+ keys = item.keys()
+ for key in keys:
+ html_colunms = (
+ html_colunms + f"- **{column_index}.[{key}]** _{item[key]}_\n"
+ )
- html_plans = f"### **分析计划**\n"
- index = 0
- for item in data.plans:
- index += 1
- html_plans = html_plans + f"{item} \n"
- html = f"""{html_title}\n{html_colunms}\n{html_plans}"""
- return html
+ html_plans = f"### **分析计划**\n"
+ index = 0
+ for item in data.plans:
+ index += 1
+ html_plans = html_plans + f"{item} \n"
+ html = f"""{html_title}\n{html_colunms}\n{html_plans}"""
+ return html
+ else:
+ return speak
\ No newline at end of file
diff --git a/pilot/server/dbgpt_server.py b/pilot/server/dbgpt_server.py
index 86ca49330..69fb2ee63 100644
--- a/pilot/server/dbgpt_server.py
+++ b/pilot/server/dbgpt_server.py
@@ -68,7 +68,7 @@ app.add_middleware(
app.include_router(api_v1, prefix="/api")
-app.include_router(knowledge_router, prefix="/api")
+# app.include_router(knowledge_router, prefix="/api")
app.include_router(api_editor_route_v1, prefix="/api")
# app.include_router(api_v1)
From 57d17a073cfcb3ccb9c5f967f93c410a67610803 Mon Sep 17 00:00:00 2001
From: yhjun1026 <460342015@qq.com>
Date: Thu, 31 Aug 2023 20:24:18 +0800
Subject: [PATCH 3/7] feat(editor): ChatExcel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🔥ChatExcel Mode Operation Manual
---
pilot/scene/chat_data/chat_excel/excel_analyze/chat.py | 2 +-
pilot/server/dbgpt_server.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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 806fada18..a3f4dc0b2 100644
--- a/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py
+++ b/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py
@@ -93,7 +93,7 @@ class ChatExcel(BaseChat):
"excel_reader": self.excel_reader,
}
learn_chat = ExcelLearning(**chat_param)
- result = learn_chat.nostream_call()
+ result = learn_chat.call()
return result
def do_action(self, prompt_response):
diff --git a/pilot/server/dbgpt_server.py b/pilot/server/dbgpt_server.py
index 69fb2ee63..86ca49330 100644
--- a/pilot/server/dbgpt_server.py
+++ b/pilot/server/dbgpt_server.py
@@ -68,7 +68,7 @@ app.add_middleware(
app.include_router(api_v1, prefix="/api")
-# app.include_router(knowledge_router, prefix="/api")
+app.include_router(knowledge_router, prefix="/api")
app.include_router(api_editor_route_v1, prefix="/api")
# app.include_router(api_v1)
From ff9ead0859c4b91115d534d724df3f92a498e5d2 Mon Sep 17 00:00:00 2001
From: yhjun1026 <460342015@qq.com>
Date: Thu, 31 Aug 2023 20:30:44 +0800
Subject: [PATCH 4/7] feat(editor): ChatExcel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🔥ChatExcel Mode Operation Manual
---
pilot/connections/manages/connection_manager.py | 11 +++++++----
pilot/connections/rdbms/base.py | 1 -
.../chat_data/chat_excel/excel_learning/out_parser.py | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/pilot/connections/manages/connection_manager.py b/pilot/connections/manages/connection_manager.py
index 711f1d6db..a933205c2 100644
--- a/pilot/connections/manages/connection_manager.py
+++ b/pilot/connections/manages/connection_manager.py
@@ -153,12 +153,15 @@ class ConnectManager:
db_user = db_info.db_user
db_pwd = db_info.db_pwd
return connect_instance.from_uri_db(
- host=db_host, port=db_port, user=db_user, pwd=db_pwd, db_name=db_name
+ host=db_host,
+ port=db_port,
+ user=db_user,
+ pwd=db_pwd,
+ db_name=db_name,
)
except Exception as e:
- print(f'{db_info.db_name} Test connect Failure!{str(e)}')
- raise ValueError(f'{db_info.db_name} Test connect Failure!{str(e)}')
-
+ print(f"{db_info.db_name} Test connect Failure!{str(e)}")
+ raise ValueError(f"{db_info.db_name} Test connect Failure!{str(e)}")
def get_db_list(self):
return self.storage.get_db_list()
diff --git a/pilot/connections/rdbms/base.py b/pilot/connections/rdbms/base.py
index dbd8de5f3..97d90e344 100644
--- a/pilot/connections/rdbms/base.py
+++ b/pilot/connections/rdbms/base.py
@@ -501,7 +501,6 @@ class RDBMSDatabase(BaseConnect):
except Exception as e:
return []
-
def get_table_comments(self, db_name):
cursor = self.session.execute(
text(
diff --git a/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py b/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py
index c583e958d..c990b042c 100644
--- a/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py
+++ b/pilot/scene/chat_data/chat_excel/excel_learning/out_parser.py
@@ -62,4 +62,4 @@ class LearningExcelOutputParser(BaseOutputParser):
html = f"""{html_title}\n{html_colunms}\n{html_plans}"""
return html
else:
- return speak
\ No newline at end of file
+ return speak
From c80878feefbcaeee34eb74f16f51a7fb800526fc Mon Sep 17 00:00:00 2001
From: yhjun1026 <460342015@qq.com>
Date: Thu, 31 Aug 2023 21:22:12 +0800
Subject: [PATCH 5/7] feat(editor): ChatExcel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🔥ChatExcel Mode Operation Manual
---
pilot/scene/base_chat.py | 11 ++++++++---
.../scene/chat_data/chat_excel/excel_analyze/chat.py | 6 +++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/pilot/scene/base_chat.py b/pilot/scene/base_chat.py
index 88f457935..726db8304 100644
--- a/pilot/scene/base_chat.py
+++ b/pilot/scene/base_chat.py
@@ -178,7 +178,7 @@ class BaseChat(ABC):
async def nostream_call(self):
payload = self.__call_base()
- logger.info(f"Requert: \n{payload}")
+ logger.info(f"Request: \n{payload}")
ai_response_text = ""
try:
from pilot.model.worker.manager import worker_manager
@@ -231,12 +231,17 @@ class BaseChat(ABC):
except StopAsyncIteration:
break
+
def _blocking_nostream_call(self):
logger.warn(
"_blocking_nostream_call is only temporarily used in webserver and will be deleted soon, please use nostream_call to replace it for higher performance"
)
loop = get_or_create_event_loop()
- return loop.run_until_complete(self.nostream_call())
+ try:
+ return loop.run_until_complete(self.nostream_call())
+ finally:
+ loop.close()
+
def call(self):
if self.prompt_template.stream_out:
@@ -244,7 +249,7 @@ class BaseChat(ABC):
else:
return self._blocking_nostream_call()
- def prepare(self):
+ async def prepare(self):
pass
def generate_llm_text(self) -> str:
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 a3f4dc0b2..7f6ae856c 100644
--- a/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py
+++ b/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py
@@ -1,6 +1,6 @@
import json
import os
-
+import asyncio
from typing import List, Any, Dict
from pilot.scene.base_message import (
@@ -81,7 +81,7 @@ class ChatExcel(BaseChat):
}
return input_values
- def prepare(self):
+ async def prepare(self):
logger.info(f"{self.chat_mode} prepare start!")
if len(self.history_message) > 0:
return None
@@ -93,7 +93,7 @@ class ChatExcel(BaseChat):
"excel_reader": self.excel_reader,
}
learn_chat = ExcelLearning(**chat_param)
- result = learn_chat.call()
+ result = await learn_chat.nostream_call()
return result
def do_action(self, prompt_response):
From 26716ddeb9e45a9ef0c3030380e82d02bff1de2b Mon Sep 17 00:00:00 2001
From: yhjun1026 <460342015@qq.com>
Date: Fri, 1 Sep 2023 09:56:30 +0800
Subject: [PATCH 6/7] feat(editor): ChatExcel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🔥ChatExcel Mode Operation Manual
---
pilot/scene/base_chat.py | 2 --
.../chat_excel/excel_learning/verify_sql.py | 29 +++++++++++++++++++
pilot/server/static/404.html | 2 +-
pilot/server/static/404/index.html | 2 +-
.../chunks/app/chat/page-81e618fbf297a8f1.js | 1 +
.../chunks/app/chat/page-dc56c69ea8f72017.js | 1 -
.../_buildManifest.js | 0
.../_ssgManifest.js | 0
pilot/server/static/chat/index.html | 2 +-
pilot/server/static/chat/index.txt | 4 +--
pilot/server/static/database/index.html | 2 +-
pilot/server/static/database/index.txt | 2 +-
.../datastores/documents/chunklist/index.html | 2 +-
.../datastores/documents/chunklist/index.txt | 2 +-
.../static/datastores/documents/index.html | 2 +-
.../static/datastores/documents/index.txt | 2 +-
pilot/server/static/datastores/index.html | 2 +-
pilot/server/static/datastores/index.txt | 2 +-
pilot/server/static/index.html | 2 +-
pilot/server/static/index.txt | 2 +-
20 files changed, 45 insertions(+), 18 deletions(-)
create mode 100644 pilot/scene/chat_data/chat_excel/excel_learning/verify_sql.py
create mode 100644 pilot/server/static/_next/static/chunks/app/chat/page-81e618fbf297a8f1.js
delete mode 100644 pilot/server/static/_next/static/chunks/app/chat/page-dc56c69ea8f72017.js
rename pilot/server/static/_next/static/{HHDsBd1B4aAH55tFrMBIv => g4yxzotH2uCI1z7uk8kQC}/_buildManifest.js (100%)
rename pilot/server/static/_next/static/{HHDsBd1B4aAH55tFrMBIv => g4yxzotH2uCI1z7uk8kQC}/_ssgManifest.js (100%)
diff --git a/pilot/scene/base_chat.py b/pilot/scene/base_chat.py
index 726db8304..161f84953 100644
--- a/pilot/scene/base_chat.py
+++ b/pilot/scene/base_chat.py
@@ -231,7 +231,6 @@ class BaseChat(ABC):
except StopAsyncIteration:
break
-
def _blocking_nostream_call(self):
logger.warn(
"_blocking_nostream_call is only temporarily used in webserver and will be deleted soon, please use nostream_call to replace it for higher performance"
@@ -242,7 +241,6 @@ class BaseChat(ABC):
finally:
loop.close()
-
def call(self):
if self.prompt_template.stream_out:
yield self._blocking_stream_call()
diff --git a/pilot/scene/chat_data/chat_excel/excel_learning/verify_sql.py b/pilot/scene/chat_data/chat_excel/excel_learning/verify_sql.py
new file mode 100644
index 000000000..af5c566af
--- /dev/null
+++ b/pilot/scene/chat_data/chat_excel/excel_learning/verify_sql.py
@@ -0,0 +1,29 @@
+import re
+import sqlparse
+
+
+def add_quotes(sql, column_names=[]):
+ parsed = sqlparse.parse(sql)
+ for stmt in parsed:
+ for token in stmt.tokens:
+ deep_quotes(token, column_names)
+ return str(parsed[0])
+
+
+def deep_quotes(token, column_names=[]):
+ if hasattr(token, "tokens"):
+ for token_child in token.tokens:
+ deep_quotes(token_child, column_names)
+ else:
+ if token.ttype == sqlparse.tokens.Name:
+ if len(column_names) > 0:
+ if token.value in column_names:
+ token.value = f'"{token.value}"'
+ else:
+ token.value = f'"{token.value}"'
+
+
+if __name__ == "__main__":
+ sql = "SELECT SUM(预算) AS 总预算 FROM yhj-zx"
+ new_sql = add_quotes(sql, ["预算"])
+ print(new_sql)
diff --git a/pilot/server/static/404.html b/pilot/server/static/404.html
index b9b8281be..954920cda 100644
--- a/pilot/server/static/404.html
+++ b/pilot/server/static/404.html
@@ -1 +1 @@
-
404: This page could not be found 404
This page could not be found.
\ No newline at end of file
+404: This page could not be found 404
This page could not be found.
\ No newline at end of file
diff --git a/pilot/server/static/404/index.html b/pilot/server/static/404/index.html
index b9b8281be..954920cda 100644
--- a/pilot/server/static/404/index.html
+++ b/pilot/server/static/404/index.html
@@ -1 +1 @@
-404: This page could not be found 404
This page could not be found.
\ No newline at end of file
+404: This page could not be found 404
This page could not be found.
\ No newline at end of file
diff --git a/pilot/server/static/_next/static/chunks/app/chat/page-81e618fbf297a8f1.js b/pilot/server/static/_next/static/chunks/app/chat/page-81e618fbf297a8f1.js
new file mode 100644
index 000000000..5fe51b4a6
--- /dev/null
+++ b/pilot/server/static/_next/static/chunks/app/chat/page-81e618fbf297a8f1.js
@@ -0,0 +1 @@
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[929],{86066:function(e,l,t){Promise.resolve().then(t.bind(t,50229))},50229:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return e_}});var a=t(9268),n=t(86006),s=t(57931),i=t(11196),r=t(83192),o=t(35891),d=t(22046),c=t(53113),u=t(71451),h=t(24857),v=t(90545),x=t(48755),m=t(56959),f=t(76447),p=t(61469),j=t(98222),g=t(84257),y=t(77055);function b(e){let{value:l,language:t="mysql",onChange:s,thoughts:i}=e,r=(0,n.useMemo)(()=>i&&i.length>0?"-- ".concat(i," \n").concat(l):l,[l,i]);return(0,a.jsx)(g.ZP,{value:(0,y.WU)(r),language:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},wordWrap:"on"}})}var w=t(89749),Z=t(56008),_=t(90022),N=t(8997),S=t(91440),P=t(84835),k=t.n(P),C=function(e){let{type:l,values:t,title:s,description:i}=e,o=n.useMemo(()=>{if(!((null==t?void 0:t.length)>0))return(0,a.jsx)("div",{className:"h-full",children:(0,a.jsx)(f.Z,{image:f.Z.PRESENTED_IMAGE_SIMPLE,description:"图表数据为空"})});if("IndicatorValue"!==l){if("Table"===l){var e,n,s;let l=k().groupBy(t,"type");return(0,a.jsx)("div",{className:"flex-1 overflow-auto",children:(0,a.jsxs)(r.Z,{"aria-label":"basic table",hoverRow:!0,stickyHeader:!0,children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:Object.keys(l).map(e=>(0,a.jsx)("th",{children:e},e))})}),(0,a.jsx)("tbody",{children:null===(e=Object.values(l))||void 0===e?void 0:null===(n=e[0])||void 0===n?void 0:null===(s=n.map)||void 0===s?void 0:s.call(n,(e,t)=>{var n;return(0,a.jsx)("tr",{children:null===(n=Object.keys(l))||void 0===n?void 0:n.map(e=>{var n;return(0,a.jsx)("td",{children:(null==l?void 0:null===(n=l[e])||void 0===n?void 0:n[t].value)||""},e)})},t)})})]})})}return"BarChart"===l?(0,a.jsx)("div",{className:"flex-1 h-full",children:(0,a.jsxs)(S.Chart,{autoFit:!0,data:t||[],forceUpdate:!0,children:[(0,a.jsx)(S.Interval,{position:"name*value",style:{lineWidth:3,stroke:(0,S.getTheme)().colors10[0]}}),(0,a.jsx)(S.Tooltip,{shared:!0})]})}):"LineChart"===l?(0,a.jsx)("div",{className:"flex-1 h-full",children:(0,a.jsx)(S.Chart,{forceUpdate:!0,autoFit:!0,data:t||[],children:(0,a.jsx)(S.LineAdvance,{shape:"smooth",point:!0,area:!0,position:"name*value",color:"type"})})}):(0,a.jsx)("div",{className:"h-full",children:(0,a.jsx)(f.Z,{image:f.Z.PRESENTED_IMAGE_SIMPLE,description:"暂不支持该图表类型"})})}},[t,l]);return"IndicatorValue"===l&&(null==t?void 0:t.length)>0?(0,a.jsx)("div",{className:"flex flex-row gap-3",children:t.map(e=>(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(_.Z,{sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"justify-around",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:e.name}),(0,a.jsx)(d.ZP,{children:"".concat(e.type,": ").concat(e.value)})]})})},e.name))}):(0,a.jsx)("div",{className:"flex-1 h-full",children:(0,a.jsx)(_.Z,{className:"h-full overflow-auto",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[s&&(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:s}),i&&(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:i}),o]})})})};let{Search:E}=m.default;function O(e){var l,t,s;let{editorValue:i,chartData:o,tableData:d,handleChange:c}=e,u=n.useMemo(()=>o?(0,a.jsx)("div",{className:"flex-1 overflow-auto p-3",style:{flexShrink:0,overflow:"hidden"},children:(0,a.jsx)(C,{...o})}):(0,a.jsx)("div",{}),[o]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,a.jsx)("div",{className:"flex-1",style:{flexShrink:0,overflow:"auto"},children:(0,a.jsx)(b,{value:(null==i?void 0:i.sql)||"",language:"mysql",onChange:c,thoughts:(null==i?void 0:i.thoughts)||""})}),u]}),(0,a.jsx)("div",{className:"h-96 border-[var(--joy-palette-divider)] border-t border-solid overflow-auto",children:(null==d?void 0:null===(l=d.values)||void 0===l?void 0:l.length)>0?(0,a.jsxs)(r.Z,{"aria-label":"basic table",stickyHeader:!0,children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:null==d?void 0:null===(t=d.columns)||void 0===t?void 0:t.map((e,l)=>(0,a.jsx)("th",{children:e},e+l))})}),(0,a.jsx)("tbody",{children:null==d?void 0:null===(s=d.values)||void 0===s?void 0:s.map((e,l)=>{var t;return(0,a.jsx)("tr",{children:null===(t=Object.keys(e))||void 0===t?void 0:t.map(l=>(0,a.jsx)("td",{children:e[l]},l))},l)})})]}):(0,a.jsx)("div",{className:"h-full flex justify-center items-center",children:(0,a.jsx)(f.Z,{})})})]})}var R=function(){var e,l,t,s,r;let[m,f]=n.useState([]),[g,y]=n.useState([]),[b,_]=n.useState(""),[N,S]=n.useState(),[P,k]=n.useState(!0),[C,R]=n.useState(),[q,T]=n.useState(),[A,B]=n.useState(),[L,D]=n.useState(),[I,M]=n.useState(),F=(0,Z.useSearchParams)(),U=F.get("id"),z=F.get("scene"),{data:W,loading:V}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/editor/sql/rounds",{con_uid:U}),{onSuccess:e=>{var l,t;let a=null==e?void 0:null===(l=e.data)||void 0===l?void 0:l[(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.length)-1];a&&S(null==a?void 0:a.round)}}),{run:J,loading:H}=(0,i.Z)(async()=>{var e,l;let t=null===(e=null==W?void 0:null===(l=W.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.PR)("/api/v1/editor/sql/run",{db_name:t,sql:null==A?void 0:A.sql})},{manual:!0,onSuccess:e=>{var l,t;D({columns:null==e?void 0:null===(l=e.data)||void 0===l?void 0:l.colunms,values:null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.values})}}),{run:G,loading:K}=(0,i.Z)(async()=>{var e,l;let t=null===(e=null==W?void 0:null===(l=W.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name,a={db_name:t,sql:null==A?void 0:A.sql};return"chat_dashboard"===z&&(a.chart_type=null==A?void 0:A.showcase),await (0,w.PR)("/api/v1/editor/chart/run",a)},{manual:!0,ready:!!(null==A?void 0:A.sql),onSuccess:e=>{if(null==e?void 0:e.success){var l,t,a,n,s,i,r;D({columns:(null==e?void 0:null===(l=e.data)||void 0===l?void 0:null===(t=l.sql_data)||void 0===t?void 0:t.colunms)||[],values:(null==e?void 0:null===(a=e.data)||void 0===a?void 0:null===(n=a.sql_data)||void 0===n?void 0:n.values)||[]}),(null==e?void 0:null===(s=e.data)||void 0===s?void 0:s.chart_values)?R({type:null==e?void 0:null===(i=e.data)||void 0===i?void 0:i.chart_type,values:null==e?void 0:null===(r=e.data)||void 0===r?void 0:r.chart_values,title:null==A?void 0:A.title,description:null==A?void 0:A.thoughts}):R(void 0)}}}),{run:Y,loading:$}=(0,i.Z)(async()=>{var e,l,t,a,n;let s=null===(e=null==W?void 0:null===(l=W.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.PR)("/api/v1/sql/editor/submit",{conv_uid:U,db_name:s,conv_round:N,old_sql:null==q?void 0:q.sql,old_speak:null==q?void 0:q.thoughts,new_sql:null==A?void 0:A.sql,new_speak:(null===(t=null==A?void 0:null===(a=A.thoughts)||void 0===a?void 0:a.match(/^\n--(.*)\n\n$/))||void 0===t?void 0:null===(n=t[1])||void 0===n?void 0:n.trim())||(null==A?void 0:A.thoughts)})},{manual:!0,onSuccess:e=>{(null==e?void 0:e.success)&&J()}}),{run:Q,loading:X}=(0,i.Z)(async()=>{var e,l,t,a,n,s;let i=null===(e=null==W?void 0:null===(l=W.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.PR)("/api/v1/chart/editor/submit",{conv_uid:U,chart_title:null==A?void 0:A.title,db_name:i,old_sql:null==q?void 0:null===(t=q[I])||void 0===t?void 0:t.sql,new_chart_type:null==A?void 0:A.showcase,new_sql:null==A?void 0:A.sql,new_comment:(null===(a=null==A?void 0:null===(n=A.thoughts)||void 0===n?void 0:n.match(/^\n--(.*)\n\n$/))||void 0===a?void 0:null===(s=a[1])||void 0===s?void 0:s.trim())||(null==A?void 0:A.thoughts),gmt_create:new Date().getTime()})},{manual:!0,onSuccess:e=>{(null==e?void 0:e.success)&&G()}}),{data:ee}=(0,i.Z)(async()=>{var e,l;let t=null===(e=null==W?void 0:null===(l=W.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.Tk)("/v1/editor/db/tables",{db_name:t,page_index:1,page_size:200})},{ready:!!(null===(e=null==W?void 0:null===(l=W.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name),refreshDeps:[null===(t=null==W?void 0:null===(s=W.data)||void 0===s?void 0:s.find(e=>e.round===N))||void 0===t?void 0:t.db_name]}),{run:el}=(0,i.Z)(async e=>await (0,w.Tk)("/v1/editor/sql",{con_uid:U,round:e}),{manual:!0,onSuccess:e=>{let l;try{if(Array.isArray(null==e?void 0:e.data))l=null==e?void 0:e.data,M("0");else if("string"==typeof(null==e?void 0:e.data)){let t=JSON.parse(null==e?void 0:e.data);l=t}else l=null==e?void 0:e.data}catch(e){console.log(e)}finally{T(l),Array.isArray(l)?B(null==l?void 0:l[Number(I||0)]):B(l)}}}),et=n.useMemo(()=>{let e=(l,t)=>l.map(l=>{let n=l.title,s=n.indexOf(b),i=n.substring(0,s),r=n.slice(s+b.length),c=s>-1?(0,a.jsx)(o.Z,{title:((null==l?void 0:l.comment)||(null==l?void 0:l.title))+((null==l?void 0:l.can_null)==="YES"?"(can null)":"(can't null)"),children:(0,a.jsxs)("span",{children:[i,(0,a.jsx)("span",{className:"text-[#1677ff]",children:b}),r,(null==l?void 0:l.type)&&(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",className:"pl-0.5",style:{display:"inline"},children:"[".concat(null==l?void 0:l.type,"]")})]})}):(0,a.jsx)(o.Z,{title:((null==l?void 0:l.comment)||(null==l?void 0:l.title))+((null==l?void 0:l.can_null)==="YES"?"(can null)":"(can't null)"),children:(0,a.jsxs)("span",{children:[n,(null==l?void 0:l.type)&&(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",className:"pl-0.5",style:{display:"inline"},children:"[".concat(null==l?void 0:l.type,"]")})]})});if(l.children){let a=t?String(t)+"_"+l.key:l.key;return{title:n,showTitle:c,key:a,children:e(l.children,a)}}return{title:n,showTitle:c,key:l.key}});return(null==ee?void 0:ee.data)?(f([null==ee?void 0:ee.data.key]),e([null==ee?void 0:ee.data])):[]},[b,ee]),ea=n.useMemo(()=>{let e=[],l=(t,a)=>{if(t&&!((null==t?void 0:t.length)<=0))for(let n=0;n{let t;for(let a=0;al.key===e)?t=n.key:en(e,n.children)&&(t=en(e,n.children)))}return t};function es(e){let l;if(!e)return{sql:"",thoughts:""};let t=e&&e.match(/(--.*)\n([\s\S]*)/),a="";return t&&t.length>=3&&(a=t[1],l=t[2]),{sql:l,thoughts:a}}return n.useEffect(()=>{N&&el(N)},[el,N]),n.useEffect(()=>{q&&"chat_dashboard"===z&&I&&G()},[I,z,q,G]),n.useEffect(()=>{q&&"chat_dashboard"!==z&&J()},[z,q,J]),(0,a.jsxs)("div",{className:"flex flex-col w-full h-full",children:[(0,a.jsx)("div",{className:"bg-[#f8f8f8] border-[var(--joy-palette-divider)] border-b border-solid flex items-center px-3 justify-between",children:(0,a.jsxs)("div",{className:"absolute right-4 top-2",children:[(0,a.jsx)(c.Z,{className:"bg-[#1677ff] text-[#fff] hover:bg-[#1c558e] px-4 cursor-pointer",loading:H||K,size:"sm",onClick:async()=>{"chat_dashboard"===z?G():J()},children:"Run"}),(0,a.jsx)(c.Z,{variant:"outlined",size:"sm",className:"ml-3 px-4 cursor-pointer",loading:$||X,onClick:async()=>{"chat_dashboard"===z?await Q():await Y()},children:"Save"})]})}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsxs)("div",{className:"text h-full border-[var(--joy-palette-divider)] border-r border-solid p-3 max-h-full overflow-auto",style:{width:"300px"},children:[(0,a.jsxs)("div",{className:"flex items-center py-3",children:[(0,a.jsx)(u.Z,{className:"h-4 min-w-[240px]",size:"sm",value:N,onChange:(e,l)=>{S(l)},children:null==W?void 0:null===(r=W.data)||void 0===r?void 0:r.map(e=>(0,a.jsx)(h.Z,{value:null==e?void 0:e.round,children:null==e?void 0:e.round_name},null==e?void 0:e.round))}),(0,a.jsx)(x.Z,{className:"ml-2"})]}),(0,a.jsx)(E,{style:{marginBottom:8},placeholder:"Search",onChange:e=>{let{value:l}=e.target;if(null==ee?void 0:ee.data){if(l){let e=ea.map(e=>e.title.indexOf(l)>-1?en(e.key,et):null).filter((e,l,t)=>e&&t.indexOf(e)===l);f(e)}else f([]);_(l),k(!0)}}}),et&&et.length>0&&(0,a.jsx)(p.Z,{onExpand:e=>{f(e),k(!1)},expandedKeys:m,autoExpandParent:P,treeData:et,fieldNames:{title:"showTitle"}})]}),(0,a.jsx)("div",{className:"flex flex-col flex-1 max-w-full overflow-hidden",children:Array.isArray(q)?(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(v.Z,{className:"h-full",sx:{".ant-tabs-content, .ant-tabs-tabpane-active":{height:"100%"},"& .ant-tabs-card.ant-tabs-top >.ant-tabs-nav .ant-tabs-tab, & .ant-tabs-card.ant-tabs-top >div>.ant-tabs-nav .ant-tabs-tab":{borderRadius:"0"}},children:(0,a.jsx)(j.Z,{className:"h-full dark:text-white px-2",activeKey:I,onChange:e=>{M(e),B(null==q?void 0:q[Number(e)])},items:null==q?void 0:q.map((e,l)=>({key:l+"",label:null==e?void 0:e.title,children:(0,a.jsx)("div",{className:"flex flex-col h-full",children:(0,a.jsx)(O,{editorValue:e,handleChange:e=>{let{sql:l,thoughts:t}=es(e);B({sql:l,thoughts:t})},tableData:L,chartData:C})})}))})})}):(0,a.jsx)(O,{editorValue:q,handleChange:e=>{let{sql:l,thoughts:t}=es(e);B({thoughts:t,sql:l})},tableData:L,chartData:void 0})})]})]})},q=t(69962),T=t(97287),A=t(73141),B=t(45642),L=t(71990),D=e=>{let l=(0,n.useReducer)((e,l)=>({...e,...l}),{...e});return l},I=t(21628),M=t(52040),F=e=>{let{queryAgentURL:l,channel:t,queryBody:a,initHistory:i,runHistoryList:r}=e,[o,d]=D({history:i||[]}),c=(0,Z.useSearchParams)(),u=c.get("id"),{refreshDialogList:h}=(0,s.Cg)(),v=new AbortController;(0,n.useEffect)(()=>{i&&d({history:i})},[i]);let x=async(e,n)=>{if(!e)return;let s=[...o.history,{role:"human",context:e}],i=s.length;d({history:s});let r={conv_uid:u,...n,...a,user_input:e,channel:t};if(!(null==r?void 0:r.conv_uid)){I.ZP.error("conv_uid 不存在,请刷新后重试");return}try{await (0,L.L)("".concat(M.env.API_BASE_URL?M.env.API_BASE_URL:"").concat("/api"+l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:v.signal,openWhenHidden:!0,async onopen(e){if(s.length<=1){var l;h();let e=new URLSearchParams(window.location.search);e.delete("initMessage"),null===(l=window.history)||void 0===l||l.replaceState(null,null,"?".concat(e.toString()))}(!e.ok||e.headers.get("content-type")!==L.a)&&e.status>=400&&e.status<500&&429!==e.status&&e.status},onclose(){console.log("onclose")},onerror(e){throw console.log("onerror"),Error(e)},onmessage:e=>{var l,t,a;if(e.data=null===(l=e.data)||void 0===l?void 0:l.replaceAll("\\n","\n"),"[DONE]"===e.data);else if(null===(t=e.data)||void 0===t?void 0:t.startsWith("[ERROR]"))d({history:[...s,{role:"view",context:null===(a=e.data)||void 0===a?void 0:a.replace("[ERROR]","")}]});else{let l=[...s];e.data&&((null==l?void 0:l[i])?l[i].context="".concat(e.data):l.push({role:"view",context:e.data}),d({history:l}))}}})}catch(e){console.log(e),d({history:[...s,{role:"view",context:"Sorry, We meet some error, please try agin later."}]})}};return{handleChatSubmit:x,history:o.history}},U=t(67830),z=t(54842),W=t(80937),V=t(311),J=t(94244),H=t(35086),G=t(53047),K=t(95066),Y=t(30530),$=t(64747),Q=t(19700),X=t(92391),ee=t(55749),el=t(70781),et=t(42599),ea=t(99398),en=t(49064),es=t(71563),ei=t(86362),er=t(50946),eo=t(52276),ed=t(53534),ec=t(24946),eu=t(98479),eh=t(81616),ev=function(e){var l,t;let{convUid:s,chatMode:i,fileName:r,onComplete:o,...d}=e,[c,u]=(0,n.useState)(!1),[h,v]=(0,n.useState)([]),[x,m]=(0,n.useState)(),[f,p]=(0,n.useState)(),j=async e=>{var l;if(!e){I.ZP.error("Please select the *.(csv|xlsx|xls) file");return}if(!/\.(csv|xlsx|xls)$/.test(null!==(l=e.file.name)&&void 0!==l?l:"")){I.ZP.error("File type must be csv, xlsx or xls");return}v([e.file])},g=async()=>{u(!0),p("normal");try{let e=new FormData;e.append("doc_file",h[0]);let{success:l,err_msg:t}=await ed.Z.post("/api/v1/chat/mode/params/file/load?conv_uid=".concat(s,"&chat_mode=").concat(i),e,{timeout:36e5,headers:{"Content-Type":"multipart/form-data"},onUploadProgress(e){let l=Math.ceil(e.loaded/(e.total||0)*100);m(l)}});if(!l){I.ZP.error(t);return}I.ZP.success("success"),p("success"),o()}catch(e){p("exception"),I.ZP.error((null==e?void 0:e.message)||"Upload Error")}finally{u(!1)}};return(0,a.jsxs)("div",{className:"w-full",children:[!r&&(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(es.Z,{placement:"topLeft",title:"Files cannot be changed after upload",children:(0,a.jsx)(ei.default,{disabled:c,className:"mr-1",beforeUpload:()=>!1,fileList:h,name:"file",accept:".csv,.xlsx,.xls",multiple:!1,onChange:j,showUploadList:{showDownloadIcon:!1,showPreviewIcon:!1,showRemoveIcon:!1},itemRender:()=>(0,a.jsx)(a.Fragment,{}),...d,children:(0,a.jsx)(er.ZP,{className:"flex justify-center items-center dark:bg-[#4e4f56] dark:text-gray-200",disabled:c,icon:(0,a.jsx)(ec.Z,{}),children:"Select File"})})}),(0,a.jsx)(er.ZP,{type:"primary",loading:c,className:"flex justify-center items-center",disabled:!h.length,icon:(0,a.jsx)(eu.Z,{}),onClick:g,children:c?100===x?"Analysis":"Uploading":"Upload"})]}),(!!h.length||r)&&(0,a.jsxs)("div",{className:"mt-2 text-gray-500 text-sm flex items-center",children:[(0,a.jsx)(eh.Z,{className:"mr-2"}),(0,a.jsx)("span",{children:null!==(t=null==h?void 0:null===(l=h[0])||void 0===l?void 0:l.name)&&void 0!==t?t:r})]}),("number"==typeof x||!!r)&&(0,a.jsx)(eo.Z,{className:"mb-0",percent:r?100:x,size:"small",status:r?"success":f})]})};let ex=X.z.object({query:X.z.string().min(1)});var em=e=>{var l;let{messages:s,dialogue:i,onSubmit:r,readOnly:o,paramsList:d,onRefreshHistory:x,clearIntialMessage:m,setChartsData:f}=e,p=(0,Z.useSearchParams)(),j=p.get("initMessage"),g=p.get("spaceNameOriginal"),y=p.get("id"),b=p.get("scene"),w="chat_dashboard"===b,N=(0,n.useRef)(null),[S,P]=(0,n.useState)(!1),[C,E]=(0,n.useState)(),[O,R]=(0,n.useState)(!1),[q,T]=(0,n.useState)(),[A,B]=(0,n.useState)(s),[L,D]=(0,n.useState)(""),M=(0,Q.cI)({resolver:(0,U.F)(ex),defaultValues:{}}),F=async e=>{let{query:l}=e;try{P(!0),M.reset(),await r(l,{select_param:"chat_excel"===b?null==i?void 0:i.select_param:null==d?void 0:d[C]})}catch(e){}finally{P(!1)}},X=async()=>{try{var e;let l=new URLSearchParams(window.location.search),t=l.get("initMessage");l.delete("initMessage"),null===(e=window.history)||void 0===e||e.replaceState(null,null,"?".concat(l.toString())),await F({query:t})}catch(e){console.log(e)}finally{null==m||m()}},es={overrides:{code:e=>{let{children:l}=e;return(0,a.jsx)(ea.Z,{language:"javascript",style:en.Z,children:l})}},wrapper:n.Fragment},ei=e=>{let l=e;try{l=JSON.parse(e)}catch(e){console.log(e)}return l},er=(0,n.useMemo)(()=>{if("function"==typeof(null==window?void 0:window.fetch)){let e=t(62631);return t(25204),t(82372),e.default}},[]);return(0,n.useEffect)(()=>{N.current&&N.current.scrollTo(0,N.current.scrollHeight)},[null==s?void 0:s.length]),(0,n.useEffect)(()=>{j&&s.length<=0&&X()},[j,s.length]),(0,n.useEffect)(()=>{var e,l;d&&(null===(e=Object.keys(d||{}))||void 0===e?void 0:e.length)>0&&E(g||(null===(l=Object.keys(d||{}))||void 0===l?void 0:l[0]))},[d]),(0,n.useEffect)(()=>{if(w){let e=k().cloneDeep(s);e.forEach(e=>{(null==e?void 0:e.role)==="view"&&"string"==typeof(null==e?void 0:e.context)&&(e.context=ei(null==e?void 0:e.context))}),B(e.filter(e=>["view","human"].includes(e.role)))}else B(s.filter(e=>["view","human"].includes(e.role)))},[w,s]),(0,a.jsxs)("div",{className:"w-full h-full",children:[(0,a.jsxs)(W.Z,{className:"w-full h-full bg-[#fefefe] dark:bg-[#212121]",sx:{table:{borderCollapse:"collapse",border:"1px solid #ccc",width:"100%"},"th, td":{border:"1px solid #ccc",padding:"10px",textAlign:"center"}},children:[(0,a.jsxs)(W.Z,{ref:N,direction:"column",sx:{overflowY:"auto",maxHeight:"100%",flex:1},children:[null==A?void 0:A.map((e,l)=>{var t,n;return(0,a.jsx)(W.Z,{children:(0,a.jsx)(_.Z,{size:"sm",variant:"outlined",color:"view"===e.role?"primary":"neutral",sx:l=>({background:"view"===e.role?"var(--joy-palette-primary-softBg, var(--joy-palette-primary-100, #DDF1FF))":"unset",border:"unset",borderRadius:"unset",padding:"24px 0 26px 0",lineHeight:"24px"}),children:(0,a.jsxs)(v.Z,{sx:{width:"76%",margin:"0 auto"},className:"flex flex-row",children:["view"===e.role?(0,a.jsx)(el.Z,{className:"mr-2 mt-1"}):(0,a.jsx)(ee.Z,{className:"mr-2 mt-1"}),(0,a.jsx)("div",{className:"inline align-middle mt-0.5 max-w-full flex-1 overflow-auto",children:w&&"view"===e.role&&"object"==typeof(null==e?void 0:e.context)?(0,a.jsxs)(a.Fragment,{children:["[".concat(e.context.template_name,"]: "),(0,a.jsx)(V.Z,{sx:{color:"#1677ff"},component:"button",onClick:()=>{R(!0),T(l),D(JSON.stringify(null==e?void 0:e.context,null,2))},children:e.context.template_introduce||"More Details"})]}):(0,a.jsx)(a.Fragment,{children:"string"==typeof e.context&&(0,a.jsx)(et.Z,{options:es,children:null===(t=e.context)||void 0===t?void 0:null===(n=t.replaceAll)||void 0===n?void 0:n.call(t,"\\n","\n")})})})]})})},l)}),S&&(0,a.jsx)(J.Z,{variant:"soft",color:"neutral",size:"sm",sx:{mx:"auto",my:2}})]}),!o&&(0,a.jsx)(v.Z,{className:"bg-[#fefefe] dark:bg-[#212121] before:bg-[#fefefe] before:dark:bg-[#212121]",sx:{position:"relative","&::before":{content:'" "',position:"absolute",top:"-18px",left:"0",right:"0",width:"100%",margin:"0 auto",height:"20px",filter:"blur(10px)",zIndex:2}},children:(0,a.jsxs)("form",{style:{maxWidth:"100%",width:"76%",position:"relative",display:"flex",marginTop:"auto",overflow:"visible",background:"none",justifyContent:"center",marginLeft:"auto",marginRight:"auto",flexDirection:"column",gap:"12px",paddingBottom:"58px",paddingTop:"20px"},onSubmit:e=>{e.stopPropagation(),M.handleSubmit(F)(e)},children:[(0,a.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[Object.keys(d||{}).length>0&&(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsx)(u.Z,{value:C,onChange:(e,l)=>{E(l)},sx:{maxWidth:"100%"},children:null===(l=Object.keys(d||{}))||void 0===l?void 0:l.map(e=>(0,a.jsx)(h.Z,{value:e,children:e},e))})}),"chat_excel"===b&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(ev,{convUid:y,chatMode:b,fileName:null==i?void 0:i.select_param,onComplete:()=>{null==m||m(),null==x||x()}})})]}),(0,a.jsx)(H.ZP,{disabled:"chat_excel"===b&&!(null==i?void 0:i.select_param),className:"w-full h-12",variant:"outlined",endDecorator:(0,a.jsx)(G.ZP,{type:"submit",disabled:S,children:(0,a.jsx)(z.Z,{})}),...M.register("query")})]})})]}),(0,a.jsx)(K.Z,{open:O,onClose:()=>{R(!1)},children:(0,a.jsxs)(Y.Z,{"aria-labelledby":"variant-modal-title","aria-describedby":"variant-modal-description",children:[(0,a.jsx)($.Z,{}),(0,a.jsxs)(v.Z,{sx:{marginTop:"32px"},children:[!!er&&(0,a.jsx)(er,{mode:"json",value:L,height:"600px",width:"820px",onChange:D,placeholder:"默认json数据",debounceChangePeriod:100,showPrintMargin:!0,showGutter:!0,highlightActiveLine:!0,setOptions:{useWorker:!0,showLineNumbers:!0,highlightSelectedWord:!0,tabSize:2}}),(0,a.jsx)(c.Z,{variant:"outlined",className:"w-full",sx:{marginTop:"12px"},onClick:()=>{if(q)try{let e=k().cloneDeep(A),l=JSON.parse(L);e[q].context=l,B(e),null==f||f(null==l?void 0:l.charts),R(!1),D("")}catch(e){I.ZP.error("JSON 格式化出错")}},children:"Submit"})]})]})})]})};function ef(e){let{key:l,chart:t}=e;return(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(_.Z,{className:"h-full",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:t.chart_name}),(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:t.chart_desc}),(0,a.jsx)("div",{className:"h-[300px]",children:(0,a.jsx)(S.Chart,{autoFit:!0,data:t.values,children:(0,a.jsx)(S.LineAdvance,{shape:"smooth",point:!0,area:!0,position:"name*value",color:"type"})})})]})})},l)}function ep(e){let{key:l,chart:t}=e;return(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(_.Z,{className:"h-full",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:t.chart_name}),(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:t.chart_desc}),(0,a.jsx)("div",{className:"h-[300px]",children:(0,a.jsxs)(S.Chart,{autoFit:!0,data:t.values,children:[(0,a.jsx)(S.Interval,{position:"name*value",style:{lineWidth:3,stroke:(0,S.getTheme)().colors10[0]}}),(0,a.jsx)(S.Tooltip,{shared:!0})]})})]})})},l)}function ej(e){var l,t;let{key:n,chart:s}=e,i=(0,P.groupBy)(s.values,"type");return(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(_.Z,{className:"h-full overflow-auto",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:s.chart_name}),"\xb7",(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:s.chart_desc}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsxs)(r.Z,{"aria-label":"basic table",stripe:"odd",hoverRow:!0,borderAxis:"bothBetween",children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:Object.keys(i).map(e=>(0,a.jsx)("th",{children:e},e))})}),(0,a.jsx)("tbody",{children:null===(l=Object.values(i))||void 0===l?void 0:null===(t=l[0])||void 0===t?void 0:t.map((e,l)=>{var t;return(0,a.jsx)("tr",{children:null===(t=Object.keys(i))||void 0===t?void 0:t.map(e=>{var t;return(0,a.jsx)("td",{children:(null==i?void 0:null===(t=i[e])||void 0===t?void 0:t[l].value)||""},e)})},l)})})]})})]})})},n)}let eg=()=>(0,a.jsxs)(_.Z,{className:"h-full w-full flex bg-transparent",children:[(0,a.jsx)(q.Z,{animation:"wave",variant:"text",level:"body2"}),(0,a.jsx)(q.Z,{animation:"wave",variant:"text",level:"body2"}),(0,a.jsx)(T.Z,{ratio:"21/9",className:"flex-1",sx:{["& .".concat(A.Z.content)]:{height:"100%"}},children:(0,a.jsx)(q.Z,{variant:"overlay",className:"h-full"})})]});var ey=()=>{var e;let[l,t]=(0,n.useState)();n.useRef(null);let[r,o]=n.useState(!1),c=(0,Z.useSearchParams)(),{dialogueList:u,refreshDialogList:h}=(0,s.Cg)(),x=c.get("id"),m=c.get("scene"),f=(0,n.useMemo)(()=>(null!==(e=null==u?void 0:u.data)&&void 0!==e?e:[]).find(e=>e.conv_uid===x),[x,u]),{data:p,run:j}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/chat/dialogue/messages/history",{con_uid:x}),{ready:!!x,refreshDeps:[x]}),{data:g,run:y}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/chat/db/list"),{ready:!!m&&!!["chat_with_db_execute","chat_with_db_qa"].includes(m)}),{data:b}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/chat/db/support/type"),{ready:!!m&&!!["chat_with_db_execute","chat_with_db_qa"].includes(m)}),{history:S,handleChatSubmit:P}=F({queryAgentURL:"/v1/chat/completions",queryBody:{conv_uid:x,chat_mode:m||"chat_normal"},initHistory:null==p?void 0:p.data,runHistoryList:j}),{data:k,run:C}=(0,i.Z)(async()=>await (0,w.Kw)("/v1/chat/mode/params/list?chat_mode=".concat(m)),{ready:!!m,refreshDeps:[x,m]});(0,n.useEffect)(()=>{try{var e;let l=null==S?void 0:null===(e=S[S.length-1])||void 0===e?void 0:e.context,a=JSON.parse(l);t((null==a?void 0:a.template_name)==="report"?null==a?void 0:a.charts:void 0)}catch(e){t(void 0)}},[S]);let E=(0,n.useMemo)(()=>{if(l){let e=[],t=null==l?void 0:l.filter(e=>"IndicatorValue"===e.chart_type);t.length>0&&e.push({charts:t,type:"IndicatorValue"});let a=null==l?void 0:l.filter(e=>"IndicatorValue"!==e.chart_type),n=a.length,s=0;return[[0],[1],[2],[1,2],[1,3],[2,1,2],[2,1,3],[3,1,3],[3,2,3]][n].forEach(l=>{if(l>0){let t=a.slice(s,s+l);s+=l,e.push({charts:t})}}),e}},[l]);return(0,a.jsxs)(B.Z,{container:!0,spacing:2,className:"h-full overflow-auto",sx:{flexGrow:1},children:[l&&(0,a.jsx)(B.Z,{xs:8,className:"max-h-full",children:(0,a.jsx)("div",{className:"flex flex-col gap-3 h-full",children:null==E?void 0:E.map((e,l)=>(0,a.jsx)("div",{className:"".concat((null==e?void 0:e.type)!=="IndicatorValue"?"flex gap-3":""),children:e.charts.map(e=>"IndicatorValue"===e.chart_type?(0,a.jsx)("div",{className:"flex flex-row gap-3",children:e.values.map(e=>(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(_.Z,{sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"justify-around",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:e.name}),(0,a.jsx)(d.ZP,{children:e.value})]})})},e.name))},e.chart_uid):"LineChart"===e.chart_type?(0,a.jsx)(ef,{chart:e},e.chart_uid):"BarChart"===e.chart_type?(0,a.jsx)(ep,{chart:e},e.chart_uid):"Table"===e.chart_type?(0,a.jsx)(ej,{chart:e},e.chart_uid):void 0)},"chart_row_".concat(l)))})}),!l&&"chat_dashboard"===m&&(0,a.jsx)(B.Z,{xs:8,className:"max-h-full p-6",children:(0,a.jsx)("div",{className:"flex flex-col gap-3 h-full",children:(0,a.jsxs)(B.Z,{container:!0,spacing:2,sx:{flexGrow:1},children:[(0,a.jsx)(B.Z,{xs:8,children:(0,a.jsx)(v.Z,{className:"h-full w-full",sx:{display:"flex",gap:2},children:(0,a.jsx)(eg,{})})}),(0,a.jsx)(B.Z,{xs:4,children:(0,a.jsx)(eg,{})}),(0,a.jsx)(B.Z,{xs:4,children:(0,a.jsx)(eg,{})}),(0,a.jsx)(B.Z,{xs:8,children:(0,a.jsx)(eg,{})})]})})}),(0,a.jsx)(B.Z,{xs:"chat_dashboard"===m?4:12,className:"h-full max-h-full",children:(0,a.jsx)("div",{className:"h-full",style:{boxShadow:"chat_dashboard"===m?"0px 0px 9px 0px #c1c0c080":"unset"},children:(0,a.jsx)(em,{clearIntialMessage:async()=>{await h()},dialogue:f,dbList:null==g?void 0:g.data,runDbList:y,onRefreshHistory:j,supportTypes:null==b?void 0:b.data,messages:S||[],onSubmit:P,paramsList:null==k?void 0:k.data,runParamsList:C,setChartsData:t})})})]})},eb=t(32093),ew=t(97237);function eZ(){let{isContract:e,setIsContract:l}=(0,s.Cg)();return(0,a.jsxs)("div",{className:"relative w-56 h-10 mx-auto p-2 flex justify-center items-center bg-[#ece9e0] rounded-3xl model-tab dark:text-violet-600 z-10 ".concat(e?"editor-tab":""),children:[(0,a.jsxs)("div",{className:"z-10 w-[50%] text-center cursor-pointer",onClick:()=>{l(!1)},children:[(0,a.jsx)("span",{children:"Preview"}),(0,a.jsx)(ew.Z,{className:"ml-1"})]}),(0,a.jsxs)("div",{className:"z-10 w-[50%] text-center cursor-pointer",onClick:()=>{l(!0)},children:[(0,a.jsx)("span",{children:"Editor"}),(0,a.jsx)(eb.Z,{className:"ml-1"})]})]})}t(95389);var e_=()=>{let{isContract:e,setIsContract:l,setIsMenuExpand:t}=(0,s.Cg)(),i=(0,Z.useSearchParams)(),r=i.get("scene"),o=i.get("id"),d=r&&["chat_with_db_execute","chat_dashboard"].includes(r);return(0,n.useEffect)(()=>{t("chat_dashboard"!==r),o&&r&&l(!1)},[o,r,t,l]),(0,a.jsxs)(a.Fragment,{children:[d&&(0,a.jsx)("div",{className:"leading-[3rem] text-right pr-3 h-12 flex justify-center",children:(0,a.jsx)("div",{className:"flex items-center cursor-pointer",children:(0,a.jsx)(eZ,{})})}),e?(0,a.jsx)(R,{}):(0,a.jsx)(ey,{})]})}},57931:function(e,l,t){"use strict";t.d(l,{ZP:function(){return c},Cg:function(){return o}});var a=t(9268),n=t(11196),s=t(89749),i=t(86006),r=t(56008);let[o,d]=function(){let e=i.createContext(void 0);return[function(){let l=i.useContext(e);if(void 0===l)throw Error("useCtx must be inside a Provider with a value");return l},e.Provider]}();var c=e=>{let{children:l}=e,t=(0,r.useSearchParams)(),o=t.get("scene"),[c,u]=i.useState(!1),[h,v]=i.useState("chat_dashboard"!==o),{run:x,data:m,refresh:f}=(0,n.Z)(async()=>await (0,s.Tk)("/v1/chat/dialogue/list"),{manual:!0});return(0,a.jsx)(d,{value:{isContract:c,isMenuExpand:h,dialogueList:m,setIsContract:u,setIsMenuExpand:v,queryDialogueList:x,refreshDialogList:f},children:l})}},53534:function(e,l,t){"use strict";var a=t(24214),n=t(52040);let s=a.Z.create({baseURL:n.env.API_BASE_URL});s.defaults.timeout=1e4,s.interceptors.response.use(e=>e.data,e=>Promise.reject(e)),l.Z=s},89749:function(e,l,t){"use strict";t.d(l,{Ej:function(){return u},Kw:function(){return d},PR:function(){return c},Tk:function(){return o}});var a=t(21628),n=t(53534),s=t(84835);let i={"content-type":"application/json"},r=e=>{if(!(0,s.isPlainObject)(e))return JSON.stringify(e);let l={...e};for(let e in l){let t=l[e];"string"==typeof t&&(l[e]=t.trim())}return JSON.stringify(l)},o=(e,l)=>{if(l){let t=Object.keys(l).filter(e=>void 0!==l[e]&&""!==l[e]).map(e=>"".concat(e,"=").concat(l[e])).join("&");t&&(e+="?".concat(t))}return n.Z.get("/api"+e,{headers:i}).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)})},d=(e,l)=>{let t=r(l);return n.Z.post("/api"+e,{body:t,headers:i}).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)})},c=(e,l)=>n.Z.post(e,l,{headers:i}).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)}),u=(e,l)=>n.Z.post(e,l).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)})},95389:function(){}},function(e){e.O(0,[180,757,282,355,932,358,649,191,230,715,569,196,86,919,579,537,767,341,116,959,554,253,769,744],function(){return e(e.s=86066)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/pilot/server/static/_next/static/chunks/app/chat/page-dc56c69ea8f72017.js b/pilot/server/static/_next/static/chunks/app/chat/page-dc56c69ea8f72017.js
deleted file mode 100644
index 05bdd0c91..000000000
--- a/pilot/server/static/_next/static/chunks/app/chat/page-dc56c69ea8f72017.js
+++ /dev/null
@@ -1 +0,0 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[929],{86066:function(e,l,t){Promise.resolve().then(t.bind(t,50229))},50229:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return e_}});var a=t(9268),n=t(86006),s=t(57931),i=t(11196),r=t(83192),o=t(35891),d=t(22046),c=t(53113),u=t(71451),h=t(24857),v=t(90545),x=t(48755),m=t(56959),f=t(76447),p=t(61469),j=t(98222),g=t(84257),y=t(77055);function b(e){let{value:l,language:t="mysql",onChange:s,thoughts:i}=e,r=(0,n.useMemo)(()=>i&&i.length>0?"-- ".concat(i," \n").concat(l):l,[l,i]);return(0,a.jsx)(g.ZP,{value:(0,y.WU)(r),language:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},wordWrap:"on"}})}var w=t(89749),Z=t(56008),_=t(90022),N=t(8997),S=t(91440),P=t(84835),k=t.n(P),C=function(e){let{type:l,values:t,title:s,description:i}=e,o=n.useMemo(()=>{if(!((null==t?void 0:t.length)>0))return(0,a.jsx)("div",{className:"h-full",children:(0,a.jsx)(f.Z,{image:f.Z.PRESENTED_IMAGE_SIMPLE,description:"图表数据为空"})});if("IndicatorValue"!==l){if("Table"===l){var e,n,s;let l=k().groupBy(t,"type");return(0,a.jsx)("div",{className:"flex-1 overflow-auto",children:(0,a.jsxs)(r.Z,{"aria-label":"basic table",hoverRow:!0,stickyHeader:!0,children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:Object.keys(l).map(e=>(0,a.jsx)("th",{children:e},e))})}),(0,a.jsx)("tbody",{children:null===(e=Object.values(l))||void 0===e?void 0:null===(n=e[0])||void 0===n?void 0:null===(s=n.map)||void 0===s?void 0:s.call(n,(e,t)=>{var n;return(0,a.jsx)("tr",{children:null===(n=Object.keys(l))||void 0===n?void 0:n.map(e=>{var n;return(0,a.jsx)("td",{children:(null==l?void 0:null===(n=l[e])||void 0===n?void 0:n[t].value)||""},e)})},t)})})]})})}return"BarChart"===l?(0,a.jsx)("div",{className:"flex-1 h-full",children:(0,a.jsxs)(S.Chart,{autoFit:!0,data:t||[],forceUpdate:!0,children:[(0,a.jsx)(S.Interval,{position:"name*value",style:{lineWidth:3,stroke:(0,S.getTheme)().colors10[0]}}),(0,a.jsx)(S.Tooltip,{shared:!0})]})}):"LineChart"===l?(0,a.jsx)("div",{className:"flex-1 h-full",children:(0,a.jsx)(S.Chart,{forceUpdate:!0,autoFit:!0,data:t||[],children:(0,a.jsx)(S.LineAdvance,{shape:"smooth",point:!0,area:!0,position:"name*value",color:"type"})})}):(0,a.jsx)("div",{className:"h-full",children:(0,a.jsx)(f.Z,{image:f.Z.PRESENTED_IMAGE_SIMPLE,description:"暂不支持该图表类型"})})}},[t,l]);return"IndicatorValue"===l&&(null==t?void 0:t.length)>0?(0,a.jsx)("div",{className:"flex flex-row gap-3",children:t.map(e=>(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(_.Z,{sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"justify-around",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:e.name}),(0,a.jsx)(d.ZP,{children:"".concat(e.type,": ").concat(e.value)})]})})},e.name))}):(0,a.jsx)("div",{className:"flex-1 h-full",children:(0,a.jsx)(_.Z,{className:"h-full overflow-auto",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[s&&(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:s}),i&&(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:i}),o]})})})};let{Search:E}=m.default;function O(e){var l,t,s;let{editorValue:i,chartData:o,tableData:d,handleChange:c}=e,u=n.useMemo(()=>o?(0,a.jsx)("div",{className:"flex-1 overflow-auto p-3",style:{flexShrink:0,overflow:"hidden"},children:(0,a.jsx)(C,{...o})}):(0,a.jsx)("div",{}),[o]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,a.jsx)("div",{className:"flex-1",style:{flexShrink:0,overflow:"auto"},children:(0,a.jsx)(b,{value:(null==i?void 0:i.sql)||"",language:"mysql",onChange:c,thoughts:(null==i?void 0:i.thoughts)||""})}),u]}),(0,a.jsx)("div",{className:"h-96 border-[var(--joy-palette-divider)] border-t border-solid overflow-auto",children:(null==d?void 0:null===(l=d.values)||void 0===l?void 0:l.length)>0?(0,a.jsxs)(r.Z,{"aria-label":"basic table",stickyHeader:!0,children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:null==d?void 0:null===(t=d.columns)||void 0===t?void 0:t.map((e,l)=>(0,a.jsx)("th",{children:e},e+l))})}),(0,a.jsx)("tbody",{children:null==d?void 0:null===(s=d.values)||void 0===s?void 0:s.map((e,l)=>{var t;return(0,a.jsx)("tr",{children:null===(t=Object.keys(e))||void 0===t?void 0:t.map(l=>(0,a.jsx)("td",{children:e[l]},l))},l)})})]}):(0,a.jsx)("div",{className:"h-full flex justify-center items-center",children:(0,a.jsx)(f.Z,{})})})]})}var R=function(){var e,l,t,s,r;let[m,f]=n.useState([]),[g,y]=n.useState([]),[b,_]=n.useState(""),[N,S]=n.useState(),[P,k]=n.useState(!0),[C,R]=n.useState(),[q,T]=n.useState(),[A,B]=n.useState(),[L,D]=n.useState(),[I,M]=n.useState(),F=(0,Z.useSearchParams)(),U=F.get("id"),z=F.get("scene"),{data:J,loading:W}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/editor/sql/rounds",{con_uid:U}),{onSuccess:e=>{var l,t;let a=null==e?void 0:null===(l=e.data)||void 0===l?void 0:l[(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.length)-1];a&&S(null==a?void 0:a.round)}}),{run:V,loading:H}=(0,i.Z)(async()=>{var e,l;let t=null===(e=null==J?void 0:null===(l=J.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.PR)("/api/v1/editor/sql/run",{db_name:t,sql:null==A?void 0:A.sql})},{manual:!0,onSuccess:e=>{var l,t;D({columns:null==e?void 0:null===(l=e.data)||void 0===l?void 0:l.colunms,values:null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.values})}}),{run:G,loading:K}=(0,i.Z)(async()=>{var e,l;let t=null===(e=null==J?void 0:null===(l=J.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name,a={db_name:t,sql:null==A?void 0:A.sql};return"chat_dashboard"===z&&(a.chart_type=null==A?void 0:A.showcase),await (0,w.PR)("/api/v1/editor/chart/run",a)},{manual:!0,ready:!!(null==A?void 0:A.sql),onSuccess:e=>{if(null==e?void 0:e.success){var l,t,a,n,s,i,r;D({columns:(null==e?void 0:null===(l=e.data)||void 0===l?void 0:null===(t=l.sql_data)||void 0===t?void 0:t.colunms)||[],values:(null==e?void 0:null===(a=e.data)||void 0===a?void 0:null===(n=a.sql_data)||void 0===n?void 0:n.values)||[]}),(null==e?void 0:null===(s=e.data)||void 0===s?void 0:s.chart_values)?R({type:null==e?void 0:null===(i=e.data)||void 0===i?void 0:i.chart_type,values:null==e?void 0:null===(r=e.data)||void 0===r?void 0:r.chart_values,title:null==A?void 0:A.title,description:null==A?void 0:A.thoughts}):R(void 0)}}}),{run:Y,loading:$}=(0,i.Z)(async()=>{var e,l,t,a,n;let s=null===(e=null==J?void 0:null===(l=J.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.PR)("/api/v1/sql/editor/submit",{conv_uid:U,db_name:s,conv_round:N,old_sql:null==q?void 0:q.sql,old_speak:null==q?void 0:q.thoughts,new_sql:null==A?void 0:A.sql,new_speak:(null===(t=null==A?void 0:null===(a=A.thoughts)||void 0===a?void 0:a.match(/^\n--(.*)\n\n$/))||void 0===t?void 0:null===(n=t[1])||void 0===n?void 0:n.trim())||(null==A?void 0:A.thoughts)})},{manual:!0,onSuccess:e=>{(null==e?void 0:e.success)&&V()}}),{run:Q,loading:X}=(0,i.Z)(async()=>{var e,l,t,a,n,s;let i=null===(e=null==J?void 0:null===(l=J.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.PR)("/api/v1/chart/editor/submit",{conv_uid:U,chart_title:null==A?void 0:A.title,db_name:i,old_sql:null==q?void 0:null===(t=q[I])||void 0===t?void 0:t.sql,new_chart_type:null==A?void 0:A.showcase,new_sql:null==A?void 0:A.sql,new_comment:(null===(a=null==A?void 0:null===(n=A.thoughts)||void 0===n?void 0:n.match(/^\n--(.*)\n\n$/))||void 0===a?void 0:null===(s=a[1])||void 0===s?void 0:s.trim())||(null==A?void 0:A.thoughts),gmt_create:new Date().getTime()})},{manual:!0,onSuccess:e=>{(null==e?void 0:e.success)&&G()}}),{data:ee}=(0,i.Z)(async()=>{var e,l;let t=null===(e=null==J?void 0:null===(l=J.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name;return await (0,w.Tk)("/v1/editor/db/tables",{db_name:t,page_index:1,page_size:200})},{ready:!!(null===(e=null==J?void 0:null===(l=J.data)||void 0===l?void 0:l.find(e=>e.round===N))||void 0===e?void 0:e.db_name),refreshDeps:[null===(t=null==J?void 0:null===(s=J.data)||void 0===s?void 0:s.find(e=>e.round===N))||void 0===t?void 0:t.db_name]}),{run:el}=(0,i.Z)(async e=>await (0,w.Tk)("/v1/editor/sql",{con_uid:U,round:e}),{manual:!0,onSuccess:e=>{let l;try{if(Array.isArray(null==e?void 0:e.data))l=null==e?void 0:e.data,M("0");else if("string"==typeof(null==e?void 0:e.data)){let t=JSON.parse(null==e?void 0:e.data);l=t}else l=null==e?void 0:e.data}catch(e){console.log(e)}finally{T(l),Array.isArray(l)?B(null==l?void 0:l[Number(I||0)]):B(l)}}}),et=n.useMemo(()=>{let e=(l,t)=>l.map(l=>{let n=l.title,s=n.indexOf(b),i=n.substring(0,s),r=n.slice(s+b.length),c=s>-1?(0,a.jsx)(o.Z,{title:((null==l?void 0:l.comment)||(null==l?void 0:l.title))+((null==l?void 0:l.can_null)==="YES"?"(can null)":"(can't null)"),children:(0,a.jsxs)("span",{children:[i,(0,a.jsx)("span",{className:"text-[#1677ff]",children:b}),r,(null==l?void 0:l.type)&&(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",className:"pl-0.5",style:{display:"inline"},children:"[".concat(null==l?void 0:l.type,"]")})]})}):(0,a.jsx)(o.Z,{title:((null==l?void 0:l.comment)||(null==l?void 0:l.title))+((null==l?void 0:l.can_null)==="YES"?"(can null)":"(can't null)"),children:(0,a.jsxs)("span",{children:[n,(null==l?void 0:l.type)&&(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",className:"pl-0.5",style:{display:"inline"},children:"[".concat(null==l?void 0:l.type,"]")})]})});if(l.children){let a=t?String(t)+"_"+l.key:l.key;return{title:n,showTitle:c,key:a,children:e(l.children,a)}}return{title:n,showTitle:c,key:l.key}});return(null==ee?void 0:ee.data)?(f([null==ee?void 0:ee.data.key]),e([null==ee?void 0:ee.data])):[]},[b,ee]),ea=n.useMemo(()=>{let e=[],l=(t,a)=>{if(t&&!((null==t?void 0:t.length)<=0))for(let n=0;n{let t;for(let a=0;al.key===e)?t=n.key:en(e,n.children)&&(t=en(e,n.children)))}return t};return n.useEffect(()=>{N&&el(N)},[el,N]),n.useEffect(()=>{q&&"chat_dashboard"===z&&I&&G()},[I,z,q,G]),n.useEffect(()=>{q&&"chat_dashboard"!==z&&V()},[z,q,V]),(0,a.jsxs)("div",{className:"flex flex-col w-full h-full",children:[(0,a.jsx)("div",{className:"bg-[#f8f8f8] border-[var(--joy-palette-divider)] border-b border-solid flex items-center px-3 justify-between",children:(0,a.jsxs)("div",{className:"absolute right-4 top-2",children:[(0,a.jsx)(c.Z,{className:"bg-[#1677ff] text-[#fff] hover:bg-[#1c558e] px-4 cursor-pointer",loading:H||K,size:"sm",onClick:async()=>{"chat_dashboard"===z?G():V()},children:"Run"}),(0,a.jsx)(c.Z,{variant:"outlined",size:"sm",className:"ml-3 px-4 cursor-pointer",loading:$||X,onClick:async()=>{"chat_dashboard"===z?await Q():await Y()},children:"Save"})]})}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-auto",children:[(0,a.jsxs)("div",{className:"text h-full border-[var(--joy-palette-divider)] border-r border-solid p-3 max-h-full overflow-auto",style:{width:"300px"},children:[(0,a.jsxs)("div",{className:"flex items-center py-3",children:[(0,a.jsx)(u.Z,{className:"h-4 min-w-[240px]",size:"sm",value:N,onChange:(e,l)=>{S(l)},children:null==J?void 0:null===(r=J.data)||void 0===r?void 0:r.map(e=>(0,a.jsx)(h.Z,{value:null==e?void 0:e.round,children:null==e?void 0:e.round_name},null==e?void 0:e.round))}),(0,a.jsx)(x.Z,{className:"ml-2"})]}),(0,a.jsx)(E,{style:{marginBottom:8},placeholder:"Search",onChange:e=>{let{value:l}=e.target;if(null==ee?void 0:ee.data){if(l){let e=ea.map(e=>e.title.indexOf(l)>-1?en(e.key,et):null).filter((e,l,t)=>e&&t.indexOf(e)===l);f(e)}else f([]);_(l),k(!0)}}}),et&&et.length>0&&(0,a.jsx)(p.Z,{onExpand:e=>{f(e),k(!1)},expandedKeys:m,autoExpandParent:P,treeData:et,fieldNames:{title:"showTitle"}})]}),(0,a.jsx)("div",{className:"flex flex-col flex-1 max-w-full overflow-hidden",children:Array.isArray(q)?(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(v.Z,{className:"h-full",sx:{".ant-tabs-content, .ant-tabs-tabpane-active":{height:"100%"},"& .ant-tabs-card.ant-tabs-top >.ant-tabs-nav .ant-tabs-tab, & .ant-tabs-card.ant-tabs-top >div>.ant-tabs-nav .ant-tabs-tab":{borderRadius:"0"}},children:(0,a.jsx)(j.Z,{className:"h-full dark:text-white px-2",activeKey:I,onChange:e=>{M(e),B(null==q?void 0:q[Number(e)])},items:null==q?void 0:q.map((e,l)=>({key:l+"",label:null==e?void 0:e.title,children:(0,a.jsx)("div",{className:"flex flex-col h-full",children:(0,a.jsx)(O,{editorValue:e,handleChange:(e,l)=>{if(A){let t=JSON.parse(JSON.stringify(A));t.sql=e,t.thoughts=l,B(t)}},tableData:L,chartData:C})})}))})})}):(0,a.jsx)(O,{editorValue:q,handleChange:(e,l)=>{B({thoughts:l,sql:e})},tableData:L,chartData:void 0})})]})]})},q=t(69962),T=t(97287),A=t(73141),B=t(45642),L=t(71990),D=e=>{let l=(0,n.useReducer)((e,l)=>({...e,...l}),{...e});return l},I=t(21628),M=t(52040),F=e=>{let{queryAgentURL:l,channel:t,queryBody:a,initHistory:i,runHistoryList:r}=e,[o,d]=D({history:i||[]}),c=(0,Z.useSearchParams)(),u=c.get("id"),{refreshDialogList:h}=(0,s.Cg)(),v=new AbortController;(0,n.useEffect)(()=>{i&&d({history:i})},[i]);let x=async(e,n)=>{if(!e)return;let s=[...o.history,{role:"human",context:e}],i=s.length;d({history:s});let r={conv_uid:u,...n,...a,user_input:e,channel:t};if(!(null==r?void 0:r.conv_uid)){I.ZP.error("conv_uid 不存在,请刷新后重试");return}try{await (0,L.L)("".concat(M.env.API_BASE_URL?M.env.API_BASE_URL:"").concat("/api"+l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:v.signal,openWhenHidden:!0,async onopen(e){if(s.length<=1){var l;h();let e=new URLSearchParams(window.location.search);e.delete("initMessage"),null===(l=window.history)||void 0===l||l.replaceState(null,null,"?".concat(e.toString()))}(!e.ok||e.headers.get("content-type")!==L.a)&&e.status>=400&&e.status<500&&429!==e.status&&e.status},onclose(){console.log("onclose")},onerror(e){throw console.log("onerror"),Error(e)},onmessage:e=>{var l,t,a;if(e.data=null===(l=e.data)||void 0===l?void 0:l.replaceAll("\\n","\n"),"[DONE]"===e.data);else if(null===(t=e.data)||void 0===t?void 0:t.startsWith("[ERROR]"))d({history:[...s,{role:"view",context:null===(a=e.data)||void 0===a?void 0:a.replace("[ERROR]","")}]});else{let l=[...s];e.data&&((null==l?void 0:l[i])?l[i].context="".concat(e.data):l.push({role:"view",context:e.data}),d({history:l}))}}})}catch(e){console.log(e),d({history:[...s,{role:"view",context:"Sorry, We meet some error, please try agin later."}]})}};return{handleChatSubmit:x,history:o.history}},U=t(67830),z=t(54842),J=t(80937),W=t(311),V=t(94244),H=t(35086),G=t(53047),K=t(95066),Y=t(30530),$=t(64747),Q=t(19700),X=t(92391),ee=t(55749),el=t(70781),et=t(42599),ea=t(99398),en=t(49064),es=t(71563),ei=t(86362),er=t(50946),eo=t(52276),ed=t(53534),ec=t(24946),eu=t(98479),eh=t(81616),ev=function(e){var l,t;let{convUid:s,chatMode:i,fileName:r,onComplete:o,...d}=e,[c,u]=(0,n.useState)(!1),[h,v]=(0,n.useState)([]),[x,m]=(0,n.useState)(),[f,p]=(0,n.useState)(),j=async e=>{var l;if(!e){I.ZP.error("Please select the *.(csv|xlsx|xls) file");return}if(!/\.(csv|xlsx|xls)$/.test(null!==(l=e.file.name)&&void 0!==l?l:"")){I.ZP.error("File type must be csv, xlsx or xls");return}v([e.file])},g=async()=>{u(!0),p("normal");try{let e=new FormData;e.append("doc_file",h[0]);let{success:l,err_msg:t}=await ed.Z.post("/api/v1/chat/mode/params/file/load?conv_uid=".concat(s,"&chat_mode=").concat(i),e,{timeout:36e5,headers:{"Content-Type":"multipart/form-data"},onUploadProgress(e){let l=Math.ceil(e.loaded/(e.total||0)*100);m(l)}});if(!l){I.ZP.error(t);return}I.ZP.success("success"),p("success"),o()}catch(e){p("exception"),I.ZP.error((null==e?void 0:e.message)||"Upload Error")}finally{u(!1)}};return(0,a.jsxs)("div",{className:"w-full",children:[!r&&(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(es.Z,{placement:"topLeft",title:"Files cannot be changed after upload",children:(0,a.jsx)(ei.default,{disabled:c,className:"mr-1",beforeUpload:()=>!1,fileList:h,name:"file",accept:".csv,.xlsx,.xls",multiple:!1,onChange:j,showUploadList:{showDownloadIcon:!1,showPreviewIcon:!1,showRemoveIcon:!1},itemRender:()=>(0,a.jsx)(a.Fragment,{}),...d,children:(0,a.jsx)(er.ZP,{className:"flex justify-center items-center dark:bg-[#4e4f56] dark:text-gray-200",disabled:c,icon:(0,a.jsx)(ec.Z,{}),children:"Select File"})})}),(0,a.jsx)(er.ZP,{type:"primary",loading:c,className:"flex justify-center items-center",disabled:!h.length,icon:(0,a.jsx)(eu.Z,{}),onClick:g,children:c?100===x?"Analysis":"Uploading":"Upload"})]}),(!!h.length||r)&&(0,a.jsxs)("div",{className:"mt-2 text-gray-500 text-sm flex items-center",children:[(0,a.jsx)(eh.Z,{className:"mr-2"}),(0,a.jsx)("span",{children:null!==(t=null==h?void 0:null===(l=h[0])||void 0===l?void 0:l.name)&&void 0!==t?t:r})]}),("number"==typeof x||!!r)&&(0,a.jsx)(eo.Z,{className:"mb-0",percent:r?100:x,size:"small",status:r?"success":f})]})};let ex=X.z.object({query:X.z.string().min(1)});var em=e=>{var l;let{messages:s,dialogue:i,onSubmit:r,readOnly:o,paramsList:d,onRefreshHistory:x,clearIntialMessage:m,setChartsData:f}=e,p=(0,Z.useSearchParams)(),j=p.get("initMessage"),g=p.get("spaceNameOriginal"),y=p.get("id"),b=p.get("scene"),w="chat_dashboard"===b,N=(0,n.useRef)(null),[S,P]=(0,n.useState)(!1),[C,E]=(0,n.useState)(),[O,R]=(0,n.useState)(!1),[q,T]=(0,n.useState)(),[A,B]=(0,n.useState)(s),[L,D]=(0,n.useState)(""),M=(0,Q.cI)({resolver:(0,U.F)(ex),defaultValues:{}}),F=async e=>{let{query:l}=e;try{P(!0),M.reset(),await r(l,{select_param:"chat_excel"===b?null==i?void 0:i.select_param:null==d?void 0:d[C]})}catch(e){}finally{P(!1)}},X=async()=>{try{var e;let l=new URLSearchParams(window.location.search),t=l.get("initMessage");l.delete("initMessage"),null===(e=window.history)||void 0===e||e.replaceState(null,null,"?".concat(l.toString())),await F({query:t})}catch(e){console.log(e)}finally{null==m||m()}},es={overrides:{code:e=>{let{children:l}=e;return(0,a.jsx)(ea.Z,{language:"javascript",style:en.Z,children:l})}},wrapper:n.Fragment},ei=e=>{let l=e;try{l=JSON.parse(e)}catch(e){console.log(e)}return l},er=(0,n.useMemo)(()=>{if("function"==typeof(null==window?void 0:window.fetch)){let e=t(62631);return t(25204),t(82372),e.default}},[]);return(0,n.useEffect)(()=>{N.current&&N.current.scrollTo(0,N.current.scrollHeight)},[null==s?void 0:s.length]),(0,n.useEffect)(()=>{j&&s.length<=0&&X()},[j,s.length]),(0,n.useEffect)(()=>{var e,l;d&&(null===(e=Object.keys(d||{}))||void 0===e?void 0:e.length)>0&&E(g||(null===(l=Object.keys(d||{}))||void 0===l?void 0:l[0]))},[d]),(0,n.useEffect)(()=>{if(w){let e=k().cloneDeep(s);e.forEach(e=>{(null==e?void 0:e.role)==="view"&&"string"==typeof(null==e?void 0:e.context)&&(e.context=ei(null==e?void 0:e.context))}),B(e.filter(e=>["view","human"].includes(e.role)))}else B(s.filter(e=>["view","human"].includes(e.role)))},[w,s]),(0,a.jsxs)("div",{className:"w-full h-full",children:[(0,a.jsxs)(J.Z,{className:"w-full h-full bg-[#fefefe] dark:bg-[#212121]",sx:{table:{borderCollapse:"collapse",border:"1px solid #ccc",width:"100%"},"th, td":{border:"1px solid #ccc",padding:"10px",textAlign:"center"}},children:[(0,a.jsxs)(J.Z,{ref:N,direction:"column",sx:{overflowY:"auto",maxHeight:"100%",flex:1},children:[null==A?void 0:A.map((e,l)=>{var t,n;return(0,a.jsx)(J.Z,{children:(0,a.jsx)(_.Z,{size:"sm",variant:"outlined",color:"view"===e.role?"primary":"neutral",sx:l=>({background:"view"===e.role?"var(--joy-palette-primary-softBg, var(--joy-palette-primary-100, #DDF1FF))":"unset",border:"unset",borderRadius:"unset",padding:"24px 0 26px 0",lineHeight:"24px"}),children:(0,a.jsxs)(v.Z,{sx:{width:"76%",margin:"0 auto"},className:"flex flex-row",children:["view"===e.role?(0,a.jsx)(el.Z,{className:"mr-2 mt-1"}):(0,a.jsx)(ee.Z,{className:"mr-2 mt-1"}),(0,a.jsx)("div",{className:"inline align-middle mt-0.5 max-w-full flex-1 overflow-auto",children:w&&"view"===e.role&&"object"==typeof(null==e?void 0:e.context)?(0,a.jsxs)(a.Fragment,{children:["[".concat(e.context.template_name,"]: "),(0,a.jsx)(W.Z,{sx:{color:"#1677ff"},component:"button",onClick:()=>{R(!0),T(l),D(JSON.stringify(null==e?void 0:e.context,null,2))},children:e.context.template_introduce||"More Details"})]}):(0,a.jsx)(a.Fragment,{children:"string"==typeof e.context&&(0,a.jsx)(et.Z,{options:es,children:null===(t=e.context)||void 0===t?void 0:null===(n=t.replaceAll)||void 0===n?void 0:n.call(t,"\\n","\n")})})})]})})},l)}),S&&(0,a.jsx)(V.Z,{variant:"soft",color:"neutral",size:"sm",sx:{mx:"auto",my:2}})]}),!o&&(0,a.jsx)(v.Z,{className:"bg-[#fefefe] dark:bg-[#212121] before:bg-[#fefefe] before:dark:bg-[#212121]",sx:{position:"relative","&::before":{content:'" "',position:"absolute",top:"-18px",left:"0",right:"0",width:"100%",margin:"0 auto",height:"20px",filter:"blur(10px)",zIndex:2}},children:(0,a.jsxs)("form",{style:{maxWidth:"100%",width:"76%",position:"relative",display:"flex",marginTop:"auto",overflow:"visible",background:"none",justifyContent:"center",marginLeft:"auto",marginRight:"auto",flexDirection:"column",gap:"12px",paddingBottom:"58px",paddingTop:"20px"},onSubmit:e=>{e.stopPropagation(),M.handleSubmit(F)(e)},children:[(0,a.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[Object.keys(d||{}).length>0&&(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsx)(u.Z,{value:C,onChange:(e,l)=>{E(l)},sx:{maxWidth:"100%"},children:null===(l=Object.keys(d||{}))||void 0===l?void 0:l.map(e=>(0,a.jsx)(h.Z,{value:e,children:e},e))})}),"chat_excel"===b&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(ev,{convUid:y,chatMode:b,fileName:null==i?void 0:i.select_param,onComplete:()=>{null==m||m(),null==x||x()}})})]}),(0,a.jsx)(H.ZP,{disabled:"chat_excel"===b&&!(null==i?void 0:i.select_param),className:"w-full h-12",variant:"outlined",endDecorator:(0,a.jsx)(G.ZP,{type:"submit",disabled:S,children:(0,a.jsx)(z.Z,{})}),...M.register("query")})]})})]}),(0,a.jsx)(K.Z,{open:O,onClose:()=>{R(!1)},children:(0,a.jsxs)(Y.Z,{"aria-labelledby":"variant-modal-title","aria-describedby":"variant-modal-description",children:[(0,a.jsx)($.Z,{}),(0,a.jsxs)(v.Z,{sx:{marginTop:"32px"},children:[!!er&&(0,a.jsx)(er,{mode:"json",value:L,height:"600px",width:"820px",onChange:D,placeholder:"默认json数据",debounceChangePeriod:100,showPrintMargin:!0,showGutter:!0,highlightActiveLine:!0,setOptions:{useWorker:!0,showLineNumbers:!0,highlightSelectedWord:!0,tabSize:2}}),(0,a.jsx)(c.Z,{variant:"outlined",className:"w-full",sx:{marginTop:"12px"},onClick:()=>{if(q)try{let e=k().cloneDeep(A),l=JSON.parse(L);e[q].context=l,B(e),null==f||f(null==l?void 0:l.charts),R(!1),D("")}catch(e){I.ZP.error("JSON 格式化出错")}},children:"Submit"})]})]})})]})};function ef(e){let{key:l,chart:t}=e;return(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(_.Z,{className:"h-full",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:t.chart_name}),(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:t.chart_desc}),(0,a.jsx)("div",{className:"h-[300px]",children:(0,a.jsx)(S.Chart,{autoFit:!0,data:t.values,children:(0,a.jsx)(S.LineAdvance,{shape:"smooth",point:!0,area:!0,position:"name*value",color:"type"})})})]})})},l)}function ep(e){let{key:l,chart:t}=e;return(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(_.Z,{className:"h-full",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:t.chart_name}),(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:t.chart_desc}),(0,a.jsx)("div",{className:"h-[300px]",children:(0,a.jsxs)(S.Chart,{autoFit:!0,data:t.values,children:[(0,a.jsx)(S.Interval,{position:"name*value",style:{lineWidth:3,stroke:(0,S.getTheme)().colors10[0]}}),(0,a.jsx)(S.Tooltip,{shared:!0})]})})]})})},l)}function ej(e){var l,t;let{key:n,chart:s}=e,i=(0,P.groupBy)(s.values,"type");return(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(_.Z,{className:"h-full overflow-auto",sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"h-full",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:s.chart_name}),"\xb7",(0,a.jsx)(d.ZP,{gutterBottom:!0,level:"body3",children:s.chart_desc}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsxs)(r.Z,{"aria-label":"basic table",stripe:"odd",hoverRow:!0,borderAxis:"bothBetween",children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:Object.keys(i).map(e=>(0,a.jsx)("th",{children:e},e))})}),(0,a.jsx)("tbody",{children:null===(l=Object.values(i))||void 0===l?void 0:null===(t=l[0])||void 0===t?void 0:t.map((e,l)=>{var t;return(0,a.jsx)("tr",{children:null===(t=Object.keys(i))||void 0===t?void 0:t.map(e=>{var t;return(0,a.jsx)("td",{children:(null==i?void 0:null===(t=i[e])||void 0===t?void 0:t[l].value)||""},e)})},l)})})]})})]})})},n)}let eg=()=>(0,a.jsxs)(_.Z,{className:"h-full w-full flex bg-transparent",children:[(0,a.jsx)(q.Z,{animation:"wave",variant:"text",level:"body2"}),(0,a.jsx)(q.Z,{animation:"wave",variant:"text",level:"body2"}),(0,a.jsx)(T.Z,{ratio:"21/9",className:"flex-1",sx:{["& .".concat(A.Z.content)]:{height:"100%"}},children:(0,a.jsx)(q.Z,{variant:"overlay",className:"h-full"})})]});var ey=()=>{var e;let[l,t]=(0,n.useState)();n.useRef(null);let[r,o]=n.useState(!1),c=(0,Z.useSearchParams)(),{dialogueList:u,refreshDialogList:h}=(0,s.Cg)(),x=c.get("id"),m=c.get("scene"),f=(0,n.useMemo)(()=>(null!==(e=null==u?void 0:u.data)&&void 0!==e?e:[]).find(e=>e.conv_uid===x),[x,u]),{data:p,run:j}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/chat/dialogue/messages/history",{con_uid:x}),{ready:!!x,refreshDeps:[x]}),{data:g,run:y}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/chat/db/list"),{ready:!!m&&!!["chat_with_db_execute","chat_with_db_qa"].includes(m)}),{data:b}=(0,i.Z)(async()=>await (0,w.Tk)("/v1/chat/db/support/type"),{ready:!!m&&!!["chat_with_db_execute","chat_with_db_qa"].includes(m)}),{history:S,handleChatSubmit:P}=F({queryAgentURL:"/v1/chat/completions",queryBody:{conv_uid:x,chat_mode:m||"chat_normal"},initHistory:null==p?void 0:p.data,runHistoryList:j}),{data:k,run:C}=(0,i.Z)(async()=>await (0,w.Kw)("/v1/chat/mode/params/list?chat_mode=".concat(m)),{ready:!!m,refreshDeps:[x,m]});(0,n.useEffect)(()=>{try{var e;let l=null==S?void 0:null===(e=S[S.length-1])||void 0===e?void 0:e.context,a=JSON.parse(l);t((null==a?void 0:a.template_name)==="report"?null==a?void 0:a.charts:void 0)}catch(e){t(void 0)}},[S]);let E=(0,n.useMemo)(()=>{if(l){let e=[],t=null==l?void 0:l.filter(e=>"IndicatorValue"===e.chart_type);t.length>0&&e.push({charts:t,type:"IndicatorValue"});let a=null==l?void 0:l.filter(e=>"IndicatorValue"!==e.chart_type),n=a.length,s=0;return[[0],[1],[2],[1,2],[1,3],[2,1,2],[2,1,3],[3,1,3],[3,2,3]][n].forEach(l=>{if(l>0){let t=a.slice(s,s+l);s+=l,e.push({charts:t})}}),e}},[l]);return(0,a.jsxs)(B.Z,{container:!0,spacing:2,className:"h-full overflow-auto",sx:{flexGrow:1},children:[l&&(0,a.jsx)(B.Z,{xs:8,className:"max-h-full",children:(0,a.jsx)("div",{className:"flex flex-col gap-3 h-full",children:null==E?void 0:E.map((e,l)=>(0,a.jsx)("div",{className:"".concat((null==e?void 0:e.type)!=="IndicatorValue"?"flex gap-3":""),children:e.charts.map(e=>"IndicatorValue"===e.chart_type?(0,a.jsx)("div",{className:"flex flex-row gap-3",children:e.values.map(e=>(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(_.Z,{sx:{background:"transparent"},children:(0,a.jsxs)(N.Z,{className:"justify-around",children:[(0,a.jsx)(d.ZP,{gutterBottom:!0,component:"div",children:e.name}),(0,a.jsx)(d.ZP,{children:e.value})]})})},e.name))},e.chart_uid):"LineChart"===e.chart_type?(0,a.jsx)(ef,{chart:e},e.chart_uid):"BarChart"===e.chart_type?(0,a.jsx)(ep,{chart:e},e.chart_uid):"Table"===e.chart_type?(0,a.jsx)(ej,{chart:e},e.chart_uid):void 0)},"chart_row_".concat(l)))})}),!l&&"chat_dashboard"===m&&(0,a.jsx)(B.Z,{xs:8,className:"max-h-full p-6",children:(0,a.jsx)("div",{className:"flex flex-col gap-3 h-full",children:(0,a.jsxs)(B.Z,{container:!0,spacing:2,sx:{flexGrow:1},children:[(0,a.jsx)(B.Z,{xs:8,children:(0,a.jsx)(v.Z,{className:"h-full w-full",sx:{display:"flex",gap:2},children:(0,a.jsx)(eg,{})})}),(0,a.jsx)(B.Z,{xs:4,children:(0,a.jsx)(eg,{})}),(0,a.jsx)(B.Z,{xs:4,children:(0,a.jsx)(eg,{})}),(0,a.jsx)(B.Z,{xs:8,children:(0,a.jsx)(eg,{})})]})})}),(0,a.jsx)(B.Z,{xs:"chat_dashboard"===m?4:12,className:"h-full max-h-full",children:(0,a.jsx)("div",{className:"h-full",style:{boxShadow:"chat_dashboard"===m?"0px 0px 9px 0px #c1c0c080":"unset"},children:(0,a.jsx)(em,{clearIntialMessage:async()=>{await h()},dialogue:f,dbList:null==g?void 0:g.data,runDbList:y,onRefreshHistory:j,supportTypes:null==b?void 0:b.data,messages:S||[],onSubmit:P,paramsList:null==k?void 0:k.data,runParamsList:C,setChartsData:t})})})]})},eb=t(32093),ew=t(97237);function eZ(){let{isContract:e,setIsContract:l}=(0,s.Cg)();return(0,a.jsxs)("div",{className:"relative w-56 h-10 mx-auto p-2 flex justify-center items-center bg-[#ece9e0] rounded-3xl model-tab dark:text-violet-600 z-10 ".concat(e?"editor-tab":""),children:[(0,a.jsxs)("div",{className:"z-10 w-[50%] text-center cursor-pointer",onClick:()=>{l(!1)},children:[(0,a.jsx)("span",{children:"Preview"}),(0,a.jsx)(ew.Z,{className:"ml-1"})]}),(0,a.jsxs)("div",{className:"z-10 w-[50%] text-center cursor-pointer",onClick:()=>{l(!0)},children:[(0,a.jsx)("span",{children:"Editor"}),(0,a.jsx)(eb.Z,{className:"ml-1"})]})]})}t(95389);var e_=()=>{let{isContract:e,setIsContract:l,setIsMenuExpand:t}=(0,s.Cg)(),i=(0,Z.useSearchParams)(),r=i.get("scene"),o=i.get("id"),d=r&&["chat_with_db_execute","chat_dashboard"].includes(r);return(0,n.useEffect)(()=>{t("chat_dashboard"!==r),o&&r&&l(!1)},[o,r,t,l]),(0,a.jsxs)(a.Fragment,{children:[d&&(0,a.jsx)("div",{className:"leading-[3rem] text-right pr-3 h-12 flex justify-center",children:(0,a.jsx)("div",{className:"flex items-center cursor-pointer",children:(0,a.jsx)(eZ,{})})}),e?(0,a.jsx)(R,{}):(0,a.jsx)(ey,{})]})}},57931:function(e,l,t){"use strict";t.d(l,{ZP:function(){return c},Cg:function(){return o}});var a=t(9268),n=t(11196),s=t(89749),i=t(86006),r=t(56008);let[o,d]=function(){let e=i.createContext(void 0);return[function(){let l=i.useContext(e);if(void 0===l)throw Error("useCtx must be inside a Provider with a value");return l},e.Provider]}();var c=e=>{let{children:l}=e,t=(0,r.useSearchParams)(),o=t.get("scene"),[c,u]=i.useState(!1),[h,v]=i.useState("chat_dashboard"!==o),{run:x,data:m,refresh:f}=(0,n.Z)(async()=>await (0,s.Tk)("/v1/chat/dialogue/list"),{manual:!0});return(0,a.jsx)(d,{value:{isContract:c,isMenuExpand:h,dialogueList:m,setIsContract:u,setIsMenuExpand:v,queryDialogueList:x,refreshDialogList:f},children:l})}},53534:function(e,l,t){"use strict";var a=t(24214),n=t(52040);let s=a.Z.create({baseURL:n.env.API_BASE_URL});s.defaults.timeout=1e4,s.interceptors.response.use(e=>e.data,e=>Promise.reject(e)),l.Z=s},89749:function(e,l,t){"use strict";t.d(l,{Ej:function(){return u},Kw:function(){return d},PR:function(){return c},Tk:function(){return o}});var a=t(21628),n=t(53534),s=t(84835);let i={"content-type":"application/json"},r=e=>{if(!(0,s.isPlainObject)(e))return JSON.stringify(e);let l={...e};for(let e in l){let t=l[e];"string"==typeof t&&(l[e]=t.trim())}return JSON.stringify(l)},o=(e,l)=>{if(l){let t=Object.keys(l).filter(e=>void 0!==l[e]&&""!==l[e]).map(e=>"".concat(e,"=").concat(l[e])).join("&");t&&(e+="?".concat(t))}return n.Z.get("/api"+e,{headers:i}).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)})},d=(e,l)=>{let t=r(l);return n.Z.post("/api"+e,{body:t,headers:i}).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)})},c=(e,l)=>n.Z.post(e,l,{headers:i}).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)}),u=(e,l)=>n.Z.post(e,l).then(e=>e).catch(e=>{a.ZP.error(e),Promise.reject(e)})},95389:function(){}},function(e){e.O(0,[180,757,282,355,932,358,649,191,230,715,569,196,86,919,579,537,767,341,116,959,554,253,769,744],function(){return e(e.s=86066)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/pilot/server/static/_next/static/HHDsBd1B4aAH55tFrMBIv/_buildManifest.js b/pilot/server/static/_next/static/g4yxzotH2uCI1z7uk8kQC/_buildManifest.js
similarity index 100%
rename from pilot/server/static/_next/static/HHDsBd1B4aAH55tFrMBIv/_buildManifest.js
rename to pilot/server/static/_next/static/g4yxzotH2uCI1z7uk8kQC/_buildManifest.js
diff --git a/pilot/server/static/_next/static/HHDsBd1B4aAH55tFrMBIv/_ssgManifest.js b/pilot/server/static/_next/static/g4yxzotH2uCI1z7uk8kQC/_ssgManifest.js
similarity index 100%
rename from pilot/server/static/_next/static/HHDsBd1B4aAH55tFrMBIv/_ssgManifest.js
rename to pilot/server/static/_next/static/g4yxzotH2uCI1z7uk8kQC/_ssgManifest.js
diff --git a/pilot/server/static/chat/index.html b/pilot/server/static/chat/index.html
index 00f22d269..bd8b14a3c 100644
--- a/pilot/server/static/chat/index.html
+++ b/pilot/server/static/chat/index.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pilot/server/static/chat/index.txt b/pilot/server/static/chat/index.txt
index 14dbbd6b3..9386c0d5b 100644
--- a/pilot/server/static/chat/index.txt
+++ b/pilot/server/static/chat/index.txt
@@ -1,10 +1,10 @@
1:HL["/_next/static/css/76124ca107b00a15.css",{"as":"style"}]
-0:["HHDsBd1B4aAH55tFrMBIv",[[["",{"children":["chat",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
+0:["g4yxzotH2uCI1z7uk8kQC",[[["",{"children":["chat",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
4:HL["/_next/static/css/4047a8310a399ceb.css",{"as":"style"}]
5:I{"id":"55515","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","116:static/chunks/116-4b57b4ff0a58288d.js","741:static/chunks/741-9654a56afdea9ccd.js","119:static/chunks/119-fa8ae2133f5d13d9.js","185:static/chunks/app/layout-8f881e40fdff6264.js"],"name":"","async":false}
6:I{"id":"13211","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
7:I{"id":"5767","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
8:I{"id":"37396","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
-9:I{"id":"50229","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","757:static/chunks/f60284a2-6891068c9ea7ce77.js","282:static/chunks/7e4358a0-7f236e540ced7dbb.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","649:static/chunks/649-85000b933734ec92.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","569:static/chunks/569-2c5ba6e4012e0ef6.js","196:static/chunks/196-876de32c0e3c3c98.js","86:static/chunks/86-07eeba2a9867dc2c.js","919:static/chunks/919-712e9f0bec0b7521.js","579:static/chunks/579-109b8ef1060dc09f.js","537:static/chunks/537-323ddb61f3df4dff.js","767:static/chunks/767-b93280f4b5b5e975.js","341:static/chunks/341-7283db898ec4f602.js","116:static/chunks/116-4b57b4ff0a58288d.js","959:static/chunks/959-28f2e1d44ad53ceb.js","554:static/chunks/554-82424166ff4e65a9.js","929:static/chunks/app/chat/page-dc56c69ea8f72017.js"],"name":"","async":false}
+9:I{"id":"50229","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","757:static/chunks/f60284a2-6891068c9ea7ce77.js","282:static/chunks/7e4358a0-7f236e540ced7dbb.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","649:static/chunks/649-85000b933734ec92.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","569:static/chunks/569-2c5ba6e4012e0ef6.js","196:static/chunks/196-876de32c0e3c3c98.js","86:static/chunks/86-07eeba2a9867dc2c.js","919:static/chunks/919-712e9f0bec0b7521.js","579:static/chunks/579-109b8ef1060dc09f.js","537:static/chunks/537-323ddb61f3df4dff.js","767:static/chunks/767-b93280f4b5b5e975.js","341:static/chunks/341-7283db898ec4f602.js","116:static/chunks/116-4b57b4ff0a58288d.js","959:static/chunks/959-28f2e1d44ad53ceb.js","554:static/chunks/554-82424166ff4e65a9.js","929:static/chunks/app/chat/page-81e618fbf297a8f1.js"],"name":"","async":false}
2:[["$","$L5",null,{"children":["$","$L6",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L7",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$L6",null,{"parallelRouterKey":"children","segmentPath":["children","chat","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$L7",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":[["$","$L8",null,{"propsForComponent":{"params":{}},"Component":"$9"}],null],"segment":"__PAGE__"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/4047a8310a399ceb.css","precedence":"next"}]]}],"segment":"chat"},"styles":[]}],"params":{}}],null]
3:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","link","2",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"any"}]]
diff --git a/pilot/server/static/database/index.html b/pilot/server/static/database/index.html
index 9db472745..a4fb03679 100644
--- a/pilot/server/static/database/index.html
+++ b/pilot/server/static/database/index.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pilot/server/static/database/index.txt b/pilot/server/static/database/index.txt
index d4502ccf5..2af0576e9 100644
--- a/pilot/server/static/database/index.txt
+++ b/pilot/server/static/database/index.txt
@@ -1,5 +1,5 @@
1:HL["/_next/static/css/76124ca107b00a15.css",{"as":"style"}]
-0:["HHDsBd1B4aAH55tFrMBIv",[[["",{"children":["database",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
+0:["g4yxzotH2uCI1z7uk8kQC",[[["",{"children":["database",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
4:I{"id":"55515","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","116:static/chunks/116-4b57b4ff0a58288d.js","741:static/chunks/741-9654a56afdea9ccd.js","119:static/chunks/119-fa8ae2133f5d13d9.js","185:static/chunks/app/layout-8f881e40fdff6264.js"],"name":"","async":false}
5:I{"id":"13211","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
6:I{"id":"5767","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
diff --git a/pilot/server/static/datastores/documents/chunklist/index.html b/pilot/server/static/datastores/documents/chunklist/index.html
index 98d5b5a8d..fe05de2f2 100644
--- a/pilot/server/static/datastores/documents/chunklist/index.html
+++ b/pilot/server/static/datastores/documents/chunklist/index.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pilot/server/static/datastores/documents/chunklist/index.txt b/pilot/server/static/datastores/documents/chunklist/index.txt
index 23be009e7..92a763d4f 100644
--- a/pilot/server/static/datastores/documents/chunklist/index.txt
+++ b/pilot/server/static/datastores/documents/chunklist/index.txt
@@ -1,5 +1,5 @@
1:HL["/_next/static/css/76124ca107b00a15.css",{"as":"style"}]
-0:["HHDsBd1B4aAH55tFrMBIv",[[["",{"children":["datastores",{"children":["documents",{"children":["chunklist",{"children":["__PAGE__",{}]}]}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
+0:["g4yxzotH2uCI1z7uk8kQC",[[["",{"children":["datastores",{"children":["documents",{"children":["chunklist",{"children":["__PAGE__",{}]}]}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
4:I{"id":"55515","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","116:static/chunks/116-4b57b4ff0a58288d.js","741:static/chunks/741-9654a56afdea9ccd.js","119:static/chunks/119-fa8ae2133f5d13d9.js","185:static/chunks/app/layout-8f881e40fdff6264.js"],"name":"","async":false}
5:I{"id":"13211","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
6:I{"id":"5767","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
diff --git a/pilot/server/static/datastores/documents/index.html b/pilot/server/static/datastores/documents/index.html
index da5de5f76..6676811ed 100644
--- a/pilot/server/static/datastores/documents/index.html
+++ b/pilot/server/static/datastores/documents/index.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pilot/server/static/datastores/documents/index.txt b/pilot/server/static/datastores/documents/index.txt
index e23d50ecf..faec1dc73 100644
--- a/pilot/server/static/datastores/documents/index.txt
+++ b/pilot/server/static/datastores/documents/index.txt
@@ -1,5 +1,5 @@
1:HL["/_next/static/css/76124ca107b00a15.css",{"as":"style"}]
-0:["HHDsBd1B4aAH55tFrMBIv",[[["",{"children":["datastores",{"children":["documents",{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
+0:["g4yxzotH2uCI1z7uk8kQC",[[["",{"children":["datastores",{"children":["documents",{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
4:I{"id":"55515","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","116:static/chunks/116-4b57b4ff0a58288d.js","741:static/chunks/741-9654a56afdea9ccd.js","119:static/chunks/119-fa8ae2133f5d13d9.js","185:static/chunks/app/layout-8f881e40fdff6264.js"],"name":"","async":false}
5:I{"id":"13211","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
6:I{"id":"5767","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
diff --git a/pilot/server/static/datastores/index.html b/pilot/server/static/datastores/index.html
index ee1f6be90..cfce08bf5 100644
--- a/pilot/server/static/datastores/index.html
+++ b/pilot/server/static/datastores/index.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pilot/server/static/datastores/index.txt b/pilot/server/static/datastores/index.txt
index cbaa6e396..362b969b3 100644
--- a/pilot/server/static/datastores/index.txt
+++ b/pilot/server/static/datastores/index.txt
@@ -1,5 +1,5 @@
1:HL["/_next/static/css/76124ca107b00a15.css",{"as":"style"}]
-0:["HHDsBd1B4aAH55tFrMBIv",[[["",{"children":["datastores",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
+0:["g4yxzotH2uCI1z7uk8kQC",[[["",{"children":["datastores",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
4:I{"id":"55515","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","116:static/chunks/116-4b57b4ff0a58288d.js","741:static/chunks/741-9654a56afdea9ccd.js","119:static/chunks/119-fa8ae2133f5d13d9.js","185:static/chunks/app/layout-8f881e40fdff6264.js"],"name":"","async":false}
5:I{"id":"13211","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
6:I{"id":"5767","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
diff --git a/pilot/server/static/index.html b/pilot/server/static/index.html
index 2a4e7e5bb..abf35a998 100644
--- a/pilot/server/static/index.html
+++ b/pilot/server/static/index.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pilot/server/static/index.txt b/pilot/server/static/index.txt
index 7680453ae..70eb7e2cf 100644
--- a/pilot/server/static/index.txt
+++ b/pilot/server/static/index.txt
@@ -1,5 +1,5 @@
1:HL["/_next/static/css/76124ca107b00a15.css",{"as":"style"}]
-0:["HHDsBd1B4aAH55tFrMBIv",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
+0:["g4yxzotH2uCI1z7uk8kQC",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L2",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/76124ca107b00a15.css","precedence":"next"}]],["$L3",null]]]]]
4:I{"id":"55515","chunks":["180:static/chunks/0e02fca3-615d0d51fa074d92.js","355:static/chunks/355-f67a136d901a8c5f.js","932:static/chunks/932-401b6290e4f07233.js","358:static/chunks/358-a690ea06b8189dc6.js","191:static/chunks/191-977bd4e61595fb21.js","230:static/chunks/230-62e75b5eb2fd3838.js","715:static/chunks/715-50c67108307c55aa.js","196:static/chunks/196-876de32c0e3c3c98.js","394:static/chunks/394-0ffa189aa535d3eb.js","635:static/chunks/635-485e0e15fe1137c1.js","116:static/chunks/116-4b57b4ff0a58288d.js","741:static/chunks/741-9654a56afdea9ccd.js","119:static/chunks/119-fa8ae2133f5d13d9.js","185:static/chunks/app/layout-8f881e40fdff6264.js"],"name":"","async":false}
5:I{"id":"13211","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
6:I{"id":"5767","chunks":["272:static/chunks/webpack-01b3999c74014454.js","253:static/chunks/bce60fc1-18c9f145b45d8f36.js","769:static/chunks/769-76f7aafd375fdd6b.js"],"name":"","async":false}
From 7ae10a98f7b858ab100721f5b1bf5e8702f942b2 Mon Sep 17 00:00:00 2001
From: yhjun1026 <460342015@qq.com>
Date: Fri, 1 Sep 2023 10:40:18 +0800
Subject: [PATCH 7/7] fix(editor): Editor run/save bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
🔥1.Editor bug fix
🔥2.ChatExcel Stability optimization
---
pilot/commands/disply_type/show_chart_gen.py | 22 +++--
.../chat_excel/excel_analyze/chat.py | 5 +-
.../chat_excel/excel_learning/test.py | 85 +++++++++++--------
3 files changed, 65 insertions(+), 47 deletions(-)
diff --git a/pilot/commands/disply_type/show_chart_gen.py b/pilot/commands/disply_type/show_chart_gen.py
index 6a3ee3e27..052b9d971 100644
--- a/pilot/commands/disply_type/show_chart_gen.py
+++ b/pilot/commands/disply_type/show_chart_gen.py
@@ -210,18 +210,22 @@ def response_bar_chart(speak: str, df: DataFrame) -> str:
data=df, x=x, y=sub_y_column, hue=hue, palette="Set2", ax=ax
)
else:
- if len(num_colmns) >= 3:
- can_use_columns = num_colmns[:3]
+ if len(num_colmns) > 5:
+ can_use_columns = num_colmns[:5]
else:
can_use_columns = num_colmns
- sns.barplot(
- data=df, x=x, y=y, hue=can_use_columns[0], palette="Set2", ax=ax
- )
+ can_use_columns.append(y)
- for sub_y_column in can_use_columns[1:]:
- sns.barplot(
- data=df, x=x, y=sub_y_column, hue=hue, palette="Set2", ax=ax
- )
+ df_melted = pd.melt(
+ df,
+ id_vars=x,
+ value_vars=can_use_columns,
+ var_name="line",
+ value_name="Value",
+ )
+ sns.barplot(
+ data=df_melted, x=x, y="Value", hue="line", palette="Set2", ax=ax
+ )
else:
sns.barplot(data=df, x=x, y=y, hue=hue, palette="Set2", ax=ax)
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 7f6ae856c..9cc0b43ff 100644
--- a/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py
+++ b/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py
@@ -104,4 +104,7 @@ class ChatExcel(BaseChat):
"speak": prompt_response.thoughts,
"df": self.excel_reader.get_df_by_sql_ex(prompt_response.sql),
}
- return CFG.command_disply.call(prompt_response.display, **param)
+ if CFG.command_disply.get_command(prompt_response.display):
+ return CFG.command_disply.call(prompt_response.display, **param)
+ else:
+ return CFG.command_disply.call("response_table", **param)
diff --git a/pilot/scene/chat_data/chat_excel/excel_learning/test.py b/pilot/scene/chat_data/chat_excel/excel_learning/test.py
index 7dc1a2746..fdfaf146a 100644
--- a/pilot/scene/chat_data/chat_excel/excel_learning/test.py
+++ b/pilot/scene/chat_data/chat_excel/excel_learning/test.py
@@ -157,7 +157,7 @@ if __name__ == "__main__":
# # colunms, datas = excel_reader.run( """ SELECT Year, SUM(Sales) AS Total_Sales FROM example GROUP BY Year ORDER BY Year; """)
# df = excel_reader.get_df_by_sql_ex(""" SELECT Segment, Country, SUM(Sales) AS Total_Sales, SUM(Profit) AS Total_Profit FROM example GROUP BY Segment, Country """)
df = excel_reader.get_df_by_sql_ex(
- """ SELECT `明细`, `费用小计`, `支出小计` FROM yhj-zx limit 10"""
+ """ SELECT 大项, AVG(实际) AS 平均实际支出, AVG(已支出) AS 平均已支出 FROM yhj-zx GROUP BY 大项"""
)
for column_name in df.columns.tolist():
@@ -203,44 +203,55 @@ if __name__ == "__main__":
# sns.barplot(df, x=x, y="Total_Profit", hue='Country', ax=ax)
# sns.catplot(data=df, x=x, y=y, hue='Country', kind='bar')
- x, y, non_num_columns, num_colmns = data_pre_classification(df)
- print(x, y, str(non_num_columns), str(num_colmns))
+ # x, y, non_num_columns, num_colmns = data_pre_classification(df)
+ # print(x, y, str(non_num_columns), str(num_colmns))
## 复杂折线图实现
- if len(num_colmns) > 0:
- num_colmns.append(y)
- df_melted = pd.melt(
- df, id_vars=x, value_vars=num_colmns, var_name="line", value_name="Value"
- )
- sns.lineplot(data=df_melted, x=x, y="Value", hue="line", ax=ax, palette="Set2")
- else:
- sns.lineplot(data=df, x=x, y=y, ax=ax, palette="Set2")
-
- # hue = None
- # ## 复杂柱状图实现
- # x,y, non_num_columns, num_colmns =data_pre_classification(df)
- # if len(non_num_columns) >= 1:
- # hue = non_num_columns[0]
-
- # if len(num_colmns)>=1:
- # if hue:
- # if len(num_colmns) >= 2:
- # can_use_columns = num_colmns[:2]
- # else:
- # can_use_columns = num_colmns
- # sns.barplot(data=df, x=x, y=y, hue=hue, palette="Set2", ax=ax)
- # for sub_y_column in can_use_columns:
- # sns.barplot(data=df, x=x, y=sub_y_column, hue=hue, palette="Set2", ax=ax)
- # else:
- # if len(num_colmns) >= 3:
- # can_use_columns = num_colmns[:3]
- # else:
- # can_use_columns = num_colmns
- # sns.barplot(data=df, x=x, y=y, hue=can_use_columns[0], palette="Set2", ax=ax)
- #
- # for sub_y_column in can_use_columns[1:]:
- # sns.barplot(data=df, x=x, y=sub_y_column, hue=hue, palette="Set2", ax=ax)
+ # if len(num_colmns) > 0:
+ # num_colmns.append(y)
+ # df_melted = pd.melt(
+ # df, id_vars=x, value_vars=num_colmns, var_name="line", value_name="Value"
+ # )
+ # sns.lineplot(data=df_melted, x=x, y="Value", hue="line", ax=ax, palette="Set2")
# else:
- # sns.barplot(data=df, x=x, y=y, hue=hue, palette="Set2", ax=ax)
+ # sns.lineplot(data=df, x=x, y=y, ax=ax, palette="Set2")
+
+ hue = None
+ ## 复杂柱状图实现
+ x, y, non_num_columns, num_colmns = data_pre_classification(df)
+
+ if len(non_num_columns) >= 1:
+ hue = non_num_columns[0]
+
+ if len(num_colmns) >= 1:
+ if hue:
+ if len(num_colmns) >= 2:
+ can_use_columns = num_colmns[:2]
+ else:
+ can_use_columns = num_colmns
+ sns.barplot(data=df, x=x, y=y, hue=hue, palette="Set2", ax=ax)
+ for sub_y_column in can_use_columns:
+ sns.barplot(
+ data=df, x=x, y=sub_y_column, hue=hue, palette="Set2", ax=ax
+ )
+ else:
+ if len(num_colmns) > 5:
+ can_use_columns = num_colmns[:5]
+ else:
+ can_use_columns = num_colmns
+ can_use_columns.append(y)
+
+ df_melted = pd.melt(
+ df,
+ id_vars=x,
+ value_vars=can_use_columns,
+ var_name="line",
+ value_name="Value",
+ )
+ sns.barplot(
+ data=df_melted, x=x, y="Value", hue="line", palette="Set2", ax=ax
+ )
+ else:
+ sns.barplot(data=df, x=x, y=y, hue=hue, palette="Set2", ax=ax)
# # 转换 DataFrame 格式
# df_melted = pd.melt(df, id_vars=x, value_vars=['Total_Sales', 'Total_Profit'], var_name='line', value_name='y')