diff --git a/client/src/api/response/chat.d.ts b/client/src/api/response/chat.d.ts index 2d35c78dc..c8c5480be 100644 --- a/client/src/api/response/chat.d.ts +++ b/client/src/api/response/chat.d.ts @@ -5,6 +5,7 @@ export interface InitChatResponse { chatId: string; modelId: string; systemPrompt?: string; + limitPrompt?: string; model: { name: string; avatar: string; diff --git a/client/src/components/Select/index.tsx b/client/src/components/Select/index.tsx index 5faf81d58..4999d5a9d 100644 --- a/client/src/components/Select/index.tsx +++ b/client/src/components/Select/index.tsx @@ -26,7 +26,7 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props return ( - + )} {!!item.quoteLen && ( diff --git a/client/src/pages/model/components/detail/components/Settings.tsx b/client/src/pages/model/components/detail/components/Settings.tsx index d9bb23d3b..19ed4953c 100644 --- a/client/src/pages/model/components/detail/components/Settings.tsx +++ b/client/src/pages/model/components/detail/components/Settings.tsx @@ -1,5 +1,15 @@ import React, { useCallback, useState, useMemo } from 'react'; -import { Box, Flex, Button, FormControl, Input, Textarea, Divider } from '@chakra-ui/react'; +import { + Box, + Flex, + Button, + FormControl, + Input, + Textarea, + Divider, + Tooltip +} from '@chakra-ui/react'; +import { QuestionOutlineIcon } from '@chakra-ui/icons'; import { useQuery } from '@tanstack/react-query'; import { useForm } from 'react-hook-form'; import { useRouter } from 'next/router'; @@ -20,6 +30,11 @@ import Avatar from '@/components/Avatar'; import MySelect from '@/components/Select'; import MySlider from '@/components/Slider'; +const systemPromptTip = + '模型固定的引导词,通过调整该内容,可以引导模型聊天方向。该内容会被固定在上下文的开头。'; +const limitPromptTip = + '限定模型对话范围,会被放置在本次提问前,拥有强引导和限定性。例如:\n1. 知识库是关于 Laf 的介绍,参考知识库回答问题,与 "Laf" 无关内容,直接回复: "我不知道"。\n2. 你仅回答关于 "xxx" 的问题,其他问题回复: "xxxx"'; + const Settings = ({ modelId }: { modelId: string }) => { const { toast } = useToast(); const router = useRouter(); @@ -60,7 +75,7 @@ const Settings = ({ modelId }: { modelId: string }) => { } return max; - }, [getValues, setValue, refresh]); + }, [getValues, setValue]); // 提交保存模型修改 const saveSubmitSuccess = useCallback( @@ -211,7 +226,7 @@ const Settings = ({ modelId }: { modelId: string }) => { 介绍 + + + 限定词 + + + + + + diff --git a/client/src/service/models/model.ts b/client/src/service/models/model.ts index 1b537b9ca..c75225dd3 100644 --- a/client/src/service/models/model.ts +++ b/client/src/service/models/model.ts @@ -43,7 +43,10 @@ const ModelSchema = new Schema({ default: '' }, systemPrompt: { - // 系统提示词 + type: String, + default: '' + }, + limitPrompt: { type: String, default: '' }, diff --git a/client/src/types/mongoSchema.d.ts b/client/src/types/mongoSchema.d.ts index b0338b065..19c961ba3 100644 --- a/client/src/types/mongoSchema.d.ts +++ b/client/src/types/mongoSchema.d.ts @@ -43,6 +43,7 @@ export interface ModelSchema { searchLimit: number; searchEmptyText: string; systemPrompt: string; + limitPrompt: string; temperature: number; maxToken: number; chatModel: ChatModelType; // 聊天时用的模型,训练后就是训练的模型