diff --git a/api/system.go b/api/system.go
index 82e88658..da94161e 100644
--- a/api/system.go
+++ b/api/system.go
@@ -24,4 +24,6 @@ type SystemStatus struct {
StorageServiceID int `json:"storageServiceId"`
// Local storage path
LocalStoragePath string `json:"localStoragePath"`
+ // Local storage path
+ OpenAIConfig OpenAIConfig `json:"openAIConfig"`
}
diff --git a/server/system.go b/server/system.go
index ac521457..5581a17b 100644
--- a/server/system.go
+++ b/server/system.go
@@ -56,6 +56,10 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
},
StorageServiceID: api.DatabaseStorage,
LocalStoragePath: "",
+ OpenAIConfig: api.OpenAIConfig{
+ Key: "",
+ Host: "",
+ },
}
systemSettingList, err := s.Store.FindSystemSettingList(ctx, &api.SystemSettingFind{})
@@ -95,6 +99,13 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
systemStatus.StorageServiceID = int(baseValue.(float64))
} else if systemSetting.Name == api.SystemSettingLocalStoragePathName {
systemStatus.LocalStoragePath = baseValue.(string)
+ } else if systemSetting.Name == api.SystemSettingOpenAIConfigName {
+ openAIConfig := api.OpenAIConfig{}
+ err := json.Unmarshal([]byte(systemSetting.Value), &openAIConfig)
+ if err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting open ai config value").SetInternal(err)
+ }
+ systemStatus.OpenAIConfig = openAIConfig
}
}
diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx
index f4ff0031..6df7b50f 100644
--- a/web/src/components/Header.tsx
+++ b/web/src/components/Header.tsx
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { NavLink, useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
-import { useLayoutStore, useUserStore } from "@/store/module";
+import { useGlobalStore, useLayoutStore, useUserStore } from "@/store/module";
import { resolution } from "@/utils/layout";
import Icon from "./Icon";
import showSettingDialog from "./SettingDialog";
@@ -14,8 +14,10 @@ const Header = () => {
const { t } = useTranslation();
const location = useLocation();
const userStore = useUserStore();
+ const globalStore = useGlobalStore();
const layoutStore = useLayoutStore();
const showHeader = layoutStore.state.showHeader;
+ const showAskAI = globalStore.showAskAI();
const isVisitorMode = userStore.isVisitorMode() && !userStore.state.user;
useEffect(() => {
@@ -107,13 +109,15 @@ const Header = () => {
{!isVisitorMode && (
<>
-
+ {showAskAI && (
+
+ )}