balibabu
commited on
Commit
·
ad5587c
1
Parent(s):
9ba804f
feat: Disable automatic saving of agent during running agent #3349 (#3350)
Browse files### What problem does this PR solve?
feat: Disable automatic saving of agent during running agent #3349
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/pages/add-knowledge/components/knowledge-setting/utils.ts +0 -108
- web/src/pages/flow/chat/drawer.tsx +2 -1
- web/src/pages/flow/flow-drawer/index.tsx +2 -1
- web/src/pages/flow/form/generate-form/index.tsx +1 -1
- web/src/pages/flow/header/index.tsx +3 -2
- web/src/pages/flow/hooks.ts +6 -4
- web/src/pages/flow/index.tsx +4 -1
- web/src/pages/flow/utils.ts +4 -0
web/src/pages/add-knowledge/components/knowledge-setting/utils.ts
CHANGED
|
@@ -17,111 +17,3 @@ export const ImageMap = {
|
|
| 17 |
one: getImageName('one', 2),
|
| 18 |
knowledge_graph: getImageName('knowledge-graph', 2),
|
| 19 |
};
|
| 20 |
-
|
| 21 |
-
export const TextMap = {
|
| 22 |
-
book: {
|
| 23 |
-
title: '',
|
| 24 |
-
description: `<p>Supported file formats are <b>DOCX</b>, <b>PDF</b>, <b>TXT</b>.</p><p>
|
| 25 |
-
Since a book is long and not all the parts are useful, if it's a PDF,
|
| 26 |
-
please setup the <i>page ranges</i> for every book in order eliminate negative effects and save computing time for analyzing.</p>`,
|
| 27 |
-
},
|
| 28 |
-
laws: {
|
| 29 |
-
title: '',
|
| 30 |
-
description: `<p>Supported file formats are <b>DOCX</b>, <b>PDF</b>, <b>TXT</b>.</p><p>
|
| 31 |
-
Legal documents have a very rigorous writing format. We use text feature to detect split point.
|
| 32 |
-
</p><p>
|
| 33 |
-
The chunk granularity is consistent with 'ARTICLE', and all the upper level text will be included in the chunk.
|
| 34 |
-
</p>`,
|
| 35 |
-
},
|
| 36 |
-
manual: {
|
| 37 |
-
title: '',
|
| 38 |
-
description: `<p>Only <b>PDF</b> is supported.</p><p>
|
| 39 |
-
We assume manual has hierarchical section structure. We use the lowest section titles as pivots to slice documents.
|
| 40 |
-
So, the figures and tables in the same section will not be sliced apart, and chunk size might be large.
|
| 41 |
-
</p>`,
|
| 42 |
-
},
|
| 43 |
-
naive: {
|
| 44 |
-
title: '',
|
| 45 |
-
description: `<p>Supported file formats are <b>DOCX, EXCEL, PPT, IMAGE, PDF, TXT</b>.</p>
|
| 46 |
-
<p>This method apply the naive ways to chunk files: </p>
|
| 47 |
-
<p>
|
| 48 |
-
<li>Successive text will be sliced into pieces using vision detection model.</li>
|
| 49 |
-
<li>Next, these successive pieces are merge into chunks whose token number is no more than 'Token number'.</li></p>`,
|
| 50 |
-
},
|
| 51 |
-
paper: {
|
| 52 |
-
title: '',
|
| 53 |
-
description: `<p>Only <b>PDF</b> file is supported.</p><p>
|
| 54 |
-
If our model works well, the paper will be sliced by it's sections, like <i>abstract, 1.1, 1.2</i>, etc. </p><p>
|
| 55 |
-
The benefit of doing this is that LLM can better summarize the content of relevant sections in the paper,
|
| 56 |
-
resulting in more comprehensive answers that help readers better understand the paper.
|
| 57 |
-
The downside is that it increases the context of the LLM conversation and adds computational cost,
|
| 58 |
-
so during the conversation, you can consider reducing the ‘<b>topN</b>’ setting.</p>`,
|
| 59 |
-
},
|
| 60 |
-
presentation: {
|
| 61 |
-
title: '',
|
| 62 |
-
description: `<p>The supported file formats are <b>PDF</b>, <b>PPTX</b>.</p><p>
|
| 63 |
-
Every page will be treated as a chunk. And the thumbnail of every page will be stored.</p><p>
|
| 64 |
-
<i>All the PPT files you uploaded will be chunked by using this method automatically, setting-up for every PPT file is not necessary.</i></p>`,
|
| 65 |
-
},
|
| 66 |
-
qa: {
|
| 67 |
-
title: '',
|
| 68 |
-
description: `<p><b>EXCEL</b> and <b>CSV/TXT</b> files are supported.</p><p>
|
| 69 |
-
If the file is in excel format, there should be 2 columns question and answer without header.
|
| 70 |
-
And question column is ahead of answer column.
|
| 71 |
-
And it's O.K if it has multiple sheets as long as the columns are rightly composed.</p><p>
|
| 72 |
-
|
| 73 |
-
If it's in csv format, it should be UTF-8 encoded. Use TAB as delimiter to separate question and answer.</p><p>
|
| 74 |
-
|
| 75 |
-
<i>All the deformed lines will be ignored.
|
| 76 |
-
Every pair of Q&A will be treated as a chunk.</i></p>`,
|
| 77 |
-
},
|
| 78 |
-
resume: {
|
| 79 |
-
title: '',
|
| 80 |
-
description: `<p>The supported file formats are <b>DOCX</b>, <b>PDF</b>, <b>TXT</b>.
|
| 81 |
-
</p><p>
|
| 82 |
-
The résumé comes in a variety of formats, just like a person’s personality, but we often have to organize them into structured data that makes it easy to search.
|
| 83 |
-
</p><p>
|
| 84 |
-
Instead of chunking the résumé, we parse the résumé into structured data. As a HR, you can dump all the résumé you have,
|
| 85 |
-
the you can list all the candidates that match the qualifications just by talk with <i>'RAGFlow'</i>.
|
| 86 |
-
</p>
|
| 87 |
-
`,
|
| 88 |
-
},
|
| 89 |
-
table: {
|
| 90 |
-
title: '',
|
| 91 |
-
description: `<p><b>EXCEL</b> and <b>CSV/TXT</b> format files are supported.</p><p>
|
| 92 |
-
Here're some tips:
|
| 93 |
-
<ul>
|
| 94 |
-
<li>For csv or txt file, the delimiter between columns is <em><b>TAB</b></em>.</li>
|
| 95 |
-
<li>The first line must be column headers.</li>
|
| 96 |
-
<li>Column headers must be meaningful terms in order to make our LLM understanding.
|
| 97 |
-
It's good to enumerate some synonyms using slash <i>'/'</i> to separate, and even better to
|
| 98 |
-
enumerate values using brackets like <i>'gender/sex(male, female)'</i>.<p>
|
| 99 |
-
Here are some examples for headers:<ol>
|
| 100 |
-
<li>supplier/vendor<b>'TAB'</b>color(yellow, red, brown)<b>'TAB'</b>gender/sex(male, female)<b>'TAB'</b>size(M,L,XL,XXL)</li>
|
| 101 |
-
<li>姓名/名字<b>'TAB'</b>电话/手机/微信<b>'TAB'</b>最高学历(高中,职高,硕士,本科,博士,初中,中技,中专,专科,专升本,MPA,MBA,EMBA)</li>
|
| 102 |
-
</ol>
|
| 103 |
-
</p>
|
| 104 |
-
</li>
|
| 105 |
-
<li>Every row in table will be treated as a chunk.</li>
|
| 106 |
-
</ul>`,
|
| 107 |
-
},
|
| 108 |
-
picture: {
|
| 109 |
-
title: '',
|
| 110 |
-
description: `
|
| 111 |
-
<p>Image files are supported. Video is coming soon.</p><p>
|
| 112 |
-
If the picture has text in it, OCR is applied to extract the text as its text description.
|
| 113 |
-
</p><p>
|
| 114 |
-
If the text extracted by OCR is not enough, visual LLM is used to get the descriptions.
|
| 115 |
-
</p>`,
|
| 116 |
-
},
|
| 117 |
-
one: {
|
| 118 |
-
title: '',
|
| 119 |
-
description: `
|
| 120 |
-
<p>Supported file formats are <b>DOCX, EXCEL, PDF, TXT</b>.
|
| 121 |
-
</p><p>
|
| 122 |
-
For a document, it will be treated as an entire chunk, no split at all.
|
| 123 |
-
</p><p>
|
| 124 |
-
If you want to summarize something that needs all the context of an article and the selected LLM's context length covers the document length, you can try this method.
|
| 125 |
-
</p>`,
|
| 126 |
-
},
|
| 127 |
-
};
|
|
|
|
| 17 |
one: getImageName('one', 2),
|
| 18 |
knowledge_graph: getImageName('knowledge-graph', 2),
|
| 19 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
web/src/pages/flow/chat/drawer.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { useFetchFlow } from '@/hooks/flow-hooks';
|
| 2 |
import { IModalProps } from '@/interfaces/common';
|
| 3 |
import { Drawer } from 'antd';
|
|
|
|
| 4 |
import FlowChatBox from './box';
|
| 5 |
|
| 6 |
const ChatDrawer = ({ visible, hideModal }: IModalProps<any>) => {
|
|
@@ -13,7 +14,7 @@ const ChatDrawer = ({ visible, hideModal }: IModalProps<any>) => {
|
|
| 13 |
onClose={hideModal}
|
| 14 |
open={visible}
|
| 15 |
getContainer={false}
|
| 16 |
-
width={
|
| 17 |
mask={false}
|
| 18 |
// zIndex={10000}
|
| 19 |
>
|
|
|
|
| 1 |
import { useFetchFlow } from '@/hooks/flow-hooks';
|
| 2 |
import { IModalProps } from '@/interfaces/common';
|
| 3 |
import { Drawer } from 'antd';
|
| 4 |
+
import { getDrawerWidth } from '../utils';
|
| 5 |
import FlowChatBox from './box';
|
| 6 |
|
| 7 |
const ChatDrawer = ({ visible, hideModal }: IModalProps<any>) => {
|
|
|
|
| 14 |
onClose={hideModal}
|
| 15 |
open={visible}
|
| 16 |
getContainer={false}
|
| 17 |
+
width={getDrawerWidth()}
|
| 18 |
mask={false}
|
| 19 |
// zIndex={10000}
|
| 20 |
>
|
web/src/pages/flow/flow-drawer/index.tsx
CHANGED
|
@@ -39,6 +39,7 @@ import OperatorIcon from '../operator-icon';
|
|
| 39 |
|
| 40 |
import { CloseOutlined } from '@ant-design/icons';
|
| 41 |
import { lowerFirst } from 'lodash';
|
|
|
|
| 42 |
import styles from './index.less';
|
| 43 |
|
| 44 |
interface IProps {
|
|
@@ -135,7 +136,7 @@ const FlowDrawer = ({
|
|
| 135 |
open={visible}
|
| 136 |
getContainer={false}
|
| 137 |
mask={false}
|
| 138 |
-
width={
|
| 139 |
closeIcon={null}
|
| 140 |
>
|
| 141 |
<section className={styles.formWrapper}>
|
|
|
|
| 39 |
|
| 40 |
import { CloseOutlined } from '@ant-design/icons';
|
| 41 |
import { lowerFirst } from 'lodash';
|
| 42 |
+
import { getDrawerWidth } from '../utils';
|
| 43 |
import styles from './index.less';
|
| 44 |
|
| 45 |
interface IProps {
|
|
|
|
| 136 |
open={visible}
|
| 137 |
getContainer={false}
|
| 138 |
mask={false}
|
| 139 |
+
width={getDrawerWidth()}
|
| 140 |
closeIcon={null}
|
| 141 |
>
|
| 142 |
<section className={styles.formWrapper}>
|
web/src/pages/flow/form/generate-form/index.tsx
CHANGED
|
@@ -28,7 +28,7 @@ const GenerateForm = ({ onValuesChange, form, node }: IOperatorForm) => {
|
|
| 28 |
</Form.Item>
|
| 29 |
<Form.Item
|
| 30 |
name={['prompt']}
|
| 31 |
-
label=
|
| 32 |
initialValue={t('promptText')}
|
| 33 |
tooltip={t('promptTip', { keyPrefix: 'knowledgeConfiguration' })}
|
| 34 |
rules={[
|
|
|
|
| 28 |
</Form.Item>
|
| 29 |
<Form.Item
|
| 30 |
name={['prompt']}
|
| 31 |
+
label="System"
|
| 32 |
initialValue={t('promptText')}
|
| 33 |
tooltip={t('promptTip', { keyPrefix: 'knowledgeConfiguration' })}
|
| 34 |
rules={[
|
web/src/pages/flow/header/index.tsx
CHANGED
|
@@ -14,9 +14,10 @@ import styles from './index.less';
|
|
| 14 |
|
| 15 |
interface IProps {
|
| 16 |
showChatDrawer(): void;
|
|
|
|
| 17 |
}
|
| 18 |
|
| 19 |
-
const FlowHeader = ({ showChatDrawer }: IProps) => {
|
| 20 |
const { saveGraph } = useSaveGraph();
|
| 21 |
const handleRun = useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer);
|
| 22 |
const { data } = useFetchFlow();
|
|
@@ -28,7 +29,7 @@ const FlowHeader = ({ showChatDrawer }: IProps) => {
|
|
| 28 |
} = useSetModalState();
|
| 29 |
const { visible, hideModal, showModal } = useSetModalState();
|
| 30 |
const { id } = useParams();
|
| 31 |
-
const time = useWatchAgentChange();
|
| 32 |
|
| 33 |
return (
|
| 34 |
<>
|
|
|
|
| 14 |
|
| 15 |
interface IProps {
|
| 16 |
showChatDrawer(): void;
|
| 17 |
+
chatDrawerVisible: boolean;
|
| 18 |
}
|
| 19 |
|
| 20 |
+
const FlowHeader = ({ showChatDrawer, chatDrawerVisible }: IProps) => {
|
| 21 |
const { saveGraph } = useSaveGraph();
|
| 22 |
const handleRun = useSaveGraphBeforeOpeningDebugDrawer(showChatDrawer);
|
| 23 |
const { data } = useFetchFlow();
|
|
|
|
| 29 |
} = useSetModalState();
|
| 30 |
const { visible, hideModal, showModal } = useSetModalState();
|
| 31 |
const { id } = useParams();
|
| 32 |
+
const time = useWatchAgentChange(chatDrawerVisible);
|
| 33 |
|
| 34 |
return (
|
| 35 |
<>
|
web/src/pages/flow/hooks.ts
CHANGED
|
@@ -681,7 +681,7 @@ export const useCopyPaste = () => {
|
|
| 681 |
}, [onPasteCapture]);
|
| 682 |
};
|
| 683 |
|
| 684 |
-
export const useWatchAgentChange = () => {
|
| 685 |
const [time, setTime] = useState<string>();
|
| 686 |
const nodes = useGraphStore((state) => state.nodes);
|
| 687 |
const edges = useGraphStore((state) => state.edges);
|
|
@@ -697,9 +697,11 @@ export const useWatchAgentChange = () => {
|
|
| 697 |
}, [flowDetail, setSaveTime]);
|
| 698 |
|
| 699 |
const saveAgent = useCallback(async () => {
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
|
|
|
|
|
|
| 703 |
|
| 704 |
useDebounceEffect(
|
| 705 |
() => {
|
|
|
|
| 681 |
}, [onPasteCapture]);
|
| 682 |
};
|
| 683 |
|
| 684 |
+
export const useWatchAgentChange = (chatDrawerVisible: boolean) => {
|
| 685 |
const [time, setTime] = useState<string>();
|
| 686 |
const nodes = useGraphStore((state) => state.nodes);
|
| 687 |
const edges = useGraphStore((state) => state.edges);
|
|
|
|
| 697 |
}, [flowDetail, setSaveTime]);
|
| 698 |
|
| 699 |
const saveAgent = useCallback(async () => {
|
| 700 |
+
if (!chatDrawerVisible) {
|
| 701 |
+
const ret = await saveGraph();
|
| 702 |
+
setSaveTime(ret.data.update_time);
|
| 703 |
+
}
|
| 704 |
+
}, [chatDrawerVisible, saveGraph, setSaveTime]);
|
| 705 |
|
| 706 |
useDebounceEffect(
|
| 707 |
() => {
|
web/src/pages/flow/index.tsx
CHANGED
|
@@ -25,7 +25,10 @@ function RagFlow() {
|
|
| 25 |
<ReactFlowProvider>
|
| 26 |
<Sider setCollapsed={setCollapsed} collapsed={collapsed}></Sider>
|
| 27 |
<Layout>
|
| 28 |
-
<FlowHeader
|
|
|
|
|
|
|
|
|
|
| 29 |
<Content style={{ margin: 0 }}>
|
| 30 |
<FlowCanvas
|
| 31 |
chatDrawerVisible={chatDrawerVisible}
|
|
|
|
| 25 |
<ReactFlowProvider>
|
| 26 |
<Sider setCollapsed={setCollapsed} collapsed={collapsed}></Sider>
|
| 27 |
<Layout>
|
| 28 |
+
<FlowHeader
|
| 29 |
+
showChatDrawer={showChatDrawer}
|
| 30 |
+
chatDrawerVisible={chatDrawerVisible}
|
| 31 |
+
></FlowHeader>
|
| 32 |
<Content style={{ margin: 0 }}>
|
| 33 |
<FlowCanvas
|
| 34 |
chatDrawerVisible={chatDrawerVisible}
|
web/src/pages/flow/utils.ts
CHANGED
|
@@ -317,3 +317,7 @@ export const duplicateNodeForm = (nodeData?: NodeData) => {
|
|
| 317 |
form,
|
| 318 |
};
|
| 319 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
form,
|
| 318 |
};
|
| 319 |
};
|
| 320 |
+
|
| 321 |
+
export const getDrawerWidth = () => {
|
| 322 |
+
return window.innerWidth > 1278 ? '40%' : 470;
|
| 323 |
+
};
|