diff --git a/backend/apps/chat/task/llm.py b/backend/apps/chat/task/llm.py
index 060bacc9..e5d3a083 100644
--- a/backend/apps/chat/task/llm.py
+++ b/backend/apps/chat/task/llm.py
@@ -296,7 +296,7 @@ class LLMService:
# get schema
if self.ds and not self.chat_question.db_schema:
- self.chat_question.db_schema = get_table_schema(session=self.session, ds=self.ds)
+ self.chat_question.db_schema = get_table_schema(session=self.session, current_user=self.current_user, ds=self.ds)
guess_msg: List[Union[BaseMessage, dict[str, Any]]] = []
guess_msg.append(SystemMessage(content=self.chat_question.guess_sys_question()))
@@ -726,7 +726,7 @@ def run_task(llm_service: LLMService, in_chat: bool = True):
yield orjson.dumps({'id': llm_service.ds.id, 'datasource_name': llm_service.ds.name,
'engine_type': llm_service.ds.type_name, 'type': 'datasource'}).decode() + '\n\n'
- llm_service.chat_question.db_schema = get_table_schema(session=llm_service.session, ds=llm_service.ds)
+ llm_service.chat_question.db_schema = get_table_schema(session=llm_service.session, current_user=llm_service.current_user, ds=llm_service.ds)
# generate sql
sql_res = llm_service.generate_sql()
diff --git a/frontend/src/assets/svg/icon_new_chat_outlined.svg b/frontend/src/assets/svg/icon_new_chat_outlined.svg
index c1ff4c6f..3bb65ed6 100644
--- a/frontend/src/assets/svg/icon_new_chat_outlined.svg
+++ b/frontend/src/assets/svg/icon_new_chat_outlined.svg
@@ -1,4 +1 @@
-
+
\ No newline at end of file
diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue
index 65446265..87f283ee 100644
--- a/frontend/src/views/chat/index.vue
+++ b/frontend/src/views/chat/index.vue
@@ -292,7 +292,7 @@ const createNewChat = async () => {
if (isAssistant.value) {
const assistantChat = await assistantStore.setChat()
if (assistantChat) {
- onChatCreated(assistantChat as any)
+ onChatCreatedQuick(assistantChat as any)
}
return
}
@@ -317,6 +317,26 @@ function onClickHistory(chat: Chat) {
scrollToBottom()
}
+function toAssistantHistory(chat: Chat) {
+ currentChat.value = new ChatInfo(chat)
+ if (chat !== undefined && chat.id !== undefined && !loading.value) {
+ currentChatId.value = chat.id
+ loading.value = true
+ chatApi
+ .get(chat.id)
+ .then((res) => {
+ const info = chatApi.toChatInfo(res)
+ if (info) {
+ currentChat.value = info
+ onClickHistory(info)
+ }
+ })
+ .finally(() => {
+ loading.value = false
+ })
+ }
+}
+
function onChatDeleted(id: number) {
console.log('deleted', id)
}
@@ -434,11 +454,6 @@ const sendMessage = async () => {
loading.value = true
isTyping.value = true
- /* const assistantChat = await assistantStore.setChat()
- if (assistantChat) {
- onChatCreated(assistantChat as any)
- } */
-
const currentRecord = new ChatRecord()
currentRecord.create_time = new Date()
currentRecord.chat_id = currentChatId.value
@@ -833,10 +848,9 @@ const getCurrentChatId = () => {
}
defineExpose({
getHistoryList,
- onClickHistory,
- onChatDeleted,
- onChatRenamed,
+ toAssistantHistory,
getCurrentChatId,
+ createNewChat,
})
diff --git a/frontend/src/views/embedded/assistant.vue b/frontend/src/views/embedded/assistant.vue
index 1ee4d982..04316739 100644
--- a/frontend/src/views/embedded/assistant.vue
+++ b/frontend/src/views/embedded/assistant.vue
@@ -11,6 +11,9 @@