### What problem does this PR solve? feat: add arxiv operator #918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
34
web/src/pages/flow/arxiv-form/index.tsx
Normal file
34
web/src/pages/flow/arxiv-form/index.tsx
Normal file
@@ -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;
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user