balibabu
commited on
Commit
·
284d945
1
Parent(s):
0c61e3b
feat: Add component DeepL #1739 (#1870)
Browse files### What problem does this PR solve?
feat: Add component DeepL #1739
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/assets/svg/deepl.svg +13 -0
- web/src/locales/en.ts +6 -0
- web/src/locales/zh-traditional.ts +6 -0
- web/src/locales/zh.ts +6 -0
- web/src/pages/flow/constant.tsx +86 -0
- web/src/pages/flow/deepl-form/index.tsx +36 -0
- web/src/pages/flow/flow-drawer/index.tsx +2 -0
- web/src/pages/flow/form-hooks.ts +14 -1
- web/src/pages/flow/google-scholar-form/index.tsx +2 -6
- web/src/pages/flow/hooks.ts +2 -0
web/src/assets/svg/deepl.svg
ADDED
|
web/src/locales/en.ts
CHANGED
@@ -661,6 +661,12 @@ The above is the content you need to summarize.`,
|
|
661 |
yearHigh: 'Year high',
|
662 |
patents: 'Patents',
|
663 |
data: 'Data',
|
|
|
|
|
|
|
|
|
|
|
|
|
664 |
},
|
665 |
footer: {
|
666 |
profile: 'All rights reserved @ React',
|
|
|
661 |
yearHigh: 'Year high',
|
662 |
patents: 'Patents',
|
663 |
data: 'Data',
|
664 |
+
deepL: 'DeepL',
|
665 |
+
deepLDescription:
|
666 |
+
'This component is used to get translations from https://www.deepl.com/. Typically, it provides a more specialized translation result.',
|
667 |
+
authKey: 'Auth key',
|
668 |
+
sourceLang: 'Source language',
|
669 |
+
targetLang: 'Target language',
|
670 |
},
|
671 |
footer: {
|
672 |
profile: 'All rights reserved @ React',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -619,6 +619,12 @@ export default {
|
|
619 |
yearHigh: '結束年份',
|
620 |
patents: '專利',
|
621 |
data: '數據',
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
},
|
623 |
footer: {
|
624 |
profile: '“保留所有權利 @ react”',
|
|
|
619 |
yearHigh: '結束年份',
|
620 |
patents: '專利',
|
621 |
data: '數據',
|
622 |
+
deepL: 'DeepL',
|
623 |
+
deepLDescription:
|
624 |
+
'此元件用於從 https://www.deepl.com/ 取得翻譯。通常,它提供更專業的翻譯結果。',
|
625 |
+
authKey: '授權鍵',
|
626 |
+
sourceLang: '原始語言',
|
627 |
+
targetLang: '目標語言',
|
628 |
},
|
629 |
footer: {
|
630 |
profile: '“保留所有權利 @ react”',
|
web/src/locales/zh.ts
CHANGED
@@ -637,6 +637,12 @@ export default {
|
|
637 |
yearHigh: '结束年份',
|
638 |
patents: '专利',
|
639 |
data: '数据',
|
|
|
|
|
|
|
|
|
|
|
|
|
640 |
},
|
641 |
footer: {
|
642 |
profile: 'All rights reserved @ React',
|
|
|
637 |
yearHigh: '结束年份',
|
638 |
patents: '专利',
|
639 |
data: '数据',
|
640 |
+
deepL: 'DeepL',
|
641 |
+
deepLDescription:
|
642 |
+
'该组件用于从 https://www.deepl.com/ 获取翻译。通常,它提供更专业的翻译结果。',
|
643 |
+
authKey: '授权键',
|
644 |
+
sourceLang: '源语言',
|
645 |
+
targetLang: '目标语言',
|
646 |
},
|
647 |
footer: {
|
648 |
profile: 'All rights reserved @ React',
|
web/src/pages/flow/constant.tsx
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import { ReactComponent as ArXivIcon } from '@/assets/svg/arxiv.svg';
|
2 |
import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
|
3 |
import { ReactComponent as BingIcon } from '@/assets/svg/bing.svg';
|
|
|
4 |
import { ReactComponent as DuckIcon } from '@/assets/svg/duck.svg';
|
5 |
import { ReactComponent as GoogleScholarIcon } from '@/assets/svg/google-scholar.svg';
|
6 |
import { ReactComponent as GoogleIcon } from '@/assets/svg/google.svg';
|
@@ -46,6 +47,7 @@ export enum Operator {
|
|
46 |
Google = 'Google',
|
47 |
Bing = 'Bing',
|
48 |
GoogleScholar = 'GoogleScholar',
|
|
|
49 |
}
|
50 |
|
51 |
export const operatorIconMap = {
|
@@ -66,6 +68,7 @@ export const operatorIconMap = {
|
|
66 |
[Operator.Google]: GoogleIcon,
|
67 |
[Operator.Bing]: BingIcon,
|
68 |
[Operator.GoogleScholar]: GoogleScholarIcon,
|
|
|
69 |
};
|
70 |
|
71 |
export const operatorMap = {
|
@@ -149,6 +152,7 @@ export const operatorMap = {
|
|
149 |
},
|
150 |
[Operator.Bing]: {},
|
151 |
[Operator.GoogleScholar]: {},
|
|
|
152 |
};
|
153 |
|
154 |
export const componentMenuList = [
|
@@ -200,6 +204,9 @@ export const componentMenuList = [
|
|
200 |
{
|
201 |
name: Operator.GoogleScholar,
|
202 |
},
|
|
|
|
|
|
|
203 |
];
|
204 |
|
205 |
export const initialRetrievalValues = {
|
@@ -304,6 +311,11 @@ export const initialGoogleScholarValues = {
|
|
304 |
patents: true,
|
305 |
};
|
306 |
|
|
|
|
|
|
|
|
|
|
|
307 |
export const CategorizeAnchorPointPositions = [
|
308 |
{ top: 1, right: 34 },
|
309 |
{ top: 8, right: 18 },
|
@@ -368,6 +380,7 @@ export const RestrictedUpstreamMap = {
|
|
368 |
[Operator.Google]: [Operator.Begin, Operator.Retrieval],
|
369 |
[Operator.Bing]: [Operator.Begin, Operator.Retrieval],
|
370 |
[Operator.GoogleScholar]: [Operator.Begin, Operator.Retrieval],
|
|
|
371 |
};
|
372 |
|
373 |
export const NodeMap = {
|
@@ -388,6 +401,7 @@ export const NodeMap = {
|
|
388 |
[Operator.Google]: 'ragNode',
|
389 |
[Operator.Bing]: 'ragNode',
|
390 |
[Operator.GoogleScholar]: 'ragNode',
|
|
|
391 |
};
|
392 |
|
393 |
export const LanguageOptions = [
|
@@ -1299,6 +1313,7 @@ export const GoogleLanguageOptions = [
|
|
1299 |
language_name: 'Zulu',
|
1300 |
},
|
1301 |
].map((x) => ({ label: x.language_name, value: x.language_code }));
|
|
|
1302 |
export const GoogleCountryOptions = [
|
1303 |
{
|
1304 |
country_code: 'af',
|
@@ -2353,3 +2368,74 @@ export const BingLanguageOptions = [
|
|
2353 |
{ label: 'Ukrainian uk', value: 'uk' },
|
2354 |
{ label: 'Vietnamese vi', value: 'vi' },
|
2355 |
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import { ReactComponent as ArXivIcon } from '@/assets/svg/arxiv.svg';
|
2 |
import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
|
3 |
import { ReactComponent as BingIcon } from '@/assets/svg/bing.svg';
|
4 |
+
import { ReactComponent as DeepLIcon } from '@/assets/svg/deepl.svg';
|
5 |
import { ReactComponent as DuckIcon } from '@/assets/svg/duck.svg';
|
6 |
import { ReactComponent as GoogleScholarIcon } from '@/assets/svg/google-scholar.svg';
|
7 |
import { ReactComponent as GoogleIcon } from '@/assets/svg/google.svg';
|
|
|
47 |
Google = 'Google',
|
48 |
Bing = 'Bing',
|
49 |
GoogleScholar = 'GoogleScholar',
|
50 |
+
DeepL = 'DeepL',
|
51 |
}
|
52 |
|
53 |
export const operatorIconMap = {
|
|
|
68 |
[Operator.Google]: GoogleIcon,
|
69 |
[Operator.Bing]: BingIcon,
|
70 |
[Operator.GoogleScholar]: GoogleScholarIcon,
|
71 |
+
[Operator.DeepL]: DeepLIcon,
|
72 |
};
|
73 |
|
74 |
export const operatorMap = {
|
|
|
152 |
},
|
153 |
[Operator.Bing]: {},
|
154 |
[Operator.GoogleScholar]: {},
|
155 |
+
[Operator.DeepL]: {},
|
156 |
};
|
157 |
|
158 |
export const componentMenuList = [
|
|
|
204 |
{
|
205 |
name: Operator.GoogleScholar,
|
206 |
},
|
207 |
+
{
|
208 |
+
name: Operator.DeepL,
|
209 |
+
},
|
210 |
];
|
211 |
|
212 |
export const initialRetrievalValues = {
|
|
|
311 |
patents: true,
|
312 |
};
|
313 |
|
314 |
+
export const initialDeepLValues = {
|
315 |
+
text: 5,
|
316 |
+
auth_key: 'relevance',
|
317 |
+
};
|
318 |
+
|
319 |
export const CategorizeAnchorPointPositions = [
|
320 |
{ top: 1, right: 34 },
|
321 |
{ top: 8, right: 18 },
|
|
|
380 |
[Operator.Google]: [Operator.Begin, Operator.Retrieval],
|
381 |
[Operator.Bing]: [Operator.Begin, Operator.Retrieval],
|
382 |
[Operator.GoogleScholar]: [Operator.Begin, Operator.Retrieval],
|
383 |
+
[Operator.DeepL]: [Operator.Begin, Operator.Retrieval],
|
384 |
};
|
385 |
|
386 |
export const NodeMap = {
|
|
|
401 |
[Operator.Google]: 'ragNode',
|
402 |
[Operator.Bing]: 'ragNode',
|
403 |
[Operator.GoogleScholar]: 'ragNode',
|
404 |
+
[Operator.DeepL]: 'ragNode',
|
405 |
};
|
406 |
|
407 |
export const LanguageOptions = [
|
|
|
1313 |
language_name: 'Zulu',
|
1314 |
},
|
1315 |
].map((x) => ({ label: x.language_name, value: x.language_code }));
|
1316 |
+
|
1317 |
export const GoogleCountryOptions = [
|
1318 |
{
|
1319 |
country_code: 'af',
|
|
|
2368 |
{ label: 'Ukrainian uk', value: 'uk' },
|
2369 |
{ label: 'Vietnamese vi', value: 'vi' },
|
2370 |
];
|
2371 |
+
|
2372 |
+
export const DeepLSourceLangOptions = [
|
2373 |
+
{ label: 'Arabic [1]', value: 'AR' },
|
2374 |
+
{ label: 'Bulgarian', value: 'BG' },
|
2375 |
+
{ label: 'Czech', value: 'CS' },
|
2376 |
+
{ label: 'Danish', value: 'DA' },
|
2377 |
+
{ label: 'German', value: 'DE' },
|
2378 |
+
{ label: 'Greek', value: 'EL' },
|
2379 |
+
{ label: 'English', value: 'EN' },
|
2380 |
+
{ label: 'Spanish', value: 'ES' },
|
2381 |
+
{ label: 'Estonian', value: 'ET' },
|
2382 |
+
{ label: 'Finnish', value: 'FI' },
|
2383 |
+
{ label: 'French', value: 'FR' },
|
2384 |
+
{ label: 'Hungarian', value: 'HU' },
|
2385 |
+
{ label: 'Indonesian', value: 'ID' },
|
2386 |
+
{ label: 'Italian', value: 'IT' },
|
2387 |
+
{ label: 'Japanese', value: 'JA' },
|
2388 |
+
{ label: 'Korean', value: 'KO' },
|
2389 |
+
{ label: 'Lithuanian', value: 'LT' },
|
2390 |
+
{ label: 'Latvian', value: 'LV' },
|
2391 |
+
{ label: 'Norwegian Bokmål', value: 'NB' },
|
2392 |
+
{ label: 'Dutch', value: 'NL' },
|
2393 |
+
{ label: 'Polish', value: 'PL' },
|
2394 |
+
{ label: 'Portuguese (all Portuguese varieties mixed)', value: 'PT' },
|
2395 |
+
{ label: 'Romanian', value: 'RO' },
|
2396 |
+
{ label: 'Russian', value: 'RU' },
|
2397 |
+
{ label: 'Slovak', value: 'SK' },
|
2398 |
+
{ label: 'Slovenian', value: 'SL' },
|
2399 |
+
{ label: 'Swedish', value: 'SV' },
|
2400 |
+
{ label: 'Turkish', value: 'TR' },
|
2401 |
+
{ label: 'Ukrainian', value: 'UK' },
|
2402 |
+
{ label: 'Chinese', value: 'ZH' },
|
2403 |
+
];
|
2404 |
+
export const DeepLTargetLangOptions = [
|
2405 |
+
{ label: 'Arabic [1]', value: 'AR' },
|
2406 |
+
{ label: 'Bulgarian', value: 'BG' },
|
2407 |
+
{ label: 'Czech', value: 'CS' },
|
2408 |
+
{ label: 'Danish', value: 'DA' },
|
2409 |
+
{ label: 'German', value: 'DE' },
|
2410 |
+
{ label: 'Greek', value: 'EL' },
|
2411 |
+
{ label: 'English (British)', value: 'EN-GB' },
|
2412 |
+
{ label: 'English (American)', value: 'EN-US' },
|
2413 |
+
{ label: 'Spanish', value: 'ES' },
|
2414 |
+
{ label: 'Estonian', value: 'ET' },
|
2415 |
+
{ label: 'Finnish', value: 'FI' },
|
2416 |
+
{ label: 'French', value: 'FR' },
|
2417 |
+
{ label: 'Hungarian', value: 'HU' },
|
2418 |
+
{ label: 'Indonesian', value: 'ID' },
|
2419 |
+
{ label: 'Italian', value: 'IT' },
|
2420 |
+
{ label: 'Japanese', value: 'JA' },
|
2421 |
+
{ label: 'Korean', value: 'KO' },
|
2422 |
+
{ label: 'Lithuanian', value: 'LT' },
|
2423 |
+
{ label: 'Latvian', value: 'LV' },
|
2424 |
+
{ label: 'Norwegian Bokmål', value: 'NB' },
|
2425 |
+
{ label: 'Dutch', value: 'NL' },
|
2426 |
+
{ label: 'Polish', value: 'PL' },
|
2427 |
+
{ label: 'Portuguese (Brazilian)', value: 'PT-BR' },
|
2428 |
+
{
|
2429 |
+
label:
|
2430 |
+
'Portuguese (all Portuguese varieties excluding Brazilian Portuguese)',
|
2431 |
+
value: 'PT-PT',
|
2432 |
+
},
|
2433 |
+
{ label: 'Romanian', value: 'RO' },
|
2434 |
+
{ label: 'Russian', value: 'RU' },
|
2435 |
+
{ label: 'Slovak', value: 'SK' },
|
2436 |
+
{ label: 'Slovenian', value: 'SL' },
|
2437 |
+
{ label: 'Swedish', value: 'SV' },
|
2438 |
+
{ label: 'Turkish', value: 'TR' },
|
2439 |
+
{ label: 'Ukrainian', value: 'UK' },
|
2440 |
+
{ label: 'Chinese (simplified)', value: 'ZH' },
|
2441 |
+
];
|
web/src/pages/flow/deepl-form/index.tsx
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
+
import { Form, InputNumber, Select } from 'antd';
|
3 |
+
import { DeepLSourceLangOptions, DeepLTargetLangOptions } from '../constant';
|
4 |
+
import { useBuildSortOptions } from '../form-hooks';
|
5 |
+
import { IOperatorForm } from '../interface';
|
6 |
+
|
7 |
+
const DeepLForm = ({ onValuesChange, form }: IOperatorForm) => {
|
8 |
+
const { t } = useTranslate('flow');
|
9 |
+
const options = useBuildSortOptions();
|
10 |
+
|
11 |
+
return (
|
12 |
+
<Form
|
13 |
+
name="basic"
|
14 |
+
labelCol={{ span: 8 }}
|
15 |
+
wrapperCol={{ span: 16 }}
|
16 |
+
autoComplete="off"
|
17 |
+
form={form}
|
18 |
+
onValuesChange={onValuesChange}
|
19 |
+
>
|
20 |
+
<Form.Item label={t('text')} name={'text'}>
|
21 |
+
<InputNumber></InputNumber>
|
22 |
+
</Form.Item>
|
23 |
+
<Form.Item label={t('authKey')} name={'auth_key'}>
|
24 |
+
<Select options={options}></Select>
|
25 |
+
</Form.Item>
|
26 |
+
<Form.Item label={t('sourceLang')} name={'source_lang'}>
|
27 |
+
<Select options={DeepLSourceLangOptions}></Select>
|
28 |
+
</Form.Item>
|
29 |
+
<Form.Item label={t('targetLang')} name={'target_lang'}>
|
30 |
+
<Select options={DeepLTargetLangOptions}></Select>
|
31 |
+
</Form.Item>
|
32 |
+
</Form>
|
33 |
+
);
|
34 |
+
};
|
35 |
+
|
36 |
+
export default DeepLForm;
|
web/src/pages/flow/flow-drawer/index.tsx
CHANGED
@@ -24,6 +24,7 @@ import RetrievalForm from '../retrieval-form';
|
|
24 |
import RewriteQuestionForm from '../rewrite-question-form';
|
25 |
import WikipediaForm from '../wikipedia-form';
|
26 |
|
|
|
27 |
import styles from './index.less';
|
28 |
|
29 |
interface IProps {
|
@@ -48,6 +49,7 @@ const FormMap = {
|
|
48 |
[Operator.Google]: GoogleForm,
|
49 |
[Operator.Bing]: BingForm,
|
50 |
[Operator.GoogleScholar]: GoogleScholarForm,
|
|
|
51 |
};
|
52 |
|
53 |
const EmptyContent = () => <div>empty</div>;
|
|
|
24 |
import RewriteQuestionForm from '../rewrite-question-form';
|
25 |
import WikipediaForm from '../wikipedia-form';
|
26 |
|
27 |
+
import DeepLForm from '../deepl-form';
|
28 |
import styles from './index.less';
|
29 |
|
30 |
interface IProps {
|
|
|
49 |
[Operator.Google]: GoogleForm,
|
50 |
[Operator.Bing]: BingForm,
|
51 |
[Operator.GoogleScholar]: GoogleScholarForm,
|
52 |
+
[Operator.DeepL]: DeepLForm,
|
53 |
};
|
54 |
|
55 |
const EmptyContent = () => <div>empty</div>;
|
web/src/pages/flow/form-hooks.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
import {
|
|
|
2 |
import { Operator } from './constant';
|
3 |
import useGraphStore from './store';
|
4 |
|
@@ -71,3 +72,15 @@ export const useHandleFormSelectChange = (nodeId?: string) => {
|
|
71 |
|
72 |
return { handleSelectChange };
|
73 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
+
import { useCallback, useMemo } from 'react';
|
3 |
import { Operator } from './constant';
|
4 |
import useGraphStore from './store';
|
5 |
|
|
|
72 |
|
73 |
return { handleSelectChange };
|
74 |
};
|
75 |
+
|
76 |
+
export const useBuildSortOptions = () => {
|
77 |
+
const { t } = useTranslate('flow');
|
78 |
+
|
79 |
+
const options = useMemo(() => {
|
80 |
+
return ['data', 'relevance'].map((x) => ({
|
81 |
+
value: x,
|
82 |
+
label: t(x),
|
83 |
+
}));
|
84 |
+
}, [t]);
|
85 |
+
return options;
|
86 |
+
};
|
web/src/pages/flow/google-scholar-form/index.tsx
CHANGED
@@ -3,6 +3,7 @@ import { useTranslate } from '@/hooks/common-hooks';
|
|
3 |
import { DatePicker, DatePickerProps, Form, Select, Switch } from 'antd';
|
4 |
import dayjs from 'dayjs';
|
5 |
import { useCallback, useMemo } from 'react';
|
|
|
6 |
import { IOperatorForm } from '../interface';
|
7 |
|
8 |
const YearPicker = ({
|
@@ -33,12 +34,7 @@ const YearPicker = ({
|
|
33 |
const GoogleScholarForm = ({ onValuesChange, form }: IOperatorForm) => {
|
34 |
const { t } = useTranslate('flow');
|
35 |
|
36 |
-
const options =
|
37 |
-
return ['data', 'relevance'].map((x) => ({
|
38 |
-
value: x,
|
39 |
-
label: t(x),
|
40 |
-
}));
|
41 |
-
}, [t]);
|
42 |
|
43 |
return (
|
44 |
<Form
|
|
|
3 |
import { DatePicker, DatePickerProps, Form, Select, Switch } from 'antd';
|
4 |
import dayjs from 'dayjs';
|
5 |
import { useCallback, useMemo } from 'react';
|
6 |
+
import { useBuildSortOptions } from '../form-hooks';
|
7 |
import { IOperatorForm } from '../interface';
|
8 |
|
9 |
const YearPicker = ({
|
|
|
34 |
const GoogleScholarForm = ({ onValuesChange, form }: IOperatorForm) => {
|
35 |
const { t } = useTranslate('flow');
|
36 |
|
37 |
+
const options = useBuildSortOptions();
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
return (
|
40 |
<Form
|
web/src/pages/flow/hooks.ts
CHANGED
@@ -35,6 +35,7 @@ import {
|
|
35 |
initialBeginValues,
|
36 |
initialBingValues,
|
37 |
initialCategorizeValues,
|
|
|
38 |
initialDuckValues,
|
39 |
initialGenerateValues,
|
40 |
initialGoogleScholarValues,
|
@@ -99,6 +100,7 @@ export const useInitializeOperatorParams = () => {
|
|
99 |
[Operator.Google]: initialGoogleValues,
|
100 |
[Operator.Bing]: initialBingValues,
|
101 |
[Operator.GoogleScholar]: initialGoogleScholarValues,
|
|
|
102 |
};
|
103 |
}, [llmId]);
|
104 |
|
|
|
35 |
initialBeginValues,
|
36 |
initialBingValues,
|
37 |
initialCategorizeValues,
|
38 |
+
initialDeepLValues,
|
39 |
initialDuckValues,
|
40 |
initialGenerateValues,
|
41 |
initialGoogleScholarValues,
|
|
|
100 |
[Operator.Google]: initialGoogleValues,
|
101 |
[Operator.Bing]: initialBingValues,
|
102 |
[Operator.GoogleScholar]: initialGoogleScholarValues,
|
103 |
+
[Operator.DeepL]: initialDeepLValues,
|
104 |
};
|
105 |
}, [llmId]);
|
106 |
|