Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

feat: filter out selected values ​​in other to fields from the curren… (#1307)

balibabu0acf4194ca01
diff --git a/web/src/pages/flow/categorize-form/dynamic-categorize.tsx b/web/src/pages/flow/categorize-form/dynamic-categorize.tsx
index 8843db981a..8beb7e9a2d 100644
--- a/web/src/pages/flow/categorize-form/dynamic-categorize.tsx
+++ b/web/src/pages/flow/categorize-form/dynamic-categorize.tsx
@@ -1,6 +1,7 @@
import { CloseOutlined } from '@ant-design/icons';
import { Button, Card, Form, Input, Select, Typography } from 'antd';
import { useUpdateNodeInternals } from 'reactflow';
+import { ICategorizeItem } from '../interface';
import { useBuildCategorizeToOptions, useHandleToSelectChange } from './hooks';
interface IProps {
@@ -10,7 +11,7 @@ interface IProps {
const DynamicCategorize = ({ nodeId }: IProps) => {
const updateNodeInternals = useUpdateNodeInternals();
const form = Form.useFormInstance();
- const options = useBuildCategorizeToOptions();
+ const buildCategorizeToOptions = useBuildCategorizeToOptions();
const { handleSelectChange } = useHandleToSelectChange(nodeId);
return (
@@ -60,7 +61,15 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
<Form.Item label="to" name={[field.name, 'to']}>
<Select
allowClear
- options={options}
+ options={buildCategorizeToOptions(
+ (form.getFieldValue(['items']) ?? [])
+ .map((x: ICategorizeItem) => x.to)
+ .filter(
+ (x: string) =>
+ x !==
+ form.getFieldValue(['items', field.name, 'to']),
+ ),
+ )}
onChange={handleSelectChange(
form.getFieldValue(['items', field.name, 'name']),
)}
diff --git a/web/src/pages/flow/categorize-form/hooks.ts b/web/src/pages/flow/categorize-form/hooks.ts
index 80df0cf53e..1305e3cbdf 100644
--- a/web/src/pages/flow/categorize-form/hooks.ts
+++ b/web/src/pages/flow/categorize-form/hooks.ts
@@ -17,9 +17,20 @@ const excludedNodes = [Operator.Categorize, Operator.Answer, Operator.Begin];
export const useBuildCategorizeToOptions = () => {
const nodes = useGraphStore((state) => state.nodes);
- return nodes
- .filter((x) => excludedNodes.every((y) => y !== x.data.label))
- .map((x) => ({ label: x.id, value: x.id }));
+ const buildCategorizeToOptions = useCallback(
+ (toList: string[]) => {
+ return nodes
+ .filter(
+ (x) =>
+ excludedNodes.every((y) => y !== x.data.label) &&
+ !toList.some((y) => y === x.id), // filter out selected values ​​in other to fields from the current drop-down box options
+ )
+ .map((x) => ({ label: x.id, value: x.id }));
+ },
+ [nodes],
+ );
+
+ return buildCategorizeToOptions;
};
/**