mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	Merge pull request #1644 from Yidadaa/bugfix0519
feat: close #1478 new chat use global config as default
This commit is contained in:
		@@ -2,6 +2,7 @@ import { NextRequest } from "next/server";
 | 
			
		||||
import { getServerSideConfig } from "../config/server";
 | 
			
		||||
import md5 from "spark-md5";
 | 
			
		||||
import { ACCESS_CODE_PREFIX } from "../constant";
 | 
			
		||||
import { OPENAI_URL } from "./common";
 | 
			
		||||
 | 
			
		||||
function getIP(req: NextRequest) {
 | 
			
		||||
  let ip = req.ip ?? req.headers.get("x-real-ip");
 | 
			
		||||
@@ -55,7 +56,7 @@ export function auth(req: NextRequest) {
 | 
			
		||||
    } else {
 | 
			
		||||
      console.log("[Auth] admin did not provide an api key");
 | 
			
		||||
      return {
 | 
			
		||||
        error: true,
 | 
			
		||||
        error: serverConfig.baseUrl?.includes(OPENAI_URL),
 | 
			
		||||
        msg: "admin did not provide an api key",
 | 
			
		||||
      };
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import { NextRequest } from "next/server";
 | 
			
		||||
 | 
			
		||||
const OPENAI_URL = "api.openai.com";
 | 
			
		||||
export const OPENAI_URL = "api.openai.com";
 | 
			
		||||
const DEFAULT_PROTOCOL = "https";
 | 
			
		||||
const PROTOCOL = process.env.PROTOCOL ?? DEFAULT_PROTOCOL;
 | 
			
		||||
const BASE_URL = process.env.BASE_URL ?? OPENAI_URL;
 | 
			
		||||
@@ -45,8 +45,8 @@ export async function requestOpenai(req: NextRequest) {
 | 
			
		||||
      signal: controller.signal,
 | 
			
		||||
    });
 | 
			
		||||
  } catch (err: unknown) {
 | 
			
		||||
    if (err instanceof Error && err.name === 'AbortError') {
 | 
			
		||||
      console.log('Fetch aborted');
 | 
			
		||||
    if (err instanceof Error && err.name === "AbortError") {
 | 
			
		||||
      console.log("Fetch aborted");
 | 
			
		||||
    } else {
 | 
			
		||||
      throw err;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -143,6 +143,7 @@ export function SessionConfigModel(props: { onClose: () => void }) {
 | 
			
		||||
            updater(mask);
 | 
			
		||||
            chatStore.updateCurrentSession((session) => (session.mask = mask));
 | 
			
		||||
          }}
 | 
			
		||||
          shouldSyncFromGlobal
 | 
			
		||||
          extraListItems={
 | 
			
		||||
            session.mask.modelConfig.sendMemory ? (
 | 
			
		||||
              <ListItem
 | 
			
		||||
@@ -505,7 +506,14 @@ export function Chat() {
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      // auto sync mask config from global config
 | 
			
		||||
      if (session.mask.syncGlobalConfig) {
 | 
			
		||||
        console.log("[Mask] syncing from global, name = ", session.mask.name);
 | 
			
		||||
        session.mask.modelConfig = { ...config.modelConfig };
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
    // eslint-disable-next-line react-hooks/exhaustive-deps
 | 
			
		||||
  }, []);
 | 
			
		||||
 | 
			
		||||
  // check if should send message
 | 
			
		||||
 
 | 
			
		||||
@@ -13,15 +13,15 @@ import EyeIcon from "../icons/eye.svg";
 | 
			
		||||
import CopyIcon from "../icons/copy.svg";
 | 
			
		||||
 | 
			
		||||
import { DEFAULT_MASK_AVATAR, Mask, useMaskStore } from "../store/mask";
 | 
			
		||||
import { ChatMessage, ModelConfig, useChatStore } from "../store";
 | 
			
		||||
import { ChatMessage, ModelConfig, useAppConfig, useChatStore } from "../store";
 | 
			
		||||
import { ROLES } from "../client/api";
 | 
			
		||||
import { Input, List, ListItem, Modal, Popover, Select } from "./ui-lib";
 | 
			
		||||
import { Avatar, AvatarPicker } from "./emoji";
 | 
			
		||||
import Locale, { AllLangs, Lang } from "../locales";
 | 
			
		||||
import Locale, { AllLangs, ALL_LANG_OPTIONS, Lang } from "../locales";
 | 
			
		||||
import { useNavigate } from "react-router-dom";
 | 
			
		||||
 | 
			
		||||
import chatStyle from "./chat.module.scss";
 | 
			
		||||
import { useState } from "react";
 | 
			
		||||
import { useEffect, useState } from "react";
 | 
			
		||||
import { downloadAs, readFromFile } from "../utils";
 | 
			
		||||
import { Updater } from "../typing";
 | 
			
		||||
import { ModelConfigList } from "./model-config";
 | 
			
		||||
@@ -41,6 +41,7 @@ export function MaskConfig(props: {
 | 
			
		||||
  updateMask: Updater<Mask>;
 | 
			
		||||
  extraListItems?: JSX.Element;
 | 
			
		||||
  readonly?: boolean;
 | 
			
		||||
  shouldSyncFromGlobal?: boolean;
 | 
			
		||||
}) {
 | 
			
		||||
  const [showPicker, setShowPicker] = useState(false);
 | 
			
		||||
 | 
			
		||||
@@ -49,9 +50,15 @@ export function MaskConfig(props: {
 | 
			
		||||
 | 
			
		||||
    const config = { ...props.mask.modelConfig };
 | 
			
		||||
    updater(config);
 | 
			
		||||
    props.updateMask((mask) => (mask.modelConfig = config));
 | 
			
		||||
    props.updateMask((mask) => {
 | 
			
		||||
      mask.modelConfig = config;
 | 
			
		||||
      // if user changed current session mask, it will disable auto sync
 | 
			
		||||
      mask.syncGlobalConfig = false;
 | 
			
		||||
    });
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const globalConfig = useAppConfig();
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <>
 | 
			
		||||
      <ContextPrompts
 | 
			
		||||
@@ -90,10 +97,32 @@ export function MaskConfig(props: {
 | 
			
		||||
            type="text"
 | 
			
		||||
            value={props.mask.name}
 | 
			
		||||
            onInput={(e) =>
 | 
			
		||||
              props.updateMask((mask) => (mask.name = e.currentTarget.value))
 | 
			
		||||
              props.updateMask((mask) => {
 | 
			
		||||
                mask.name = e.currentTarget.value;
 | 
			
		||||
              })
 | 
			
		||||
            }
 | 
			
		||||
          ></input>
 | 
			
		||||
        </ListItem>
 | 
			
		||||
        <ListItem
 | 
			
		||||
          title={Locale.Mask.Config.Sync.Title}
 | 
			
		||||
          subTitle={Locale.Mask.Config.Sync.SubTitle}
 | 
			
		||||
        >
 | 
			
		||||
          <input
 | 
			
		||||
            type="checkbox"
 | 
			
		||||
            checked={props.mask.syncGlobalConfig}
 | 
			
		||||
            onChange={(e) => {
 | 
			
		||||
              if (
 | 
			
		||||
                e.currentTarget.checked &&
 | 
			
		||||
                confirm(Locale.Mask.Config.Sync.Confirm)
 | 
			
		||||
              ) {
 | 
			
		||||
                props.updateMask((mask) => {
 | 
			
		||||
                  mask.syncGlobalConfig = e.currentTarget.checked;
 | 
			
		||||
                  mask.modelConfig = { ...globalConfig.modelConfig };
 | 
			
		||||
                });
 | 
			
		||||
              }
 | 
			
		||||
            }}
 | 
			
		||||
          ></input>
 | 
			
		||||
        </ListItem>
 | 
			
		||||
      </List>
 | 
			
		||||
 | 
			
		||||
      <List>
 | 
			
		||||
@@ -330,7 +359,7 @@ export function MaskPage() {
 | 
			
		||||
              </option>
 | 
			
		||||
              {AllLangs.map((lang) => (
 | 
			
		||||
                <option value={lang} key={lang}>
 | 
			
		||||
                  {Locale.Settings.Lang.Options[lang]}
 | 
			
		||||
                  {ALL_LANG_OPTIONS[lang]}
 | 
			
		||||
                </option>
 | 
			
		||||
              ))}
 | 
			
		||||
            </Select>
 | 
			
		||||
@@ -358,7 +387,7 @@ export function MaskPage() {
 | 
			
		||||
                    <div className={styles["mask-name"]}>{m.name}</div>
 | 
			
		||||
                    <div className={styles["mask-info"] + " one-line"}>
 | 
			
		||||
                      {`${Locale.Mask.Item.Info(m.context.length)} / ${
 | 
			
		||||
                        Locale.Settings.Lang.Options[m.lang]
 | 
			
		||||
                        ALL_LANG_OPTIONS[m.lang]
 | 
			
		||||
                      } / ${m.modelConfig.model}`}
 | 
			
		||||
                    </div>
 | 
			
		||||
                  </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,12 @@ import {
 | 
			
		||||
  useAppConfig,
 | 
			
		||||
} from "../store";
 | 
			
		||||
 | 
			
		||||
import Locale, { AllLangs, changeLang, getLang } from "../locales";
 | 
			
		||||
import Locale, {
 | 
			
		||||
  AllLangs,
 | 
			
		||||
  ALL_LANG_OPTIONS,
 | 
			
		||||
  changeLang,
 | 
			
		||||
  getLang,
 | 
			
		||||
} from "../locales";
 | 
			
		||||
import { copyToClipboard } from "../utils";
 | 
			
		||||
import Link from "next/link";
 | 
			
		||||
import { Path, UPDATE_URL } from "../constant";
 | 
			
		||||
@@ -419,7 +424,7 @@ export function Settings() {
 | 
			
		||||
            >
 | 
			
		||||
              {AllLangs.map((lang) => (
 | 
			
		||||
                <option value={lang} key={lang}>
 | 
			
		||||
                  {Locale.Settings.Lang.Options[lang]}
 | 
			
		||||
                  {ALL_LANG_OPTIONS[lang]}
 | 
			
		||||
                </option>
 | 
			
		||||
              ))}
 | 
			
		||||
            </Select>
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ declare global {
 | 
			
		||||
    interface ProcessEnv {
 | 
			
		||||
      OPENAI_API_KEY?: string;
 | 
			
		||||
      CODE?: string;
 | 
			
		||||
      BASE_URL?: string;
 | 
			
		||||
      PROXY_URL?: string;
 | 
			
		||||
      VERCEL?: string;
 | 
			
		||||
      HIDE_USER_API_KEY?: string; // disable user's api key input
 | 
			
		||||
@@ -38,6 +39,7 @@ export const getServerSideConfig = () => {
 | 
			
		||||
    code: process.env.CODE,
 | 
			
		||||
    codes: ACCESS_CODES,
 | 
			
		||||
    needCode: ACCESS_CODES.size > 0,
 | 
			
		||||
    baseUrl: process.env.BASE_URL,
 | 
			
		||||
    proxyUrl: process.env.PROXY_URL,
 | 
			
		||||
    isVercel: !!process.env.VERCEL,
 | 
			
		||||
    hideUserApiKey: !!process.env.HIDE_USER_API_KEY,
 | 
			
		||||
 
 | 
			
		||||
@@ -69,21 +69,6 @@ const cn = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "所有语言",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "头像",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
@@ -220,6 +205,11 @@ const cn = {
 | 
			
		||||
    Config: {
 | 
			
		||||
      Avatar: "角色头像",
 | 
			
		||||
      Name: "角色名称",
 | 
			
		||||
      Sync: {
 | 
			
		||||
        Title: "使用全局设置",
 | 
			
		||||
        SubTitle: "当前对话是否使用全局模型设置",
 | 
			
		||||
        Confirm: "当前对话的自定义设置将会被自动覆盖,确认启用全局设置?",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  NewChat: {
 | 
			
		||||
@@ -247,5 +237,6 @@ type DeepPartial<T> = T extends object
 | 
			
		||||
    }
 | 
			
		||||
  : T;
 | 
			
		||||
export type LocaleType = DeepPartial<typeof cn>;
 | 
			
		||||
export type RequiredLocaleType = typeof cn;
 | 
			
		||||
 | 
			
		||||
export default cn;
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const cs: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "Všechny jazyky",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Avatar",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -72,21 +72,6 @@ const de: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "Alle Sprachen",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Avatar",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import { SubmitKey } from "../store/config";
 | 
			
		||||
import type { LocaleType } from "./index";
 | 
			
		||||
import { RequiredLocaleType } from "./index";
 | 
			
		||||
 | 
			
		||||
const en: LocaleType = {
 | 
			
		||||
const en: RequiredLocaleType = {
 | 
			
		||||
  WIP: "Coming Soon...",
 | 
			
		||||
  Error: {
 | 
			
		||||
    Unauthorized:
 | 
			
		||||
@@ -71,21 +71,6 @@ const en: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "All Languages",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Avatar",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
@@ -223,6 +208,11 @@ const en: LocaleType = {
 | 
			
		||||
    Config: {
 | 
			
		||||
      Avatar: "Bot Avatar",
 | 
			
		||||
      Name: "Bot Name",
 | 
			
		||||
      Sync: {
 | 
			
		||||
        Title: "Use Global Config",
 | 
			
		||||
        SubTitle: "Use global config in this chat",
 | 
			
		||||
        Confirm: "Confirm to override custom config with global config?",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  NewChat: {
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const es: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "Todos los idiomas",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어"
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Avatar",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -72,21 +72,6 @@ const fr: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION : si vous souhaitez ajouter une nouvelle traduction, ne traduisez pas cette valeur, laissez-la sous forme de `Language`
 | 
			
		||||
      All: "Toutes les langues",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Vietnamese",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어"
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    Avatar: "Avatar",
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ import CS from "./cs";
 | 
			
		||||
import KO from "./ko";
 | 
			
		||||
import { merge } from "../utils/merge";
 | 
			
		||||
 | 
			
		||||
export type { LocaleType } from "./cn";
 | 
			
		||||
export type { LocaleType, RequiredLocaleType } from "./cn";
 | 
			
		||||
 | 
			
		||||
export const AllLangs = [
 | 
			
		||||
  "en",
 | 
			
		||||
@@ -32,6 +32,22 @@ export const AllLangs = [
 | 
			
		||||
] as const;
 | 
			
		||||
export type Lang = (typeof AllLangs)[number];
 | 
			
		||||
 | 
			
		||||
export const ALL_LANG_OPTIONS: Record<Lang, string> = {
 | 
			
		||||
  cn: "简体中文",
 | 
			
		||||
  en: "English",
 | 
			
		||||
  tw: "繁體中文",
 | 
			
		||||
  fr: "Français",
 | 
			
		||||
  es: "Español",
 | 
			
		||||
  it: "Italiano",
 | 
			
		||||
  tr: "Türkçe",
 | 
			
		||||
  jp: "日本語",
 | 
			
		||||
  de: "Deutsch",
 | 
			
		||||
  vi: "Tiếng Việt",
 | 
			
		||||
  ru: "Русский",
 | 
			
		||||
  cs: "Čeština",
 | 
			
		||||
  ko: "한국어",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const LANG_KEY = "lang";
 | 
			
		||||
const DEFAULT_LANG = "en";
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const it: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "Tutte le lingue",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Avatar",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const jp: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "所有语言",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어"
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "アバター",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const ko: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "All Languages",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "아바타",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
@@ -135,8 +120,7 @@ const ko: LocaleType = {
 | 
			
		||||
    },
 | 
			
		||||
    CompressThreshold: {
 | 
			
		||||
      Title: "기록 압축 임계값",
 | 
			
		||||
      SubTitle:
 | 
			
		||||
        "미압축 메시지 길이가 임계값을 초과하면 압축됨",
 | 
			
		||||
      SubTitle: "미압축 메시지 길이가 임계값을 초과하면 압축됨",
 | 
			
		||||
    },
 | 
			
		||||
    Token: {
 | 
			
		||||
      Title: "API 키",
 | 
			
		||||
@@ -168,8 +152,7 @@ const ko: LocaleType = {
 | 
			
		||||
    },
 | 
			
		||||
    PresencePenalty: {
 | 
			
		||||
      Title: "존재 페널티 (presence_penalty)",
 | 
			
		||||
      SubTitle:
 | 
			
		||||
        "값이 클수록 새로운 주제에 대해 대화할 가능성이 높아집니다.",
 | 
			
		||||
      SubTitle: "값이 클수록 새로운 주제에 대해 대화할 가능성이 높아집니다.",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  Store: {
 | 
			
		||||
@@ -178,8 +161,7 @@ const ko: LocaleType = {
 | 
			
		||||
    Error: "문제가 발생했습니다. 나중에 다시 시도해주세요.",
 | 
			
		||||
    Prompt: {
 | 
			
		||||
      History: (content: string) =>
 | 
			
		||||
        "이것은 AI와 사용자 간의 대화 기록을 요약한 내용입니다: " +
 | 
			
		||||
        content,
 | 
			
		||||
        "이것은 AI와 사용자 간의 대화 기록을 요약한 내용입니다: " + content,
 | 
			
		||||
      Topic:
 | 
			
		||||
        "다음과 같이 대화 내용을 요약하는 4~5단어 제목을 생성해주세요. 따옴표, 구두점, 인용부호, 기호 또는 추가 텍스트를 제거하십시오. 따옴표로 감싸진 부분을 제거하십시오.",
 | 
			
		||||
      Summarize:
 | 
			
		||||
@@ -232,7 +214,8 @@ const ko: LocaleType = {
 | 
			
		||||
    SubTitle: "마스크 뒤의 영혼과 대화하세요",
 | 
			
		||||
    More: "더 보기",
 | 
			
		||||
    NotShow: "다시 표시하지 않음",
 | 
			
		||||
    ConfirmNoShow: "비활성화하시겠습니까? 나중에 설정에서 다시 활성화할 수 있습니다.",
 | 
			
		||||
    ConfirmNoShow:
 | 
			
		||||
      "비활성화하시겠습니까? 나중에 설정에서 다시 활성화할 수 있습니다.",
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  UI: {
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const ru: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "Все языки",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Аватар",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const tr: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "Tüm Diller",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Avatar",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -69,21 +69,6 @@ const tw: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "所有语言",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "大頭貼",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -71,21 +71,6 @@ const vi: LocaleType = {
 | 
			
		||||
    Lang: {
 | 
			
		||||
      Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
 | 
			
		||||
      All: "Tất cả ngôn ngữ",
 | 
			
		||||
      Options: {
 | 
			
		||||
        cn: "简体中文",
 | 
			
		||||
        en: "English",
 | 
			
		||||
        tw: "繁體中文",
 | 
			
		||||
        fr: "Français",
 | 
			
		||||
        es: "Español",
 | 
			
		||||
        it: "Italiano",
 | 
			
		||||
        tr: "Türkçe",
 | 
			
		||||
        jp: "日本語",
 | 
			
		||||
        de: "Deutsch",
 | 
			
		||||
        vi: "Tiếng Việt",
 | 
			
		||||
        ru: "Русский",
 | 
			
		||||
        cs: "Čeština",
 | 
			
		||||
        ko: "한국어",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    Avatar: "Ảnh đại diện",
 | 
			
		||||
    FontSize: {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,9 +5,9 @@ import { trimTopic } from "../utils";
 | 
			
		||||
 | 
			
		||||
import Locale from "../locales";
 | 
			
		||||
import { showToast } from "../components/ui-lib";
 | 
			
		||||
import { ModelType } from "./config";
 | 
			
		||||
import { ModelType, useAppConfig } from "./config";
 | 
			
		||||
import { createEmptyMask, Mask } from "./mask";
 | 
			
		||||
import { REQUEST_TIMEOUT_MS, StoreKey } from "../constant";
 | 
			
		||||
import { StoreKey } from "../constant";
 | 
			
		||||
import { api, RequestMessage } from "../client/api";
 | 
			
		||||
import { ChatControllerPool } from "../client/controller";
 | 
			
		||||
import { prettyObject } from "../utils/format";
 | 
			
		||||
@@ -38,7 +38,6 @@ export interface ChatStat {
 | 
			
		||||
 | 
			
		||||
export interface ChatSession {
 | 
			
		||||
  id: number;
 | 
			
		||||
 | 
			
		||||
  topic: string;
 | 
			
		||||
 | 
			
		||||
  memoryPrompt: string;
 | 
			
		||||
@@ -69,6 +68,7 @@ function createEmptySession(): ChatSession {
 | 
			
		||||
    },
 | 
			
		||||
    lastUpdate: Date.now(),
 | 
			
		||||
    lastSummarizeIndex: 0,
 | 
			
		||||
 | 
			
		||||
    mask: createEmptyMask(),
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
@@ -463,7 +463,7 @@ export const useChatStore = create<ChatStore>()(
 | 
			
		||||
 | 
			
		||||
        if (
 | 
			
		||||
          historyMsgLength > modelConfig.compressMessageLengthThreshold &&
 | 
			
		||||
          session.mask.modelConfig.sendMemory
 | 
			
		||||
          modelConfig.sendMemory
 | 
			
		||||
        ) {
 | 
			
		||||
          api.llm.chat({
 | 
			
		||||
            messages: toBeSummarizedMsgs.concat({
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ export type Mask = {
 | 
			
		||||
  avatar: string;
 | 
			
		||||
  name: string;
 | 
			
		||||
  context: ChatMessage[];
 | 
			
		||||
  syncGlobalConfig?: boolean;
 | 
			
		||||
  modelConfig: ModelConfig;
 | 
			
		||||
  lang: Lang;
 | 
			
		||||
  builtin: boolean;
 | 
			
		||||
@@ -39,6 +40,7 @@ export const createEmptyMask = () =>
 | 
			
		||||
    avatar: DEFAULT_MASK_AVATAR,
 | 
			
		||||
    name: DEFAULT_TOPIC,
 | 
			
		||||
    context: [],
 | 
			
		||||
    syncGlobalConfig: true, // use global config as default
 | 
			
		||||
    modelConfig: { ...useAppConfig.getState().modelConfig },
 | 
			
		||||
    lang: getLang(),
 | 
			
		||||
    builtin: false,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user