diff --git a/web/src/components/parse-configuration/graph-rag-form-fields.tsx b/web/src/components/parse-configuration/graph-rag-form-fields.tsx index c9f10e8c5..56e631d4a 100644 --- a/web/src/components/parse-configuration/graph-rag-form-fields.tsx +++ b/web/src/components/parse-configuration/graph-rag-form-fields.tsx @@ -53,12 +53,15 @@ type GraphRagItemsProps = { marginBottom?: boolean; className?: string; data: IGenerateLogButtonProps; + onDelete?: () => void; }; export function UseGraphRagFormField({ data, + onDelete, }: { data: IGenerateLogButtonProps; + onDelete?: () => void; }) { const form = useFormContext(); const { t } = useTranslate('knowledgeConfiguration'); @@ -84,6 +87,7 @@ export function UseGraphRagFormField({ > */} { const { t } = useTranslate('knowledgeConfiguration'); const form = useFormContext(); @@ -131,7 +136,10 @@ const GraphRagItems = ({ return ( - + {useRaptor && ( <> diff --git a/web/src/components/parse-configuration/raptor-form-fields.tsx b/web/src/components/parse-configuration/raptor-form-fields.tsx index a177f2e3b..4571288c7 100644 --- a/web/src/components/parse-configuration/raptor-form-fields.tsx +++ b/web/src/components/parse-configuration/raptor-form-fields.tsx @@ -56,7 +56,13 @@ const Prompt = 'parser_config.raptor.prompt'; // The three types "table", "resume" and "one" do not display this configuration. -const RaptorFormFields = ({ data }: { data: IGenerateLogButtonProps }) => { +const RaptorFormFields = ({ + data, + onDelete, +}: { + data: IGenerateLogButtonProps; + onDelete: () => void; +}) => { const form = useFormContext(); const { t } = useTranslate('knowledgeConfiguration'); const useRaptor = useWatch({ name: UseRaptorField }); @@ -106,6 +112,7 @@ const RaptorFormFields = ({ data }: { data: IGenerateLogButtonProps }) => { ; }; @@ -29,152 +26,47 @@ const FormatPreserveEditor = ({ selectedChunkIds, textMode, }: FormatPreserveEditorProps) => { - const [content, setContent] = useState(initialValue); - // const [isEditing, setIsEditing] = useState(false); - const [activeEditIndex, setActiveEditIndex] = useState( - undefined, - ); console.log('initialValue', initialValue); - useEffect(() => { - setContent(initialValue); - }, [initialValue]); - const handleEdit = (e?: any, index?: number) => { - console.log(e, index, content); - if (content.key === 'json') { - console.log(e, e.target.innerText); - setContent((pre) => ({ - ...pre, - value: pre.value.map((item, i) => { - if (i === index) { - return { - ...item, - [Object.keys(item)[0]]: e.target.innerText, - }; - } - return item; - }), - })); - setActiveEditIndex(index); - } - }; - - const handleChange = (e: any) => { - if (content.key === 'json') { - setContent((pre) => ({ - ...pre, - value: pre.value.map((item, i) => { - if (i === activeEditIndex) { - return { - ...item, - [Object.keys(item)[0]]: e.target.value, - }; - } - return item; - }), - })); - } else { - setContent(e.target.value); - } - }; - const escapeNewlines = (text: string) => { return text.replace(/\n/g, '\\n'); }; const unescapeNewlines = (text: string) => { return text.replace(/\\n/g, '\n'); }; - - const handleSave = () => { - const saveData = { - ...content, - value: content.value?.map((item) => { - return { ...item, text: unescapeNewlines(item.text) }; - }), - }; - onSave(saveData); - setActiveEditIndex(undefined); - }; const handleCheck = (e: CheckedState, id: string | number) => { handleCheckboxClick?.(id, e === 'indeterminate' ? false : e); }; + return (
- {/* {isEditing && content.key === 'json' ? ( -