feat: add plugin instruction config (#2579)

* feat: add plugin instruction config

* fix build
This commit is contained in:
heheer
2024-08-30 17:12:57 +08:00
committed by GitHub
parent 2ef98c24be
commit 903f39fe17
20 changed files with 278 additions and 12 deletions

View File

@@ -1,16 +1,26 @@
import React, { useEffect, useMemo } from 'react';
import { Controller } from 'react-hook-form';
import RenderPluginInput from './renderPluginInput';
import { Button, Flex } from '@chakra-ui/react';
import { Box, Button, Flex } from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
import { useContextSelector } from 'use-context-selector';
import { PluginRunContext } from '../context';
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
import { isEqual } from 'lodash';
import { AppChatConfigType } from '@fastgpt/global/core/app/type';
import Markdown from '@/components/Markdown';
const RenderInput = () => {
const { pluginInputs, variablesForm, histories, onStartChat, onNewChat, onSubmit, isChatting } =
useContextSelector(PluginRunContext, (v) => v);
const {
pluginInputs,
variablesForm,
histories,
onStartChat,
onNewChat,
onSubmit,
isChatting,
chatConfig
} = useContextSelector(PluginRunContext, (v) => v);
const { t } = useTranslation();
const {
@@ -64,6 +74,20 @@ const RenderInput = () => {
return (
<>
{/* instruction */}
{chatConfig?.instruction && (
<Box
border={'1px solid'}
borderColor={'myGray.250'}
p={4}
rounded={'md'}
fontSize={'sm'}
color={'myGray.600'}
>
<Markdown source={chatConfig.instruction} />
</Box>
)}
{pluginInputs.map((input) => {
return (
<Controller

View File

@@ -19,4 +19,5 @@ export type PluginRunBoxProps = OutLinkChatAuthProps & {
chatId?: string;
tab: PluginRunBoxTabEnum;
setTab: React.Dispatch<React.SetStateAction<PluginRunBoxTabEnum>>;
chatConfig?: AppChatConfigType;
};