Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add RelevantForm #918 #1313

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh-traditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ export default {
messagePlaceholder: '訊息',
messageMsg: '請輸入訊息或刪除此欄位。',
addField: '新增字段',
loop: '環',
},
footer: {
profile: '“保留所有權利 @ react”',
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ export default {
messagePlaceholder: '消息',
messageMsg: '请输入消息或删除此字段。',
addField: '新增字段',
loop: '环',
},
footer: {
profile: 'All rights reserved @ React',
Expand Down
20 changes: 20 additions & 0 deletions web/src/pages/flow/constant.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
BranchesOutlined,
DatabaseOutlined,
MergeCellsOutlined,
MessageOutlined,
QuestionOutlined,
RocketOutlined,
SendOutlined,
SlidersOutlined,
Expand All @@ -14,6 +16,8 @@ export enum Operator {
Answer = 'Answer',
Categorize = 'Categorize',
Message = 'Message',
Relevant = 'Relevant',
RewriteQuestion = 'RewriteQuestion',
}

export const operatorIconMap = {
Expand All @@ -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 = {
Expand All @@ -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 = [
Expand All @@ -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 = {
Expand Down Expand Up @@ -115,6 +131,8 @@ export const RestrictedUpstreamMap = {
[Operator.Retrieval]: [],
[Operator.Generate]: [],
[Operator.Message]: [],
[Operator.Relevant]: [],
[Operator.RewriteQuestion]: [],
};

export const NodeMap = {
Expand All @@ -124,4 +142,6 @@ export const NodeMap = {
[Operator.Generate]: 'ragNode',
[Operator.Answer]: 'ragNode',
[Operator.Message]: 'ragNode',
[Operator.Relevant]: 'ragNode',
[Operator.RewriteQuestion]: 'ragNode',
};
4 changes: 4 additions & 0 deletions web/src/pages/flow/flow-drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +24,8 @@ const FormMap = {
[Operator.Answer]: AnswerForm,
[Operator.Categorize]: CategorizeForm,
[Operator.Message]: MessageForm,
[Operator.Relevant]: RelevantForm,
[Operator.RewriteQuestion]: RewriteQuestionForm,
};

const FlowDrawer = ({
Expand Down
33 changes: 33 additions & 0 deletions web/src/pages/flow/relevant-form/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
34 changes: 34 additions & 0 deletions web/src/pages/flow/rewrite-question-form/index.tsx
Original file line number Diff line number Diff line change
@@ -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;