balibabu commited on
Commit
77dbe3e
·
1 Parent(s): 8fcd0f0

feat: add PubMed operator #918 (#1589)

Browse files

### 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)

web/src/assets/svg/pubmed.svg ADDED
web/src/locales/en.ts CHANGED
@@ -579,7 +579,7 @@ The above is the content you need to summarize.`,
579
  messageDescription:
580
  'This component is used to send user static information. You can prepare several messages which will be chosen randomly.',
581
  keywordDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
582
- wikipediaDescription: `This component is used to get search result from https://www.wikipedia.org/. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adopt.`,
583
  promptText: `Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:
584
  {input}
585
  The above is the content you need to summarize.`,
@@ -602,10 +602,10 @@ The above is the content you need to summarize.`,
602
  keywordExtract: 'Keyword',
603
  keywordExtractDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
604
  baidu: 'Baidu',
605
- baiduDescription: `This component is used to get search result from www.baidu.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adopt.`,
606
  duckDuckGo: 'DuckDuckGo',
607
  duckDuckGoDescription:
608
- 'This component is used to get search result from www.duckduckgo.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adopt.',
609
  channel: 'Channel',
610
  channelTip: `Perform text search or news search on the component's input`,
611
  text: 'Text',
@@ -614,6 +614,10 @@ The above is the content you need to summarize.`,
614
  messageHistoryWindowSizeTip:
615
  'The window size of conversation history that needed to be seen by LLM. The larger the better. But be careful with the maximum content length of LLM.',
616
  wikipedia: 'Wikipedia',
 
 
 
 
617
  },
618
  footer: {
619
  profile: 'All rights reserved @ React',
 
579
  messageDescription:
580
  'This component is used to send user static information. You can prepare several messages which will be chosen randomly.',
581
  keywordDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
582
+ wikipediaDescription: `This component is used to get search result from https://www.wikipedia.org/. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adapt.`,
583
  promptText: `Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:
584
  {input}
585
  The above is the content you need to summarize.`,
 
602
  keywordExtract: 'Keyword',
603
  keywordExtractDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
604
  baidu: 'Baidu',
605
+ baiduDescription: `This component is used to get search result from www.baidu.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adapt.`,
606
  duckDuckGo: 'DuckDuckGo',
607
  duckDuckGoDescription:
608
+ 'This component is used to get search result from www.duckduckgo.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adapt.',
609
  channel: 'Channel',
610
  channelTip: `Perform text search or news search on the component's input`,
611
  text: 'Text',
 
614
  messageHistoryWindowSizeTip:
615
  'The window size of conversation history that needed to be seen by LLM. The larger the better. But be careful with the maximum content length of LLM.',
616
  wikipedia: 'Wikipedia',
617
+ pubMed: 'PubMed',
618
+ email: 'Email',
619
+ emailTip:
620
+ '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.',
621
  },
622
  footer: {
623
  profile: 'All rights reserved @ React',
web/src/locales/zh-traditional.ts CHANGED
@@ -541,7 +541,7 @@ export default {
541
  messageDescription:
542
  '此元件用於向使用者發送靜態訊息。您可以準備幾條訊息,這些訊息將隨機選擇。',
543
  keywordDescription: `該組件用於從用戶的問題中提取關鍵字。 Top N指定需要提取的關鍵字數量。`,
544
- wikipediaDescription: `此元件用於從 https://www.wikipedia.org/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 指定您需要採用的搜尋結果的數量。`,
545
  promptText: `請總結以下段落。注意數字,不要胡編亂造。段落如下:
546
  {input}
547
  以上就是你需要總結的內容。`,
@@ -575,6 +575,9 @@ export default {
575
  messageHistoryWindowSizeTip:
576
  'LLM需要查看的對話記錄的視窗大小。越大越好。但要注意LLM的最大內容長度。',
577
  wikipedia: '維基百科',
 
 
 
578
  },
579
  footer: {
580
  profile: '“保留所有權利 @ react”',
 
541
  messageDescription:
542
  '此元件用於向使用者發送靜態訊息。您可以準備幾條訊息,這些訊息將隨機選擇。',
543
  keywordDescription: `該組件用於從用戶的問題中提取關鍵字。 Top N指定需要提取的關鍵字數量。`,
544
+ wikipediaDescription: `此元件用於從 https://www.wikipedia.org/ 取得搜尋結果。通常,它作為知識庫的補充。 Top N 指定您需要調整的搜尋結果數。`,
545
  promptText: `請總結以下段落。注意數字,不要胡編亂造。段落如下:
546
  {input}
547
  以上就是你需要總結的內容。`,
 
575
  messageHistoryWindowSizeTip:
576
  'LLM需要查看的對話記錄的視窗大小。越大越好。但要注意LLM的最大內容長度。',
577
  wikipedia: '維基百科',
578
+ email: '信箱',
579
+ emailTip:
580
+ '此元件用於從 https://pubmed.ncbi.nlm.nih.gov/ 取得搜尋結果。通常,它充當知識庫的補充。 Top N 指定您需要適應的搜尋結果的數量。電子郵件是必填欄位。',
581
  },
582
  footer: {
583
  profile: '“保留所有權利 @ react”',
web/src/locales/zh.ts CHANGED
@@ -559,7 +559,7 @@ export default {
559
  messageDescription:
560
  '此组件用于向用户发送静态信息。您可以准备几条消息,这些消息将被随机选择。',
561
  keywordDescription: `该组件用于从用户的问题中提取关键词。Top N指定需要提取的关键词数量。`,
562
- wikipediaDescription: `此组件用于从 https://www.wikipedia.org/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要采用的搜索结果数量。`,
563
  promptText: `请总结以下段落。注意数字,不要胡编乱造。段落如下:
564
  {input}
565
  以上就是你需要总结的内容。`,
@@ -581,10 +581,10 @@ export default {
581
  keywordExtract: '关键词',
582
  keywordExtractDescription: `该组件用于从用户的问题中提取关键词。Top N指定需要提取的关键词数量。`,
583
  baidu: '百度',
584
- baiduDescription: `该组件用于获取www.baidu.com的搜索结果,一般作为知识库的补充,Top N指定需要采纳的搜索结果数量。`,
585
  duckDuckGo: 'DuckDuckGo',
586
  duckDuckGoDescription:
587
- '此组件用于从 www.duckduckgo.com 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要采用的搜索结果数量。',
588
  channel: '频道',
589
  channelTip: '针对该组件的输入进行文本搜索或新闻搜索',
590
  text: '文本',
@@ -593,6 +593,9 @@ export default {
593
  messageHistoryWindowSizeTip:
594
  'LLM 需要查看的对话历史窗口大小。越大越好。但要注意 LLM 的最大内容长度。',
595
  wikipedia: '维基百科',
 
 
 
596
  },
597
  footer: {
598
  profile: 'All rights reserved @ React',
 
559
  messageDescription:
560
  '此组件用于向用户发送静态信息。您可以准备几条消息,这些消息将被随机选择。',
561
  keywordDescription: `该组件用于从用户的问题中提取关键词。Top N指定需要提取的关键词数量。`,
562
+ wikipediaDescription: `此组件用于从 https://www.wikipedia.org/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数量。`,
563
  promptText: `请总结以下段落。注意数字,不要胡编乱造。段落如下:
564
  {input}
565
  以上就是你需要总结的内容。`,
 
581
  keywordExtract: '关键词',
582
  keywordExtractDescription: `该组件用于从用户的问题中提取关键词。Top N指定需要提取的关键词数量。`,
583
  baidu: '百度',
584
+ baiduDescription: `此元件用於取得www.baidu.com的搜尋結果。通常作為知識庫的補充。 Top N指定您需要適配的搜尋結果數。`,
585
  duckDuckGo: 'DuckDuckGo',
586
  duckDuckGoDescription:
587
+ '此元件用於從 www.duckduckgo.com 取得搜尋結果。通常,它作為知識庫的補充。 Top N 指定您需要調整的搜尋結果數。',
588
  channel: '频道',
589
  channelTip: '针对该组件的输入进行文本搜索或新闻搜索',
590
  text: '文本',
 
593
  messageHistoryWindowSizeTip:
594
  'LLM 需要查看的对话历史窗口大小。越大越好。但要注意 LLM 的最大内容长度。',
595
  wikipedia: '维基百科',
596
+ email: '邮箱',
597
+ emailTip:
598
+ '此组件用于从 https://pubmed.ncbi.nlm.nih.gov/ 获取搜索结果。通常,它作为知识库的补充。Top N 指定您需要调整的搜索结果数。电子邮件是必填字段。',
599
  },
600
  footer: {
601
  profile: 'All rights reserved @ React',
web/src/pages/flow/constant.tsx CHANGED
@@ -1,7 +1,9 @@
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';
 
4
  import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
 
5
  import { variableEnabledFieldMap } from '@/constants/chat';
6
  import i18n from '@/locales/config';
7
 
@@ -35,6 +37,7 @@ export enum Operator {
35
  Baidu = 'Baidu',
36
  DuckDuckGo = 'DuckDuckGo',
37
  Wikipedia = 'Wikipedia',
 
38
  }
39
 
40
  export const operatorIconMap = {
@@ -50,6 +53,7 @@ export const operatorIconMap = {
50
  [Operator.DuckDuckGo]: DuckIcon,
51
  [Operator.Baidu]: BaiduIcon,
52
  [Operator.Wikipedia]: WikipediaIcon,
 
53
  };
54
 
55
  export const operatorMap = {
@@ -113,6 +117,9 @@ export const operatorMap = {
113
  [Operator.Wikipedia]: {
114
  backgroundColor: '#dee0e2',
115
  },
 
 
 
116
  };
117
 
118
  export const componentMenuList = [
@@ -149,6 +156,9 @@ export const componentMenuList = [
149
  {
150
  name: Operator.Wikipedia,
151
  },
 
 
 
152
  ];
153
 
154
  export const initialRetrievalValues = {
@@ -221,6 +231,11 @@ export const initialWikipediaValues = {
221
  language: 'en',
222
  };
223
 
 
 
 
 
 
224
  export const CategorizeAnchorPointPositions = [
225
  { top: 1, right: 34 },
226
  { top: 8, right: 18 },
@@ -280,6 +295,7 @@ export const RestrictedUpstreamMap = {
280
  [Operator.Baidu]: [Operator.Begin, Operator.Retrieval],
281
  [Operator.DuckDuckGo]: [Operator.Begin, Operator.Retrieval],
282
  [Operator.Wikipedia]: [Operator.Begin, Operator.Retrieval],
 
283
  };
284
 
285
  export const NodeMap = {
@@ -295,6 +311,7 @@ export const NodeMap = {
295
  [Operator.DuckDuckGo]: 'ragNode',
296
  [Operator.Baidu]: 'ragNode',
297
  [Operator.Wikipedia]: 'ragNode',
 
298
  };
299
 
300
  export const LanguageOptions = [
 
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';
4
+ import { ReactComponent as PubMedIcon } from '@/assets/svg/pubmed.svg';
5
  import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
6
+
7
  import { variableEnabledFieldMap } from '@/constants/chat';
8
  import i18n from '@/locales/config';
9
 
 
37
  Baidu = 'Baidu',
38
  DuckDuckGo = 'DuckDuckGo',
39
  Wikipedia = 'Wikipedia',
40
+ PubMed = 'PubMed',
41
  }
42
 
43
  export const operatorIconMap = {
 
53
  [Operator.DuckDuckGo]: DuckIcon,
54
  [Operator.Baidu]: BaiduIcon,
55
  [Operator.Wikipedia]: WikipediaIcon,
56
+ [Operator.PubMed]: PubMedIcon,
57
  };
58
 
59
  export const operatorMap = {
 
117
  [Operator.Wikipedia]: {
118
  backgroundColor: '#dee0e2',
119
  },
120
+ [Operator.PubMed]: {
121
+ backgroundColor: '#a2ccf0',
122
+ },
123
  };
124
 
125
  export const componentMenuList = [
 
156
  {
157
  name: Operator.Wikipedia,
158
  },
159
+ {
160
+ name: Operator.PubMed,
161
+ },
162
  ];
163
 
164
  export const initialRetrievalValues = {
 
231
  language: 'en',
232
  };
233
 
234
+ export const initialPubMedValues = {
235
+ top_n: 10,
236
+ email: '',
237
+ };
238
+
239
  export const CategorizeAnchorPointPositions = [
240
  { top: 1, right: 34 },
241
  { top: 8, right: 18 },
 
295
  [Operator.Baidu]: [Operator.Begin, Operator.Retrieval],
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 = {
 
311
  [Operator.DuckDuckGo]: 'ragNode',
312
  [Operator.Baidu]: 'ragNode',
313
  [Operator.Wikipedia]: 'ragNode',
314
+ [Operator.PubMed]: 'ragNode',
315
  };
316
 
317
  export const LanguageOptions = [
web/src/pages/flow/flow-drawer/index.tsx CHANGED
@@ -14,6 +14,7 @@ import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
14
  import KeywordExtractForm from '../keyword-extract-form';
15
  import MessageForm from '../message-form';
16
  import OperatorIcon from '../operator-icon';
 
17
  import RelevantForm from '../relevant-form';
18
  import RetrievalForm from '../retrieval-form';
19
  import RewriteQuestionForm from '../rewrite-question-form';
@@ -38,6 +39,7 @@ const FormMap = {
38
  [Operator.DuckDuckGo]: DuckDuckGoForm,
39
  [Operator.KeywordExtract]: KeywordExtractForm,
40
  [Operator.Wikipedia]: WikipediaForm,
 
41
  };
42
 
43
  const EmptyContent = () => <div>empty</div>;
 
14
  import KeywordExtractForm from '../keyword-extract-form';
15
  import MessageForm from '../message-form';
16
  import OperatorIcon from '../operator-icon';
17
+ import PubMedForm from '../pubmed-form';
18
  import RelevantForm from '../relevant-form';
19
  import RetrievalForm from '../retrieval-form';
20
  import RewriteQuestionForm from '../rewrite-question-form';
 
39
  [Operator.DuckDuckGo]: DuckDuckGoForm,
40
  [Operator.KeywordExtract]: KeywordExtractForm,
41
  [Operator.Wikipedia]: WikipediaForm,
42
+ [Operator.PubMed]: PubMedForm,
43
  };
44
 
45
  const EmptyContent = () => <div>empty</div>;
web/src/pages/flow/hooks.ts CHANGED
@@ -38,6 +38,7 @@ import {
38
  initialGenerateValues,
39
  initialKeywordExtractValues,
40
  initialMessageValues,
 
41
  initialRelevantValues,
42
  initialRetrievalValues,
43
  initialRewriteQuestionValues,
@@ -90,6 +91,7 @@ export const useInitializeOperatorParams = () => {
90
  [Operator.DuckDuckGo]: initialDuckValues,
91
  [Operator.Baidu]: initialBaiduValues,
92
  [Operator.Wikipedia]: initialWikipediaValues,
 
93
  };
94
  }, [llmId]);
95
 
 
38
  initialGenerateValues,
39
  initialKeywordExtractValues,
40
  initialMessageValues,
41
+ initialPubMedValues,
42
  initialRelevantValues,
43
  initialRetrievalValues,
44
  initialRewriteQuestionValues,
 
91
  [Operator.DuckDuckGo]: initialDuckValues,
92
  [Operator.Baidu]: initialBaiduValues,
93
  [Operator.Wikipedia]: initialWikipediaValues,
94
+ [Operator.PubMed]: initialPubMedValues,
95
  };
96
  }, [llmId]);
97
 
web/src/pages/flow/pubmed-form/index.tsx ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import TopNItem from '@/components/top-n-item';
2
+ import { useTranslate } from '@/hooks/common-hooks';
3
+ import { Form, Input } from 'antd';
4
+ import { IOperatorForm } from '../interface';
5
+
6
+ const PubMedForm = ({ onValuesChange, form }: IOperatorForm) => {
7
+ const { t } = useTranslate('flow');
8
+
9
+ return (
10
+ <Form
11
+ name="basic"
12
+ labelCol={{ span: 6 }}
13
+ wrapperCol={{ span: 18 }}
14
+ autoComplete="off"
15
+ form={form}
16
+ onValuesChange={onValuesChange}
17
+ >
18
+ <TopNItem initialValue={10}></TopNItem>
19
+ <Form.Item
20
+ label={t('email')}
21
+ name={'email'}
22
+ tooltip={t('emailTip')}
23
+ rules={[{ type: 'email' }]}
24
+ >
25
+ <Input></Input>
26
+ </Form.Item>
27
+ </Form>
28
+ );
29
+ };
30
+
31
+ export default PubMedForm;
web/src/pages/user-setting/setting-model/api-key-modal/index.tsx CHANGED
@@ -77,7 +77,7 @@ const ApiKeyModal = ({
77
  <Input placeholder="https://api.openai.com/v1" />
78
  </Form.Item>
79
  )}
80
- {llmFactory.toLowerCase() === 'Minimax'.toLowerCase() && (
81
  <Form.Item<FieldType> label={'Group ID'} name="group_id">
82
  <Input />
83
  </Form.Item>
 
77
  <Input placeholder="https://api.openai.com/v1" />
78
  </Form.Item>
79
  )}
80
+ {llmFactory?.toLowerCase() === 'Minimax'.toLowerCase() && (
81
  <Form.Item<FieldType> label={'Group ID'} name="group_id">
82
  <Input />
83
  </Form.Item>