Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: remove openai setting section (#2084)
boojack218159bf8385
diff --git a/api/v1/system_setting.go b/api/v1/system_setting.goindex 6aec4490f..41fd824b5 100644--- a/api/v1/system_setting.go+++ b/api/v1/system_setting.go@@ -40,8 +40,6 @@ const (SystemSettingTelegramBotTokenName SystemSettingName = "telegram-bot-token"// SystemSettingMemoDisplayWithUpdatedTsName is the name of memo display with updated ts.SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts"- // SystemSettingOpenAIConfigName is the name of OpenAI config.- SystemSettingOpenAIConfigName SystemSettingName = "openai-config"// SystemSettingAutoBackupIntervalName is the name of auto backup interval as seconds.SystemSettingAutoBackupIntervalName SystemSettingName = "auto-backup-interval")@@ -73,11 +71,6 @@ type SystemSetting struct {Description string `json:"description"`}-type OpenAIConfig struct {- Key string `json:"key"`- Host string `json:"host"`-}-type UpsertSystemSettingRequest struct {Name SystemSettingName `json:"name"`Value string `json:"value"`@@ -144,11 +137,6 @@ func (upsert UpsertSystemSettingRequest) Validate() error {if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {return fmt.Errorf(systemSettingUnmarshalError, settingName)}- case SystemSettingOpenAIConfigName:- value := OpenAIConfig{}- if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {- return fmt.Errorf(systemSettingUnmarshalError, settingName)- }case SystemSettingAutoBackupIntervalName:var value intif err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {diff --git a/server/server.go b/server/server.goindex a1da098d5..b3e0173ee 100644--- a/server/server.go+++ b/server/server.go@@ -73,11 +73,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store}))e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{- Skipper: func(c echo.Context) bool {- // this is a hack to skip timeout for openai chat streaming- // because streaming require to flush response. But the timeout middleware will break it.- return c.Request().URL.Path == "/api/v1/openai/chat-streaming"- },ErrorMessage: "Request timeout",Timeout: 30 * time.Second,}))diff --git a/web/src/components/Settings/OpenAISection.tsx b/web/src/components/Settings/OpenAISection.tsxdeleted file mode 100644index 3825ccd1a..000000000--- a/web/src/components/Settings/OpenAISection.tsx+++ /dev/null@@ -1,102 +0,0 @@-import { Button, Input } from "@mui/joy";-import { useEffect, useState } from "react";-import { toast } from "react-hot-toast";-import * as api from "@/helpers/api";-import { useGlobalStore } from "@/store/module";-import { useTranslate } from "@/utils/i18n";-import LearnMore from "../LearnMore";-import "@/less/settings/system-section.less";--interface OpenAIConfig {- key: string;- host: string;-}--const OpenAISection = () => {- const t = useTranslate();- const globalStore = useGlobalStore();- const [openAIConfig, setOpenAIConfig] = useState<OpenAIConfig>({- key: "",- host: "",- });-- useEffect(() => {- globalStore.fetchSystemStatus();- }, []);-- useEffect(() => {- api.getSystemSetting().then(({ data: systemSettings }) => {- const openAIConfigSetting = systemSettings.find((setting) => setting.name === "openai-config");- if (openAIConfigSetting) {- setOpenAIConfig(JSON.parse(openAIConfigSetting.value));- }- });- }, []);-- const handleOpenAIConfigKeyChanged = (value: string) => {- setOpenAIConfig({- ...openAIConfig,- key: value,- });- };-- const handleOpenAIConfigHostChanged = (value: string) => {- setOpenAIConfig({- ...openAIConfig,- host: value,- });- };-- const handleSaveOpenAIConfig = async () => {- try {- await api.upsertSystemSetting({- name: "openai-config",- value: JSON.stringify(openAIConfig),- });- } catch (error) {- console.error(error);- return;- }- toast.success("OpenAI Config updated");- };-- return (- <div className="section-container system-section-container">- <p className="title-text">{t("setting.openai")}</p>- <div className="form-label">- <div className="flex flex-row items-center">- <span className="text-sm mr-1">{t("setting.system-section.openai-api-key")}</span>- <LearnMore title={t("setting.system-section.openai-api-key-description")} url="https://platform.openai.com/account/api-keys" />- </div>- </div>- <Input- className="w-full"- sx={{- fontFamily: "monospace",- fontSize: "14px",- }}- placeholder={t("setting.system-section.openai-api-key-placeholder")}- value={openAIConfig.key}- onChange={(event) => handleOpenAIConfigKeyChanged(event.target.value)}- />- <div className="form-label mt-2">- <span className="normal-text">{t("setting.system-section.openai-api-host")}</span>- </div>- <Input- className="w-full"- sx={{- fontFamily: "monospace",- fontSize: "14px",- }}- placeholder={t("setting.system-section.openai-api-host-placeholder")}- value={openAIConfig.host}- onChange={(event) => handleOpenAIConfigHostChanged(event.target.value)}- />- <div className="mt-4">- <Button onClick={handleSaveOpenAIConfig}>{t("common.save")}</Button>- </div>- </div>- );-};--export default OpenAISection;diff --git a/web/src/helpers/api.ts b/web/src/helpers/api.tsindex 469c3ae75..9c8ed6cda 100644--- a/web/src/helpers/api.ts+++ b/web/src/helpers/api.ts@@ -138,10 +138,6 @@ export function deleteMemo(memoId: MemoId) {return axios.delete(`/api/v1/memo/${memoId}`);}-export function checkOpenAIEnabled() {- return axios.get<boolean>(`/api/openai/enabled`);-}-export function getResourceList() {return axios.get<Resource[]>("/api/v1/resource");}diff --git a/web/src/pages/Setting.tsx b/web/src/pages/Setting.tsxindex b0acd09bf..cc8141a8b 100644--- a/web/src/pages/Setting.tsx+++ b/web/src/pages/Setting.tsx@@ -5,16 +5,15 @@ import Icon from "@/components/Icon";import MobileHeader from "@/components/MobileHeader";import MemberSection from "@/components/Settings/MemberSection";import MyAccountSection from "@/components/Settings/MyAccountSection";-import OpenAISection from "@/components/Settings/OpenAISection";import PreferencesSection from "@/components/Settings/PreferencesSection";import SSOSection from "@/components/Settings/SSOSection";import StorageSection from "@/components/Settings/StorageSection";import SystemSection from "@/components/Settings/SystemSection";-import { useGlobalStore, useUserStore } from "@/store/module";+import { useUserStore } from "@/store/module";import { useTranslate } from "@/utils/i18n";import "@/less/setting.less";-type SettingSection = "my-account" | "preference" | "member" | "system" | "openai" | "storage" | "sso";+type SettingSection = "my-account" | "preference" | "member" | "system" | "storage" | "sso";interface State {selectedSection: SettingSection;@@ -22,7 +21,6 @@ interface State {const Setting = () => {const t = useTranslate();- const globalStore = useGlobalStore();const userStore = useUserStore();const user = userStore.state.user;const [state, setState] = useState<State>({@@ -39,11 +37,7 @@ const Setting = () => {const getSettingSectionList = () => {let settingList: SettingSection[] = ["my-account", "preference"];if (isHost) {- if (globalStore.isDev()) {- settingList = settingList.concat(["member", "system", "openai", "storage", "sso"]);- } else {- settingList = settingList.concat(["member", "system", "storage", "sso"]);- }+ settingList = settingList.concat(["member", "system", "storage", "sso"]);}return settingList;};@@ -84,14 +78,6 @@ const Setting = () => {><Icon.Settings2 className="w-4 h-auto mr-2 opacity-80" /> {t("setting.system")}</span>- {globalStore.isDev() && (- <span- onClick={() => handleSectionSelectorItemClick("openai")}- className={`section-item ${state.selectedSection === "openai" ? "selected" : ""}`}- >- <Icon.Bot className="w-4 h-auto mr-2 opacity-80" /> {t("setting.openai")} <BetaBadge />- </span>- )}<spanonClick={() => handleSectionSelectorItemClick("storage")}className={`section-item ${state.selectedSection === "storage" ? "selected" : ""}`}@@ -128,8 +114,6 @@ const Setting = () => {<MemberSection />) : state.selectedSection === "system" ? (<SystemSection />- ) : state.selectedSection === "openai" ? (- <OpenAISection />) : state.selectedSection === "storage" ? (<StorageSection />) : state.selectedSection === "sso" ? (