From 480ec2d463f75dec6df0237bcc02e7f735f3ef81 Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 18 Apr 2023 10:16:11 +0800 Subject: [PATCH] chore: declare bots id --- src/components/QueryDrawer.tsx | 2 +- src/store/assistant.ts | 3 +++ src/store/conversation.ts | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/QueryDrawer.tsx b/src/components/QueryDrawer.tsx index 4786f94..17223b8 100644 --- a/src/components/QueryDrawer.tsx +++ b/src/components/QueryDrawer.tsx @@ -21,7 +21,7 @@ const QueryDrawer = () => { const [isLoading, setIsLoading] = useState(false); const context = queryStore.context; const executionMessage = executionResult ? getMessageFromExecutionResult(executionResult) : ""; - const showExecutionWarningBanner = !checkStatementIsSelect(statement); + const showExecutionWarningBanner = statement.trim() && !checkStatementIsSelect(statement); useEffect(() => { if (!queryStore.showDrawer) { diff --git a/src/store/assistant.ts b/src/store/assistant.ts index bff41d5..4badaae 100644 --- a/src/store/assistant.ts +++ b/src/store/assistant.ts @@ -2,6 +2,9 @@ import { first } from "lodash-es"; import { Assistant, Id } from "@/types"; import * as customAssistantList from "../../assistants"; +export const GeneralBotId = "general-bot"; +export const SQLChatBotId = "sql-chat-bot"; + export const assistantList: Assistant[] = Object.keys(customAssistantList).map((name) => { return { ...((customAssistantList as any)[name].default as Assistant), diff --git a/src/store/conversation.ts b/src/store/conversation.ts index 6d1c296..feeb890 100644 --- a/src/store/conversation.ts +++ b/src/store/conversation.ts @@ -3,11 +3,12 @@ import { create } from "zustand"; import { persist } from "zustand/middleware"; import { Conversation, Id } from "@/types"; import { generateUUID } from "@/utils"; +import { GeneralBotId, SQLChatBotId } from "."; const getDefaultConversation = (): Conversation => { return { id: generateUUID(), - assistantId: "general-bot", + assistantId: GeneralBotId, title: dayjs().format("LTS"), createdAt: Date.now(), }; @@ -36,7 +37,7 @@ export const useConversationStore = create()( databaseName, }; if (connectionId) { - conversation.assistantId = "sql-chat-bot"; + conversation.assistantId = SQLChatBotId; } set((state) => ({ conversationList: [...state.conversationList, conversation],