feat: add PubMed operator #918 (#1589)

### What problem does this PR solve?

feat: modify the translation of baiduDescription #918
feat: add PubMed operator #918
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-07-18 15:45:34 +08:00
committed by GitHub
parent 0b94376cd4
commit cf4fff64f8
9 changed files with 76 additions and 8 deletions

View File

@ -1,7 +1,9 @@
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';
import { ReactComponent as PubMedIcon } from '@/assets/svg/pubmed.svg';
import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
import { variableEnabledFieldMap } from '@/constants/chat';
import i18n from '@/locales/config';
@ -35,6 +37,7 @@ export enum Operator {
Baidu = 'Baidu',
DuckDuckGo = 'DuckDuckGo',
Wikipedia = 'Wikipedia',
PubMed = 'PubMed',
}
export const operatorIconMap = {
@ -50,6 +53,7 @@ export const operatorIconMap = {
[Operator.DuckDuckGo]: DuckIcon,
[Operator.Baidu]: BaiduIcon,
[Operator.Wikipedia]: WikipediaIcon,
[Operator.PubMed]: PubMedIcon,
};
export const operatorMap = {
@ -113,6 +117,9 @@ export const operatorMap = {
[Operator.Wikipedia]: {
backgroundColor: '#dee0e2',
},
[Operator.PubMed]: {
backgroundColor: '#a2ccf0',
},
};
export const componentMenuList = [
@ -149,6 +156,9 @@ export const componentMenuList = [
{
name: Operator.Wikipedia,
},
{
name: Operator.PubMed,
},
];
export const initialRetrievalValues = {
@ -221,6 +231,11 @@ export const initialWikipediaValues = {
language: 'en',
};
export const initialPubMedValues = {
top_n: 10,
email: '',
};
export const CategorizeAnchorPointPositions = [
{ top: 1, right: 34 },
{ top: 8, right: 18 },
@ -280,6 +295,7 @@ export const RestrictedUpstreamMap = {
[Operator.Baidu]: [Operator.Begin, Operator.Retrieval],
[Operator.DuckDuckGo]: [Operator.Begin, Operator.Retrieval],
[Operator.Wikipedia]: [Operator.Begin, Operator.Retrieval],
[Operator.PubMed]: [Operator.Begin, Operator.Retrieval],
};
export const NodeMap = {
@ -295,6 +311,7 @@ export const NodeMap = {
[Operator.DuckDuckGo]: 'ragNode',
[Operator.Baidu]: 'ragNode',
[Operator.Wikipedia]: 'ragNode',
[Operator.PubMed]: 'ragNode',
};
export const LanguageOptions = [

View File

@ -14,6 +14,7 @@ import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
import KeywordExtractForm from '../keyword-extract-form';
import MessageForm from '../message-form';
import OperatorIcon from '../operator-icon';
import PubMedForm from '../pubmed-form';
import RelevantForm from '../relevant-form';
import RetrievalForm from '../retrieval-form';
import RewriteQuestionForm from '../rewrite-question-form';
@ -38,6 +39,7 @@ const FormMap = {
[Operator.DuckDuckGo]: DuckDuckGoForm,
[Operator.KeywordExtract]: KeywordExtractForm,
[Operator.Wikipedia]: WikipediaForm,
[Operator.PubMed]: PubMedForm,
};
const EmptyContent = () => <div>empty</div>;

View File

@ -38,6 +38,7 @@ import {
initialGenerateValues,
initialKeywordExtractValues,
initialMessageValues,
initialPubMedValues,
initialRelevantValues,
initialRetrievalValues,
initialRewriteQuestionValues,
@ -90,6 +91,7 @@ export const useInitializeOperatorParams = () => {
[Operator.DuckDuckGo]: initialDuckValues,
[Operator.Baidu]: initialBaiduValues,
[Operator.Wikipedia]: initialWikipediaValues,
[Operator.PubMed]: initialPubMedValues,
};
}, [llmId]);

View File

@ -0,0 +1,31 @@
import TopNItem from '@/components/top-n-item';
import { useTranslate } from '@/hooks/common-hooks';
import { Form, Input } from 'antd';
import { IOperatorForm } from '../interface';
const PubMedForm = ({ onValuesChange, form }: IOperatorForm) => {
const { t } = useTranslate('flow');
return (
<Form
name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off"
form={form}
onValuesChange={onValuesChange}
>
<TopNItem initialValue={10}></TopNItem>
<Form.Item
label={t('email')}
name={'email'}
tooltip={t('emailTip')}
rules={[{ type: 'email' }]}
>
<Input></Input>
</Form.Item>
</Form>
);
};
export default PubMedForm;

View File

@ -77,7 +77,7 @@ const ApiKeyModal = ({
<Input placeholder="https://api.openai.com/v1" />
</Form.Item>
)}
{llmFactory.toLowerCase() === 'Minimax'.toLowerCase() && (
{llmFactory?.toLowerCase() === 'Minimax'.toLowerCase() && (
<Form.Item<FieldType> label={'Group ID'} name="group_id">
<Input />
</Form.Item>