From 5e4dd8acf74954d375eed9aaf2412fb7cf212723 Mon Sep 17 00:00:00 2001 From: tianzhou Date: Wed, 31 May 2023 18:01:38 +0800 Subject: [PATCH 1/2] chore: replace supabase with neon as the sample database consolidate --- src/store/connection.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store/connection.ts b/src/store/connection.ts index fb72d7fb..7bd54d45 100644 --- a/src/store/connection.ts +++ b/src/store/connection.ts @@ -15,10 +15,10 @@ const samplePGConnection: Connection = { id: "sample-pg", title: "Sample PostgreSQL", engineType: Engine.PostgreSQL, - host: "db.swxkyqvcefxcjecynews.supabase.co", + host: "ep-throbbing-thunder-042250.us-west-2.aws.neon.tech", port: "5432", - username: "readonly_user", - password: "sqlchat", + username: "sqlchat", + password: "h8yik1pvTQIs", database: "sample-employee", }; From 4a7243524b9724ce7f25f60ee3f5f0e97f9f06ee Mon Sep 17 00:00:00 2001 From: tianzhou Date: Wed, 31 May 2023 18:33:57 +0800 Subject: [PATCH 2/2] chore: optimize token UX --- src/components/ConnectionSidebar.tsx | 20 +++++++++++++------- src/components/kit/Checkbox.tsx | 4 ++-- src/locales/en.json | 2 +- src/locales/es.json | 2 +- src/locales/zh.json | 2 +- src/store/connection.ts | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/components/ConnectionSidebar.tsx b/src/components/ConnectionSidebar.tsx index b7aca7fc..e3da7398 100644 --- a/src/components/ConnectionSidebar.tsx +++ b/src/components/ConnectionSidebar.tsx @@ -9,7 +9,7 @@ import Icon from "./Icon"; import DarkModeSwitch from "./DarkModeSwitch"; import ConnectionList from "./Sidebar/ConnectionList"; import QuotaView from "./QuotaView"; -import { countTextTokens, hasFeature } from "../utils"; +import { countTextTokens, getModel, hasFeature } from "../utils"; import SettingAvatarIcon from "./SettingAvatarIcon"; import Checkbox from "./kit/Checkbox"; @@ -33,6 +33,7 @@ const ConnectionSidebar = () => { conversationStore.getConversationById(conversationStore.currentConversationId)?.selectedSchemaName || ""; const tableSchemaLoadingState = useLoading(); const currentConversation = conversationStore.getConversationById(conversationStore.currentConversationId); + const maxToken = getModel(settingStore.setting.openAIApiConfig?.model || "").max_token; const [totalToken, setTotalToken] = useState(0); useEffect(() => { updateHasSchemaProperty( @@ -193,7 +194,7 @@ const ConnectionSidebar = () => { {databaseList.length > 0 && (
{ return { @@ -243,10 +244,15 @@ const ConnectionSidebar = () => { ))}
-
-
- {t("connection.total-token")} {totalToken} -
+
+ {currentConnectionCtx && ( +
+
{t("connection.total-token")}
+
+ {totalToken}/{maxToken} +
+
+ )} {!settingStore.setting.openAIApiConfig?.key && hasFeature("quota") && (
diff --git a/src/components/kit/Checkbox.tsx b/src/components/kit/Checkbox.tsx index d292b8e6..f64abe63 100644 --- a/src/components/kit/Checkbox.tsx +++ b/src/components/kit/Checkbox.tsx @@ -11,7 +11,7 @@ const Checkbox = (props: CheckboxProps & { children?: ReactNode }) => { const { value, label, onValueChange, children } = props; return (
-
+
onValueChange(label, value)} @@ -22,7 +22,7 @@ const Checkbox = (props: CheckboxProps & { children?: ReactNode }) => { -