### What problem does this PR solve? feat: add RelevantForm #918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.8.0
| @@ -556,6 +556,7 @@ The above is the content you need to summarize.`, | |||
| messagePlaceholder: 'message', | |||
| messageMsg: 'Please input message or delete this field.', | |||
| addField: 'Add field', | |||
| loop: 'Loop', | |||
| }, | |||
| footer: { | |||
| profile: 'All rights reserved @ React', | |||
| @@ -517,6 +517,7 @@ export default { | |||
| messagePlaceholder: '訊息', | |||
| messageMsg: '請輸入訊息或刪除此欄位。', | |||
| addField: '新增字段', | |||
| loop: '環', | |||
| }, | |||
| footer: { | |||
| profile: '“保留所有權利 @ react”', | |||
| @@ -535,6 +535,7 @@ export default { | |||
| messagePlaceholder: '消息', | |||
| messageMsg: '请输入消息或删除此字段。', | |||
| addField: '新增字段', | |||
| loop: '环', | |||
| }, | |||
| footer: { | |||
| profile: 'All rights reserved @ React', | |||
| @@ -1,7 +1,9 @@ | |||
| import { | |||
| BranchesOutlined, | |||
| DatabaseOutlined, | |||
| MergeCellsOutlined, | |||
| MessageOutlined, | |||
| QuestionOutlined, | |||
| RocketOutlined, | |||
| SendOutlined, | |||
| SlidersOutlined, | |||
| @@ -14,6 +16,8 @@ export enum Operator { | |||
| Answer = 'Answer', | |||
| Categorize = 'Categorize', | |||
| Message = 'Message', | |||
| Relevant = 'Relevant', | |||
| RewriteQuestion = 'RewriteQuestion', | |||
| } | |||
| export const operatorIconMap = { | |||
| @@ -23,6 +27,8 @@ export const operatorIconMap = { | |||
| [Operator.Begin]: SlidersOutlined, | |||
| [Operator.Categorize]: DatabaseOutlined, | |||
| [Operator.Message]: MessageOutlined, | |||
| [Operator.Relevant]: BranchesOutlined, | |||
| [Operator.RewriteQuestion]: QuestionOutlined, | |||
| }; | |||
| export const operatorMap = { | |||
| @@ -34,6 +40,8 @@ export const operatorMap = { | |||
| [Operator.Begin]: { description: 'Begin description' }, | |||
| [Operator.Categorize]: { description: 'Categorize description' }, | |||
| [Operator.Message]: { description: 'Message description' }, | |||
| [Operator.Relevant]: { description: 'BranchesOutlined description' }, | |||
| [Operator.RewriteQuestion]: { description: 'RewriteQuestion description' }, | |||
| }; | |||
| export const componentMenuList = [ | |||
| @@ -57,6 +65,14 @@ export const componentMenuList = [ | |||
| name: Operator.Message, | |||
| description: operatorMap[Operator.Message].description, | |||
| }, | |||
| { | |||
| name: Operator.Relevant, | |||
| description: operatorMap[Operator.Relevant].description, | |||
| }, | |||
| { | |||
| name: Operator.RewriteQuestion, | |||
| description: operatorMap[Operator.RewriteQuestion].description, | |||
| }, | |||
| ]; | |||
| export const initialRetrievalValues = { | |||
| @@ -115,6 +131,8 @@ export const RestrictedUpstreamMap = { | |||
| [Operator.Retrieval]: [], | |||
| [Operator.Generate]: [], | |||
| [Operator.Message]: [], | |||
| [Operator.Relevant]: [], | |||
| [Operator.RewriteQuestion]: [], | |||
| }; | |||
| export const NodeMap = { | |||
| @@ -124,4 +142,6 @@ export const NodeMap = { | |||
| [Operator.Generate]: 'ragNode', | |||
| [Operator.Answer]: 'ragNode', | |||
| [Operator.Message]: 'ragNode', | |||
| [Operator.Relevant]: 'ragNode', | |||
| [Operator.RewriteQuestion]: 'ragNode', | |||
| }; | |||
| @@ -9,7 +9,9 @@ import { Operator } from '../constant'; | |||
| import GenerateForm from '../generate-form'; | |||
| import { useHandleFormValuesChange } from '../hooks'; | |||
| import MessageForm from '../message-form'; | |||
| import RelevantForm from '../relevant-form'; | |||
| import RetrievalForm from '../retrieval-form'; | |||
| import RewriteQuestionForm from '../rewrite-question-form'; | |||
| interface IProps { | |||
| node?: Node; | |||
| @@ -22,6 +24,8 @@ const FormMap = { | |||
| [Operator.Answer]: AnswerForm, | |||
| [Operator.Categorize]: CategorizeForm, | |||
| [Operator.Message]: MessageForm, | |||
| [Operator.Relevant]: RelevantForm, | |||
| [Operator.RewriteQuestion]: RewriteQuestionForm, | |||
| }; | |||
| const FlowDrawer = ({ | |||
| @@ -0,0 +1,33 @@ | |||
| import LLMSelect from '@/components/llm-select'; | |||
| import { useTranslate } from '@/hooks/commonHooks'; | |||
| import { Form } from 'antd'; | |||
| import { useSetLlmSetting } from '../hooks'; | |||
| import { IOperatorForm } from '../interface'; | |||
| const RelevantForm = ({ onValuesChange, form }: IOperatorForm) => { | |||
| const { t } = useTranslate('chat'); | |||
| useSetLlmSetting(form); | |||
| return ( | |||
| <Form | |||
| name="basic" | |||
| labelCol={{ span: 8 }} | |||
| wrapperCol={{ span: 16 }} | |||
| style={{ maxWidth: 600 }} | |||
| initialValues={{ remember: true }} | |||
| onValuesChange={onValuesChange} | |||
| autoComplete="off" | |||
| form={form} | |||
| > | |||
| <Form.Item | |||
| name={'llm_id'} | |||
| label={t('model', { keyPrefix: 'chat' })} | |||
| tooltip={t('modelTip', { keyPrefix: 'chat' })} | |||
| > | |||
| <LLMSelect></LLMSelect> | |||
| </Form.Item> | |||
| </Form> | |||
| ); | |||
| }; | |||
| export default RelevantForm; | |||
| @@ -0,0 +1,34 @@ | |||
| import LLMSelect from '@/components/llm-select'; | |||
| import { useTranslate } from '@/hooks/commonHooks'; | |||
| import { Form, InputNumber } from 'antd'; | |||
| import { useSetLlmSetting } from '../hooks'; | |||
| import { IOperatorForm } from '../interface'; | |||
| const RewriteQuestionForm = ({ onValuesChange, form }: IOperatorForm) => { | |||
| const { t } = useTranslate('chat'); | |||
| useSetLlmSetting(form); | |||
| return ( | |||
| <Form | |||
| name="basic" | |||
| labelCol={{ span: 8 }} | |||
| wrapperCol={{ span: 16 }} | |||
| onValuesChange={onValuesChange} | |||
| autoComplete="off" | |||
| form={form} | |||
| > | |||
| <Form.Item | |||
| name={'llm_id'} | |||
| label={t('model', { keyPrefix: 'chat' })} | |||
| tooltip={t('modelTip', { keyPrefix: 'chat' })} | |||
| > | |||
| <LLMSelect></LLMSelect> | |||
| </Form.Item> | |||
| <Form.Item label={t('loop', { keyPrefix: 'flow' })} name="loop"> | |||
| <InputNumber /> | |||
| </Form.Item> | |||
| </Form> | |||
| ); | |||
| }; | |||
| export default RewriteQuestionForm; | |||