diff --git a/messages/en.json b/messages/en.json index ae89b65..fc5d145 100644 --- a/messages/en.json +++ b/messages/en.json @@ -61,6 +61,10 @@ "title": "Model Setting", "model": "Model", "initialSystemInstructions": "Initial System Instructions", - "save": "Save" + "save": "Save", + "advancedOptions": "View Advanced Options (Context Limit etc.)", + "contextLimit": "Context Limit", + "contextLimitDes": "The number of messages to include in the context for the AI assistant. When set to 1, the AI assistant will only see and remember the most recent message.", + "all": "All" } } diff --git a/messages/zh.json b/messages/zh.json index 5ca45d1..242672b 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -61,6 +61,10 @@ "title": "模型设置", "model": "模型", "initialSystemInstructions": "初始系统说明", - "save": "保存" + "save": "保存", + "advancedOptions": "查看高级选项(上下文限制 等)", + "contextLimit": "上下文限制", + "contextLimitDes": "AI 助手上下文中包含的信息数量。当设置为 1 时,AI 助手将只看到并记住最近的信息。", + "all": "所有" } } diff --git a/src/app/[locale]/chat/[chatId]/PageModelSet.tsx b/src/app/[locale]/chat/[chatId]/PageModelSet.tsx index 51038ce..cc11d10 100644 --- a/src/app/[locale]/chat/[chatId]/PageModelSet.tsx +++ b/src/app/[locale]/chat/[chatId]/PageModelSet.tsx @@ -8,6 +8,21 @@ import { SIDEBAR_CHAT_STORAGE_KEY } from "~/const"; import React, { useState } from "react"; import { Models } from "~/const/switcher"; import { useOpenModalState } from "~/store/page"; +import { Disclosure } from "@headlessui/react"; +import { ChevronRight } from "lucide-react"; + +const contextLimitData = [ + { label: "Last 1 message", value: 1 }, + { label: "Last 2 messages", value: 2 }, + { label: "Last 3 messages", value: 3 }, + { label: "Last 4 messages", value: 4 }, + { label: "Last 5 messages", value: 5 }, + { label: "Last 6 messages", value: 6 }, + { label: "Last 7 messages", value: 7 }, + { label: "Last 8 messages", value: 8 }, + { label: "Last 9 messages", value: 9 }, + { label: "Last 10 messages", value: 10 }, +]; function PageModelSet() { const t = useTranslations("ModelSetting"); @@ -29,10 +44,13 @@ function PageModelSet() { Models.find((model) => model === currentChat.chatModel) as string ); + const [contextLimit, setContextLimit] = useState(currentChat.contextLimit); + const saveModelSetting = () => { const newCurrentChat = { ...currentChat, chatModel: selected, + contextLimit, } as SideBarChatProps; const newSidebarData = sidebarData.map((item) => { if (item.id === selectedChatId) { @@ -44,6 +62,10 @@ function PageModelSet() { setIsModalOpen(false); }; + const contextLimitChange = (e: React.ChangeEvent) => { + setContextLimit(Number(e.target.value)); + }; + return (
@@ -58,6 +80,49 @@ function PageModelSet() { disabled />
+
+ + {({ open }) => ( + <> + + {t("advancedOptions")} + + + +
+
+ {t("contextLimit")} +
+
+ {t("contextLimitDes")} +
+
+ +
+
+
+ + )} +
+
+