balibabu
commited on
Commit
·
942993f
1
Parent(s):
88e14ed
feat: add arxiv operator #918 (#1683)
Browse files### What problem does this PR solve?
feat: add arxiv operator #918
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/assets/svg/arxiv.svg +18 -0
- web/src/components/operate-dropdown/index.tsx +3 -1
- web/src/locales/en.ts +7 -0
- web/src/locales/zh-traditional.ts +7 -0
- web/src/locales/zh.ts +7 -0
- web/src/pages/flow/arxiv-form/index.tsx +34 -0
- web/src/pages/flow/canvas/node/dropdown.tsx +3 -1
- web/src/pages/flow/canvas/node/index.tsx +9 -3
- web/src/pages/flow/constant.tsx +23 -0
- web/src/pages/flow/flow-drawer/index.tsx +2 -0
- web/src/pages/flow/hooks.ts +2 -0
- web/src/pages/force-graph.tsx +0 -0
web/src/assets/svg/arxiv.svg
ADDED
|
web/src/components/operate-dropdown/index.tsx
CHANGED
@@ -9,6 +9,7 @@ import styles from './index.less';
|
|
9 |
interface IProps {
|
10 |
deleteItem: () => Promise<any> | void;
|
11 |
iconFontSize?: number;
|
|
|
12 |
items?: MenuProps['items'];
|
13 |
height?: number;
|
14 |
needsDeletionValidation?: boolean;
|
@@ -18,6 +19,7 @@ const OperateDropdown = ({
|
|
18 |
deleteItem,
|
19 |
children,
|
20 |
iconFontSize = 30,
|
|
|
21 |
items: otherItems = [],
|
22 |
height = 24,
|
23 |
needsDeletionValidation = true,
|
@@ -69,7 +71,7 @@ const OperateDropdown = ({
|
|
69 |
rotate={90}
|
70 |
style={{
|
71 |
fontSize: iconFontSize,
|
72 |
-
color:
|
73 |
cursor: 'pointer',
|
74 |
height,
|
75 |
}}
|
|
|
9 |
interface IProps {
|
10 |
deleteItem: () => Promise<any> | void;
|
11 |
iconFontSize?: number;
|
12 |
+
iconFontColor?: string;
|
13 |
items?: MenuProps['items'];
|
14 |
height?: number;
|
15 |
needsDeletionValidation?: boolean;
|
|
|
19 |
deleteItem,
|
20 |
children,
|
21 |
iconFontSize = 30,
|
22 |
+
iconFontColor = 'gray',
|
23 |
items: otherItems = [],
|
24 |
height = 24,
|
25 |
needsDeletionValidation = true,
|
|
|
71 |
rotate={90}
|
72 |
style={{
|
73 |
fontSize: iconFontSize,
|
74 |
+
color: iconFontColor,
|
75 |
cursor: 'pointer',
|
76 |
height,
|
77 |
}}
|
web/src/locales/en.ts
CHANGED
@@ -632,6 +632,13 @@ The above is the content you need to summarize.`,
|
|
632 |
email: 'Email',
|
633 |
emailTip:
|
634 |
'This component is used to get search result from https://pubmed.ncbi.nlm.nih.gov/. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adapt. E-mail is a required field.',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
635 |
},
|
636 |
footer: {
|
637 |
profile: 'All rights reserved @ React',
|
|
|
632 |
email: 'Email',
|
633 |
emailTip:
|
634 |
'This component is used to get search result from https://pubmed.ncbi.nlm.nih.gov/. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adapt. E-mail is a required field.',
|
635 |
+
arxiv: 'Arxiv',
|
636 |
+
arxivTip:
|
637 |
+
'This component is used to get search result from https://arxiv.org/. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adapt.',
|
638 |
+
sortBy: 'Sort by',
|
639 |
+
submittedDate: 'Submitted date',
|
640 |
+
lastUpdatedDate: 'Last updated date',
|
641 |
+
relevance: 'Relevance',
|
642 |
},
|
643 |
footer: {
|
644 |
profile: 'All rights reserved @ React',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -592,6 +592,13 @@ export default {
|
|
592 |
email: '信箱',
|
593 |
emailTip:
|
594 |
'此元件用於從 https://pubmed.ncbi.nlm.nih.gov/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 指定您需要適應的搜尋結果的數量。電子郵件是必填欄位。',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
},
|
596 |
footer: {
|
597 |
profile: '“保留所有權利 @ react”',
|
|
|
592 |
email: '信箱',
|
593 |
emailTip:
|
594 |
'此元件用於從 https://pubmed.ncbi.nlm.nih.gov/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 指定您需要適應的搜尋結果的數量。電子郵件是必填欄位。',
|
595 |
+
arxiv: 'Arxiv',
|
596 |
+
arxivTip:
|
597 |
+
'此元件用於從 https://arxiv.org/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 指定您需要適應的搜尋結果的數量。',
|
598 |
+
sortBy: '排序方式',
|
599 |
+
submittedDate: '提交日期',
|
600 |
+
lastUpdatedDate: '最後更新日期',
|
601 |
+
relevance: '關聯',
|
602 |
},
|
603 |
footer: {
|
604 |
profile: '“保留所有權利 @ react”',
|
web/src/locales/zh.ts
CHANGED
@@ -610,6 +610,13 @@ export default {
|
|
610 |
email: '邮箱',
|
611 |
emailTip:
|
612 |
'此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件是必填字段。',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
613 |
},
|
614 |
footer: {
|
615 |
profile: 'All rights reserved @ React',
|
|
|
610 |
email: '邮箱',
|
611 |
emailTip:
|
612 |
'此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件是必填字段。',
|
613 |
+
arxiv: 'Arxiv',
|
614 |
+
arxivTip:
|
615 |
+
'此组件用于从 https://arxiv.org/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数量。',
|
616 |
+
sortBy: '排序方式',
|
617 |
+
submittedDate: '提交日期',
|
618 |
+
lastUpdatedDate: '最后更新日期',
|
619 |
+
relevance: '关联',
|
620 |
},
|
621 |
footer: {
|
622 |
profile: 'All rights reserved @ React',
|
web/src/pages/flow/arxiv-form/index.tsx
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import TopNItem from '@/components/top-n-item';
|
2 |
+
import { useTranslate } from '@/hooks/common-hooks';
|
3 |
+
import { Form, Select } from 'antd';
|
4 |
+
import { useMemo } from 'react';
|
5 |
+
import { IOperatorForm } from '../interface';
|
6 |
+
|
7 |
+
const ArxivForm = ({ onValuesChange, form }: IOperatorForm) => {
|
8 |
+
const { t } = useTranslate('flow');
|
9 |
+
|
10 |
+
const options = useMemo(() => {
|
11 |
+
return ['submittedDate', 'lastUpdatedDate', 'relevance'].map((x) => ({
|
12 |
+
value: x,
|
13 |
+
label: t(x),
|
14 |
+
}));
|
15 |
+
}, [t]);
|
16 |
+
|
17 |
+
return (
|
18 |
+
<Form
|
19 |
+
name="basic"
|
20 |
+
labelCol={{ span: 6 }}
|
21 |
+
wrapperCol={{ span: 18 }}
|
22 |
+
autoComplete="off"
|
23 |
+
form={form}
|
24 |
+
onValuesChange={onValuesChange}
|
25 |
+
>
|
26 |
+
<TopNItem initialValue={10}></TopNItem>
|
27 |
+
<Form.Item label={t('sortBy')} name={'sort_by'}>
|
28 |
+
<Select options={options}></Select>
|
29 |
+
</Form.Item>
|
30 |
+
</Form>
|
31 |
+
);
|
32 |
+
};
|
33 |
+
|
34 |
+
export default ArxivForm;
|
web/src/pages/flow/canvas/node/dropdown.tsx
CHANGED
@@ -7,9 +7,10 @@ import useGraphStore from '../../store';
|
|
7 |
|
8 |
interface IProps {
|
9 |
id: string;
|
|
|
10 |
}
|
11 |
|
12 |
-
const NodeDropdown = ({ id }: IProps) => {
|
13 |
const { t } = useTranslation();
|
14 |
const deleteNodeById = useGraphStore((store) => store.deleteNodeById);
|
15 |
const duplicateNodeById = useGraphStore((store) => store.duplicateNode);
|
@@ -42,6 +43,7 @@ const NodeDropdown = ({ id }: IProps) => {
|
|
42 |
deleteItem={deleteNode}
|
43 |
items={items}
|
44 |
needsDeletionValidation={false}
|
|
|
45 |
></OperateDropdown>
|
46 |
);
|
47 |
};
|
|
|
7 |
|
8 |
interface IProps {
|
9 |
id: string;
|
10 |
+
iconFontColor?: string;
|
11 |
}
|
12 |
|
13 |
+
const NodeDropdown = ({ id, iconFontColor }: IProps) => {
|
14 |
const { t } = useTranslation();
|
15 |
const deleteNodeById = useGraphStore((store) => store.deleteNodeById);
|
16 |
const duplicateNodeById = useGraphStore((store) => store.duplicateNode);
|
|
|
43 |
deleteItem={deleteNode}
|
44 |
items={items}
|
45 |
needsDeletionValidation={false}
|
46 |
+
iconFontColor={iconFontColor}
|
47 |
></OperateDropdown>
|
48 |
);
|
49 |
};
|
web/src/pages/flow/canvas/node/index.tsx
CHANGED
@@ -11,7 +11,11 @@ import NodeDropdown from './dropdown';
|
|
11 |
import styles from './index.less';
|
12 |
import NodePopover from './popover';
|
13 |
|
14 |
-
const ZeroGapOperators = [
|
|
|
|
|
|
|
|
|
15 |
|
16 |
export function RagNode({
|
17 |
id,
|
@@ -69,8 +73,10 @@ export function RagNode({
|
|
69 |
</span>
|
70 |
</Flex>
|
71 |
<Flex flex={1}>
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
</Flex>
|
75 |
</Flex>
|
76 |
|
|
|
11 |
import styles from './index.less';
|
12 |
import NodePopover from './popover';
|
13 |
|
14 |
+
const ZeroGapOperators = [
|
15 |
+
Operator.RewriteQuestion,
|
16 |
+
Operator.KeywordExtract,
|
17 |
+
Operator.Arxiv,
|
18 |
+
];
|
19 |
|
20 |
export function RagNode({
|
21 |
id,
|
|
|
73 |
</span>
|
74 |
</Flex>
|
75 |
<Flex flex={1}>
|
76 |
+
<NodeDropdown
|
77 |
+
id={id}
|
78 |
+
iconFontColor={style?.moreIconColor}
|
79 |
+
></NodeDropdown>
|
80 |
</Flex>
|
81 |
</Flex>
|
82 |
|
web/src/pages/flow/constant.tsx
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
|
2 |
import { ReactComponent as DuckIcon } from '@/assets/svg/duck.svg';
|
3 |
import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
|
@@ -38,6 +39,7 @@ export enum Operator {
|
|
38 |
DuckDuckGo = 'DuckDuckGo',
|
39 |
Wikipedia = 'Wikipedia',
|
40 |
PubMed = 'PubMed',
|
|
|
41 |
}
|
42 |
|
43 |
export const operatorIconMap = {
|
@@ -54,6 +56,7 @@ export const operatorIconMap = {
|
|
54 |
[Operator.Baidu]: BaiduIcon,
|
55 |
[Operator.Wikipedia]: WikipediaIcon,
|
56 |
[Operator.PubMed]: PubMedIcon,
|
|
|
57 |
};
|
58 |
|
59 |
export const operatorMap = {
|
@@ -120,6 +123,16 @@ export const operatorMap = {
|
|
120 |
[Operator.PubMed]: {
|
121 |
backgroundColor: '#a2ccf0',
|
122 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
};
|
124 |
|
125 |
export const componentMenuList = [
|
@@ -159,6 +172,9 @@ export const componentMenuList = [
|
|
159 |
{
|
160 |
name: Operator.PubMed,
|
161 |
},
|
|
|
|
|
|
|
162 |
];
|
163 |
|
164 |
export const initialRetrievalValues = {
|
@@ -236,6 +252,11 @@ export const initialPubMedValues = {
|
|
236 |
email: '',
|
237 |
};
|
238 |
|
|
|
|
|
|
|
|
|
|
|
239 |
export const CategorizeAnchorPointPositions = [
|
240 |
{ top: 1, right: 34 },
|
241 |
{ top: 8, right: 18 },
|
@@ -296,6 +317,7 @@ export const RestrictedUpstreamMap = {
|
|
296 |
[Operator.DuckDuckGo]: [Operator.Begin, Operator.Retrieval],
|
297 |
[Operator.Wikipedia]: [Operator.Begin, Operator.Retrieval],
|
298 |
[Operator.PubMed]: [Operator.Begin, Operator.Retrieval],
|
|
|
299 |
};
|
300 |
|
301 |
export const NodeMap = {
|
@@ -312,6 +334,7 @@ export const NodeMap = {
|
|
312 |
[Operator.Baidu]: 'ragNode',
|
313 |
[Operator.Wikipedia]: 'ragNode',
|
314 |
[Operator.PubMed]: 'ragNode',
|
|
|
315 |
};
|
316 |
|
317 |
export const LanguageOptions = [
|
|
|
1 |
+
import { ReactComponent as ArxivIcon } from '@/assets/svg/arxiv.svg';
|
2 |
import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
|
3 |
import { ReactComponent as DuckIcon } from '@/assets/svg/duck.svg';
|
4 |
import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
|
|
|
39 |
DuckDuckGo = 'DuckDuckGo',
|
40 |
Wikipedia = 'Wikipedia',
|
41 |
PubMed = 'PubMed',
|
42 |
+
Arxiv = 'Arxiv',
|
43 |
}
|
44 |
|
45 |
export const operatorIconMap = {
|
|
|
56 |
[Operator.Baidu]: BaiduIcon,
|
57 |
[Operator.Wikipedia]: WikipediaIcon,
|
58 |
[Operator.PubMed]: PubMedIcon,
|
59 |
+
[Operator.Arxiv]: ArxivIcon,
|
60 |
};
|
61 |
|
62 |
export const operatorMap = {
|
|
|
123 |
[Operator.PubMed]: {
|
124 |
backgroundColor: '#a2ccf0',
|
125 |
},
|
126 |
+
[Operator.Arxiv]: {
|
127 |
+
width: 70,
|
128 |
+
height: 70,
|
129 |
+
fontSize: 12,
|
130 |
+
iconWidth: 16,
|
131 |
+
iconFontSize: 16,
|
132 |
+
moreIconColor: 'white',
|
133 |
+
backgroundColor: '#b31b1b',
|
134 |
+
color: 'white',
|
135 |
+
},
|
136 |
};
|
137 |
|
138 |
export const componentMenuList = [
|
|
|
172 |
{
|
173 |
name: Operator.PubMed,
|
174 |
},
|
175 |
+
{
|
176 |
+
name: Operator.Arxiv,
|
177 |
+
},
|
178 |
];
|
179 |
|
180 |
export const initialRetrievalValues = {
|
|
|
252 |
email: '',
|
253 |
};
|
254 |
|
255 |
+
export const initialArxivValues = {
|
256 |
+
top_n: 10,
|
257 |
+
sort_by: 'relevance',
|
258 |
+
};
|
259 |
+
|
260 |
export const CategorizeAnchorPointPositions = [
|
261 |
{ top: 1, right: 34 },
|
262 |
{ top: 8, right: 18 },
|
|
|
317 |
[Operator.DuckDuckGo]: [Operator.Begin, Operator.Retrieval],
|
318 |
[Operator.Wikipedia]: [Operator.Begin, Operator.Retrieval],
|
319 |
[Operator.PubMed]: [Operator.Begin, Operator.Retrieval],
|
320 |
+
[Operator.Arxiv]: [Operator.Begin, Operator.Retrieval],
|
321 |
};
|
322 |
|
323 |
export const NodeMap = {
|
|
|
334 |
[Operator.Baidu]: 'ragNode',
|
335 |
[Operator.Wikipedia]: 'ragNode',
|
336 |
[Operator.PubMed]: 'ragNode',
|
337 |
+
[Operator.Arxiv]: 'ragNode',
|
338 |
};
|
339 |
|
340 |
export const LanguageOptions = [
|
web/src/pages/flow/flow-drawer/index.tsx
CHANGED
@@ -4,6 +4,7 @@ import { Drawer, Flex, Form, Input } from 'antd';
|
|
4 |
import { useEffect } from 'react';
|
5 |
import { Node } from 'reactflow';
|
6 |
import AnswerForm from '../answer-form';
|
|
|
7 |
import BaiduForm from '../baidu-form';
|
8 |
import BeginForm from '../begin-form';
|
9 |
import CategorizeForm from '../categorize-form';
|
@@ -40,6 +41,7 @@ const FormMap = {
|
|
40 |
[Operator.KeywordExtract]: KeywordExtractForm,
|
41 |
[Operator.Wikipedia]: WikipediaForm,
|
42 |
[Operator.PubMed]: PubMedForm,
|
|
|
43 |
};
|
44 |
|
45 |
const EmptyContent = () => <div>empty</div>;
|
|
|
4 |
import { useEffect } from 'react';
|
5 |
import { Node } from 'reactflow';
|
6 |
import AnswerForm from '../answer-form';
|
7 |
+
import ArxivForm from '../arxiv-form';
|
8 |
import BaiduForm from '../baidu-form';
|
9 |
import BeginForm from '../begin-form';
|
10 |
import CategorizeForm from '../categorize-form';
|
|
|
41 |
[Operator.KeywordExtract]: KeywordExtractForm,
|
42 |
[Operator.Wikipedia]: WikipediaForm,
|
43 |
[Operator.PubMed]: PubMedForm,
|
44 |
+
[Operator.Arxiv]: ArxivForm,
|
45 |
};
|
46 |
|
47 |
const EmptyContent = () => <div>empty</div>;
|
web/src/pages/flow/hooks.ts
CHANGED
@@ -31,6 +31,7 @@ import {
|
|
31 |
NodeMap,
|
32 |
Operator,
|
33 |
RestrictedUpstreamMap,
|
|
|
34 |
initialBaiduValues,
|
35 |
initialBeginValues,
|
36 |
initialCategorizeValues,
|
@@ -92,6 +93,7 @@ export const useInitializeOperatorParams = () => {
|
|
92 |
[Operator.Baidu]: initialBaiduValues,
|
93 |
[Operator.Wikipedia]: initialWikipediaValues,
|
94 |
[Operator.PubMed]: initialPubMedValues,
|
|
|
95 |
};
|
96 |
}, [llmId]);
|
97 |
|
|
|
31 |
NodeMap,
|
32 |
Operator,
|
33 |
RestrictedUpstreamMap,
|
34 |
+
initialArxivValues,
|
35 |
initialBaiduValues,
|
36 |
initialBeginValues,
|
37 |
initialCategorizeValues,
|
|
|
93 |
[Operator.Baidu]: initialBaiduValues,
|
94 |
[Operator.Wikipedia]: initialWikipediaValues,
|
95 |
[Operator.PubMed]: initialPubMedValues,
|
96 |
+
[Operator.Arxiv]: initialArxivValues,
|
97 |
};
|
98 |
}, [llmId]);
|
99 |
|
web/src/pages/force-graph.tsx
ADDED
File without changes
|