Skip to content

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

feat: add arxiv operator #918 (#1683)

balibabu7e60800c9542
diff --git a/web/src/assets/svg/arxiv.svg b/web/src/assets/svg/arxiv.svg
new file mode 100644
index 0000000000..a30b325e10
--- /dev/null
+++ b/web/src/assets/svg/arxiv.svg
@@ -0,0 +1,18 @@
+<svg t="1721786983645" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4276"
+ width="200" height="200">
+ <path
+ d="M0 750.933333V273.066667a273.066667 273.066667 0 0 1 273.066667-273.066667h477.866666a273.066667 273.066667 0 0 1 273.066667 273.066667v477.866666a273.066667 273.066667 0 0 1-273.066667 273.066667H273.066667a273.066667 273.066667 0 0 1-273.066667-273.066667z"
+ fill="#FFFFFF" p-id="4277"></path>
+ <path
+ d="M0 750.933333V273.066667a273.066667 273.066667 0 0 1 273.066667-273.066667h477.866666a273.066667 273.066667 0 0 1 273.066667 273.066667v477.866666a273.066667 273.066667 0 0 1-273.066667 273.066667H273.066667a273.066667 273.066667 0 0 1-273.066667-273.066667z m34.133333 0q0 98.986667 69.973334 168.96Q174.08 989.866667 273.066667 989.866667h477.866666q98.986667 0 168.96-69.973334Q989.866667 849.92 989.866667 750.933333V273.066667q0-98.986667-69.973334-168.96Q849.92 34.133333 750.933333 34.133333H273.066667Q174.08 34.133333 104.106667 104.106667 34.133333 174.08 34.133333 273.066667v477.866666z"
+ fill="#F0F0F0" p-id="4278"></path>
+ <path
+ d="M433.425067 417.621333l77.346133 93.457067 227.805867-267.605333c12.049067-16.042667 17.749333-24.4736 12.049066-38.126934a41.5744 41.5744 0 0 0-36.215466-25.531733 32.529067 32.529067 0 0 0-24.302934 8.942933l-256.682666 228.864z"
+ fill="#BDB9B4" p-id="4279"></path>
+ <path
+ d="M637.405867 462.301867L275.387733 115.029333a48.2304 48.2304 0 0 0-28.4672-17.066666 37.205333 37.205333 0 0 0-35.054933 22.528c-5.700267 13.653333-1.604267 23.2448 10.888533 41.1648l288.085334 349.5936-214.4256 263.3728c-11.3664 11.741867-15.5648 28.672-11.025067 44.373333 5.905067 14.370133 19.968 23.688533 35.498667 23.552a33.860267 33.860267 0 0 0 25.531733-12.458667l290.781867-270.336c28.910933-26.0096 29.013333-71.338667 0.2048-97.450666z"
+ fill="#B31B1B" p-id="4280"></path>
+ <path
+ d="M801.0752 861.218133l-290.986667-350.72-77.312-93.422933-47.445333 42.8032a70.417067 70.417067 0 0 0 0 101.205333l369.083733 355.669334c6.5536 6.826667 15.872 10.3424 25.326934 9.591466 14.472533-0.238933 27.3408-9.216 32.529066-22.766933a43.008 43.008 0 0 0-11.195733-42.325333z"
+ fill="#BDB9B4" p-id="4281"></path>
+</svg>
\ No newline at end of file
diff --git a/web/src/components/operate-dropdown/index.tsx b/web/src/components/operate-dropdown/index.tsx
index 485fd25eff..40877fc5ad 100644
--- a/web/src/components/operate-dropdown/index.tsx
+++ b/web/src/components/operate-dropdown/index.tsx
@@ -9,6 +9,7 @@ import styles from './index.less';
interface IProps {
deleteItem: () => Promise<any> | void;
iconFontSize?: number;
+ iconFontColor?: string;
items?: MenuProps['items'];
height?: number;
needsDeletionValidation?: boolean;
@@ -18,6 +19,7 @@ const OperateDropdown = ({
deleteItem,
children,
iconFontSize = 30,
+ iconFontColor = 'gray',
items: otherItems = [],
height = 24,
needsDeletionValidation = true,
@@ -69,7 +71,7 @@ const OperateDropdown = ({
rotate={90}
style={{
fontSize: iconFontSize,
- color: 'gray',
+ color: iconFontColor,
cursor: 'pointer',
height,
}}
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index ad2c23e4f2..4227c2ec7e 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -632,6 +632,13 @@ The above is the content you need to summarize.`,
email: 'Email',
emailTip:
'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.',
+ arxiv: 'Arxiv',
+ arxivTip:
+ '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.',
+ sortBy: 'Sort by',
+ submittedDate: 'Submitted date',
+ lastUpdatedDate: 'Last updated date',
+ relevance: 'Relevance',
},
footer: {
profile: 'All rights reserved @ React',
diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts
index d27f63a1ab..c765237d3f 100644
--- a/web/src/locales/zh-traditional.ts
+++ b/web/src/locales/zh-traditional.ts
@@ -592,6 +592,13 @@ export default {
email: '信箱',
emailTip:
'此元件用於從 https://pubmed.ncbi.nlm.nih.gov/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 指定您需要適應的搜尋結果的數量。電子郵件是必填欄位。',
+ arxiv: 'Arxiv',
+ arxivTip:
+ '此元件用於從 https://arxiv.org/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 指定您需要適應的搜尋結果的數量。',
+ sortBy: '排序方式',
+ submittedDate: '提交日期',
+ lastUpdatedDate: '最後更新日期',
+ relevance: '關聯',
},
footer: {
profile: '“保留所有權利 @ react”',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 12ff68d009..9d541423b4 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -610,6 +610,13 @@ export default {
email: '邮箱',
emailTip:
'此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件是必填字段。',
+ arxiv: 'Arxiv',
+ arxivTip:
+ '此组件用于从 https://arxiv.org/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数量。',
+ sortBy: '排序方式',
+ submittedDate: '提交日期',
+ lastUpdatedDate: '最后更新日期',
+ relevance: '关联',
},
footer: {
profile: 'All rights reserved @ React',
diff --git a/web/src/pages/flow/arxiv-form/index.tsx b/web/src/pages/flow/arxiv-form/index.tsx
new file mode 100644
index 0000000000..36be0e2bf4
--- /dev/null
+++ b/web/src/pages/flow/arxiv-form/index.tsx
@@ -0,0 +1,34 @@
+import TopNItem from '@/components/top-n-item';
+import { useTranslate } from '@/hooks/common-hooks';
+import { Form, Select } from 'antd';
+import { useMemo } from 'react';
+import { IOperatorForm } from '../interface';
+
+const ArxivForm = ({ onValuesChange, form }: IOperatorForm) => {
+ const { t } = useTranslate('flow');
+
+ const options = useMemo(() => {
+ return ['submittedDate', 'lastUpdatedDate', 'relevance'].map((x) => ({
+ value: x,
+ label: t(x),
+ }));
+ }, [t]);
+
+ return (
+ <Form
+ name="basic"
+ labelCol={{ span: 6 }}
+ wrapperCol={{ span: 18 }}
+ autoComplete="off"
+ form={form}
+ onValuesChange={onValuesChange}
+ >
+ <TopNItem initialValue={10}></TopNItem>
+ <Form.Item label={t('sortBy')} name={'sort_by'}>
+ <Select options={options}></Select>
+ </Form.Item>
+ </Form>
+ );
+};
+
+export default ArxivForm;
diff --git a/web/src/pages/flow/canvas/node/dropdown.tsx b/web/src/pages/flow/canvas/node/dropdown.tsx
index b3fdce9e1f..f2b77509be 100644
--- a/web/src/pages/flow/canvas/node/dropdown.tsx
+++ b/web/src/pages/flow/canvas/node/dropdown.tsx
@@ -7,9 +7,10 @@ import useGraphStore from '../../store';
interface IProps {
id: string;
+ iconFontColor?: string;
}
-const NodeDropdown = ({ id }: IProps) => {
+const NodeDropdown = ({ id, iconFontColor }: IProps) => {
const { t } = useTranslation();
const deleteNodeById = useGraphStore((store) => store.deleteNodeById);
const duplicateNodeById = useGraphStore((store) => store.duplicateNode);
@@ -42,6 +43,7 @@ const NodeDropdown = ({ id }: IProps) => {
deleteItem={deleteNode}
items={items}
needsDeletionValidation={false}
+ iconFontColor={iconFontColor}
></OperateDropdown>
);
};
diff --git a/web/src/pages/flow/canvas/node/index.tsx b/web/src/pages/flow/canvas/node/index.tsx
index 671f75d199..c9f8aababb 100644
--- a/web/src/pages/flow/canvas/node/index.tsx
+++ b/web/src/pages/flow/canvas/node/index.tsx
@@ -11,7 +11,11 @@ import NodeDropdown from './dropdown';
import styles from './index.less';
import NodePopover from './popover';
-const ZeroGapOperators = [Operator.RewriteQuestion, Operator.KeywordExtract];
+const ZeroGapOperators = [
+ Operator.RewriteQuestion,
+ Operator.KeywordExtract,
+ Operator.Arxiv,
+];
export function RagNode({
id,
@@ -69,8 +73,10 @@ export function RagNode({
</span>
</Flex>
<Flex flex={1}>
- {' '}
- <NodeDropdown id={id}></NodeDropdown>
+ <NodeDropdown
+ id={id}
+ iconFontColor={style?.moreIconColor}
+ ></NodeDropdown>
</Flex>
</Flex>
diff --git a/web/src/pages/flow/constant.tsx b/web/src/pages/flow/constant.tsx
index 6975e20e6a..d3865a1307 100644
--- a/web/src/pages/flow/constant.tsx
+++ b/web/src/pages/flow/constant.tsx
@@ -1,3 +1,4 @@
+import { ReactComponent as ArxivIcon } from '@/assets/svg/arxiv.svg';
import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
import { ReactComponent as DuckIcon } from '@/assets/svg/duck.svg';
import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
@@ -38,6 +39,7 @@ export enum Operator {
DuckDuckGo = 'DuckDuckGo',
Wikipedia = 'Wikipedia',
PubMed = 'PubMed',
+ Arxiv = 'Arxiv',
}
export const operatorIconMap = {
@@ -54,6 +56,7 @@ export const operatorIconMap = {
[Operator.Baidu]: BaiduIcon,
[Operator.Wikipedia]: WikipediaIcon,
[Operator.PubMed]: PubMedIcon,
+ [Operator.Arxiv]: ArxivIcon,
};
export const operatorMap = {
@@ -120,6 +123,16 @@ export const operatorMap = {
[Operator.PubMed]: {
backgroundColor: '#a2ccf0',
},
+ [Operator.Arxiv]: {
+ width: 70,
+ height: 70,
+ fontSize: 12,
+ iconWidth: 16,
+ iconFontSize: 16,
+ moreIconColor: 'white',
+ backgroundColor: '#b31b1b',
+ color: 'white',
+ },
};
export const componentMenuList = [
@@ -159,6 +172,9 @@ export const componentMenuList = [
{
name: Operator.PubMed,
},
+ {
+ name: Operator.Arxiv,
+ },
];
export const initialRetrievalValues = {
@@ -236,6 +252,11 @@ export const initialPubMedValues = {
email: '',
};
+export const initialArxivValues = {
+ top_n: 10,
+ sort_by: 'relevance',
+};
+
export const CategorizeAnchorPointPositions = [
{ top: 1, right: 34 },
{ top: 8, right: 18 },
@@ -296,6 +317,7 @@ export const RestrictedUpstreamMap = {
[Operator.DuckDuckGo]: [Operator.Begin, Operator.Retrieval],
[Operator.Wikipedia]: [Operator.Begin, Operator.Retrieval],
[Operator.PubMed]: [Operator.Begin, Operator.Retrieval],
+ [Operator.Arxiv]: [Operator.Begin, Operator.Retrieval],
};
export const NodeMap = {
@@ -312,6 +334,7 @@ export const NodeMap = {
[Operator.Baidu]: 'ragNode',
[Operator.Wikipedia]: 'ragNode',
[Operator.PubMed]: 'ragNode',
+ [Operator.Arxiv]: 'ragNode',
};
export const LanguageOptions = [
diff --git a/web/src/pages/flow/flow-drawer/index.tsx b/web/src/pages/flow/flow-drawer/index.tsx
index 093111f725..2031ad9bab 100644
--- a/web/src/pages/flow/flow-drawer/index.tsx
+++ b/web/src/pages/flow/flow-drawer/index.tsx
@@ -4,6 +4,7 @@ import { Drawer, Flex, Form, Input } from 'antd';
import { useEffect } from 'react';
import { Node } from 'reactflow';
import AnswerForm from '../answer-form';
+import ArxivForm from '../arxiv-form';
import BaiduForm from '../baidu-form';
import BeginForm from '../begin-form';
import CategorizeForm from '../categorize-form';
@@ -40,6 +41,7 @@ const FormMap = {
[Operator.KeywordExtract]: KeywordExtractForm,
[Operator.Wikipedia]: WikipediaForm,
[Operator.PubMed]: PubMedForm,
+ [Operator.Arxiv]: ArxivForm,
};
const EmptyContent = () => <div>empty</div>;
diff --git a/web/src/pages/flow/hooks.ts b/web/src/pages/flow/hooks.ts
index f8ba104706..a6121266be 100644
--- a/web/src/pages/flow/hooks.ts
+++ b/web/src/pages/flow/hooks.ts
@@ -31,6 +31,7 @@ import {
NodeMap,
Operator,
RestrictedUpstreamMap,
+ initialArxivValues,
initialBaiduValues,
initialBeginValues,
initialCategorizeValues,
@@ -92,6 +93,7 @@ export const useInitializeOperatorParams = () => {
[Operator.Baidu]: initialBaiduValues,
[Operator.Wikipedia]: initialWikipediaValues,
[Operator.PubMed]: initialPubMedValues,
+ [Operator.Arxiv]: initialArxivValues,
};
}, [llmId]);
diff --git a/web/src/pages/force-graph.tsx b/web/src/pages/force-graph.tsx
new file mode 100644
index 0000000000..e69de29bb2