|
|
|
@ -33,10 +33,6 @@ const SystemSection = () => {
|
|
|
|
|
memoDisplayWithUpdatedTs: systemStatus.memoDisplayWithUpdatedTs,
|
|
|
|
|
});
|
|
|
|
|
const [telegramBotToken, setTelegramBotToken] = useState<string>("");
|
|
|
|
|
const [openAIConfig, setOpenAIConfig] = useState<OpenAIConfig>({
|
|
|
|
|
key: "",
|
|
|
|
|
host: "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
globalStore.fetchSystemStatus();
|
|
|
|
@ -44,11 +40,6 @@ const SystemSection = () => {
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
api.getSystemSetting().then(({ data: { data: systemSettings } }) => {
|
|
|
|
|
const openAIConfigSetting = systemSettings.find((setting) => setting.name === "openai-config");
|
|
|
|
|
if (openAIConfigSetting) {
|
|
|
|
|
setOpenAIConfig(JSON.parse(openAIConfigSetting.value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const telegramBotSetting = systemSettings.find((setting) => setting.name === "telegram-bot-token");
|
|
|
|
|
if (telegramBotSetting) {
|
|
|
|
|
setTelegramBotToken(telegramBotSetting.value);
|
|
|
|
@ -96,33 +87,6 @@ const SystemSection = () => {
|
|
|
|
|
toast.success(t("message.succeed-vacuum-database"));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleTelegramBotTokenChanged = (value: string) => {
|
|
|
|
|
setTelegramBotToken(value);
|
|
|
|
|
};
|
|
|
|
@ -296,37 +260,6 @@ const SystemSection = () => {
|
|
|
|
|
onChange={(event) => handleTelegramBotTokenChanged(event.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
<Divider className="!mt-3 !my-4" />
|
|
|
|
|
<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>
|
|
|
|
|
<HelpButton hint={t("setting.system-section.openai-api-key-description")} url="https://platform.openai.com/account/api-keys" />
|
|
|
|
|
</div>
|
|
|
|
|
<Button onClick={handleSaveOpenAIConfig}>{t("common.save")}</Button>
|
|
|
|
|
</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)}
|
|
|
|
|
/>
|
|
|
|
|
<Divider className="!mt-3 !my-4" />
|
|
|
|
|
<div className="form-label">
|
|
|
|
|
<span className="normal-text">{t("setting.system-section.additional-style")}</span>
|
|
|
|
|
<Button onClick={handleSaveAdditionalStyle}>{t("common.save")}</Button>
|
|
|
|
|