balibabu commited on
Commit
42dbb1f
·
1 Parent(s): 4d11778

feat: Add component QWeather #1739 (#1881)

Browse files

### What problem does this PR solve?

feat: Add component QWeather #1739

### Type of change


- [x] New Feature (non-breaking change which adds functionality)

web/src/assets/svg/qweather.svg ADDED
web/src/locales/en.ts CHANGED
@@ -725,6 +725,64 @@ The above is the content you need to summarize.`,
725
  cht: 'Traditional Chinese',
726
  vie: 'Vietnamese',
727
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
728
  },
729
  footer: {
730
  profile: 'All rights reserved @ React',
 
725
  cht: 'Traditional Chinese',
726
  vie: 'Vietnamese',
727
  },
728
+ qWeather: 'QWeather',
729
+ qWeatherDescription:
730
+ 'This component is used to get weather related information from https://www.qweather.com/. You can get weather, indices, air quality.',
731
+ lang: 'Language',
732
+ type: 'Type',
733
+ webApiKey: 'Web API key',
734
+ userType: 'User type',
735
+ timePeriod: 'Time period',
736
+ qWeatherLangOptions: {
737
+ zh: 'Simplified Chinese',
738
+ 'zh-hant': 'Traditional Chinese',
739
+ en: 'English',
740
+ de: 'German',
741
+ es: 'Spanish',
742
+ fr: 'French',
743
+ it: 'Italian',
744
+ ja: 'Japanese',
745
+ ko: 'Korean',
746
+ ru: 'Russian',
747
+ hi: 'Hindi',
748
+ th: 'Thai',
749
+ ar: 'Arabic',
750
+ pt: 'Portuguese',
751
+ bn: 'Bengali',
752
+ ms: 'Malay',
753
+ nl: 'Dutch',
754
+ el: 'Greek',
755
+ la: 'Latin',
756
+ sv: 'Swedish',
757
+ id: 'Indonesian',
758
+ pl: 'Polish',
759
+ tr: 'Turkish',
760
+ cs: 'Czech',
761
+ et: 'Estonian',
762
+ vi: 'Vietnamese',
763
+ fil: 'Filipino',
764
+ fi: 'Finnish',
765
+ he: 'Hebrew',
766
+ is: 'Icelandic',
767
+ nb: 'Norwegian',
768
+ },
769
+ qWeatherTypeOptions: {
770
+ weather: 'Weather forecast',
771
+ indices: 'Weather life index',
772
+ airquality: 'Air quality',
773
+ },
774
+ qWeatherUserTypeOptions: {
775
+ free: 'Free subscriber',
776
+ paid: 'Paid subscriber',
777
+ },
778
+ qWeatherTimePeriodOptions: {
779
+ now: 'Now',
780
+ '3d': '3 days',
781
+ '7d': '7 days',
782
+ '10d': '10 days',
783
+ '15d': '12 days',
784
+ '30d': '30 days',
785
+ },
786
  },
787
  footer: {
788
  profile: 'All rights reserved @ React',
web/src/locales/zh-traditional.ts CHANGED
@@ -683,6 +683,64 @@ export default {
683
  cht: '繁體中文',
684
  vie: '越南語',
685
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
686
  },
687
  footer: {
688
  profile: '“保留所有權利 @ react”',
 
683
  cht: '繁體中文',
684
  vie: '越南語',
685
  },
686
+ qWeather: '和風天氣',
687
+ qWeatherDescription:
688
+ '此元件用於從 https://www.qweather.com/ 取得天氣相關資訊。您可以獲得天氣、指數、空氣品質。',
689
+ lang: '語言',
690
+ type: '類型',
691
+ webApiKey: 'Web API 密鑰',
692
+ userType: '使用者類型',
693
+ timePeriod: '時間段',
694
+ qWeatherLangOptions: {
695
+ zh: '簡體中文',
696
+ 'zh-hant': '繁體中文',
697
+ en: '英文',
698
+ de: '德語',
699
+ es: '西班牙語',
700
+ fr: '法文',
701
+ it: '義大利語',
702
+ ja: '日文',
703
+ ko: '韓語',
704
+ ru: '俄文',
705
+ hi: '印地語',
706
+ th: '泰語',
707
+ ar: '阿拉伯語',
708
+ pt: '葡萄牙語',
709
+ bn: '孟加拉語',
710
+ ms: '馬來語',
711
+ nl: '荷蘭語',
712
+ el: '希臘文',
713
+ la: '拉丁文',
714
+ sv: '瑞典語',
715
+ id: '印尼語',
716
+ pl: '波蘭語',
717
+ tr: '土耳其語',
718
+ cs: '捷克語',
719
+ et: '愛沙尼亞語',
720
+ vi: '越南語',
721
+ fil: '菲律賓語',
722
+ fi: '芬蘭語',
723
+ he: '希伯來文',
724
+ is: '冰島語',
725
+ nb: '挪威語',
726
+ },
727
+ qWeatherTypeOptions: {
728
+ weather: '天氣預報',
729
+ indices: '天氣生活指數',
730
+ airquality: '空氣品質',
731
+ },
732
+ qWeatherUserTypeOptions: {
733
+ free: '免費訂閱用戶',
734
+ paid: '付費訂閱用戶',
735
+ },
736
+ qWeatherTimePeriodOptions: {
737
+ now: '現在',
738
+ '3d': '3天',
739
+ '7d': '7天',
740
+ '10d': '10天',
741
+ '15d': '12天',
742
+ '30d': '30天',
743
+ },
744
  },
745
  footer: {
746
  profile: '“保留所有權利 @ react”',
web/src/locales/zh.ts CHANGED
@@ -701,6 +701,64 @@ export default {
701
  cht: '繁体中文',
702
  vie: '越南语',
703
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  },
705
  footer: {
706
  profile: 'All rights reserved @ React',
 
701
  cht: '繁体中文',
702
  vie: '越南语',
703
  },
704
+ qWeather: '和风天气',
705
+ qWeatherDescription:
706
+ '该组件用于从 https://www.qweather.com/ 获取天气相关信息。您可以获取天气、指数、空气质量。',
707
+ lang: '语言',
708
+ type: '类型',
709
+ webApiKey: 'Web API 密钥',
710
+ userType: '用户类型',
711
+ timePeriod: '时间段',
712
+ qWeatherLangOptions: {
713
+ zh: '简体中文',
714
+ 'zh-hant': '繁体中文',
715
+ en: '英文',
716
+ de: '德语',
717
+ es: '西班牙语',
718
+ fr: '法语',
719
+ it: '意大利语',
720
+ ja: '日语',
721
+ ko: '韩语',
722
+ ru: '俄语',
723
+ hi: '印地语',
724
+ th: '泰语',
725
+ ar: '阿拉伯语',
726
+ pt: '葡萄牙语',
727
+ bn: '孟加拉语',
728
+ ms: '马来语',
729
+ nl: '荷兰语',
730
+ el: '希腊语',
731
+ la: '拉丁语',
732
+ sv: '瑞典语',
733
+ id: '印尼语',
734
+ pl: '波兰语',
735
+ tr: '土耳其语',
736
+ cs: '捷克语',
737
+ et: '爱沙尼亚语',
738
+ vi: '越南语',
739
+ fil: '菲律宾语',
740
+ fi: '芬兰语',
741
+ he: '希伯来语',
742
+ is: '冰岛语',
743
+ nb: '挪威语',
744
+ },
745
+ qWeatherTypeOptions: {
746
+ weather: '天气预报',
747
+ indices: '天气生活指数',
748
+ airquality: '空气质量',
749
+ },
750
+ qWeatherUserTypeOptions: {
751
+ free: '免费订阅用户',
752
+ paid: '付费订阅用户',
753
+ },
754
+ qWeatherTimePeriodOptions: {
755
+ now: '现在',
756
+ '3d': '3天',
757
+ '7d': '7天',
758
+ '10d': '10天',
759
+ '15d': '12天',
760
+ '30d': '30天',
761
+ },
762
  },
763
  footer: {
764
  profile: 'All rights reserved @ React',
web/src/pages/flow/constant.tsx CHANGED
@@ -9,6 +9,7 @@ import { ReactComponent as GoogleScholarIcon } from '@/assets/svg/google-scholar
9
  import { ReactComponent as GoogleIcon } from '@/assets/svg/google.svg';
10
  import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
11
  import { ReactComponent as PubMedIcon } from '@/assets/svg/pubmed.svg';
 
12
  import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
13
 
14
  import { variableEnabledFieldMap } from '@/constants/chat';
@@ -52,6 +53,7 @@ export enum Operator {
52
  DeepL = 'DeepL',
53
  GitHub = 'GitHub',
54
  BaiduFanyi = 'BaiduFanyi',
 
55
  }
56
 
57
  export const operatorIconMap = {
@@ -75,6 +77,7 @@ export const operatorIconMap = {
75
  [Operator.DeepL]: DeepLIcon,
76
  [Operator.GitHub]: GithubIcon,
77
  [Operator.BaiduFanyi]: baiduFanyiIcon,
 
78
  };
79
 
80
  export const operatorMap = {
@@ -161,6 +164,7 @@ export const operatorMap = {
161
  [Operator.DeepL]: {},
162
  [Operator.GitHub]: {},
163
  [Operator.BaiduFanyi]: {},
 
164
  };
165
 
166
  export const componentMenuList = [
@@ -221,6 +225,9 @@ export const componentMenuList = [
221
  {
222
  name: Operator.BaiduFanyi,
223
  },
 
 
 
224
  ];
225
 
226
  export const initialRetrievalValues = {
@@ -340,6 +347,13 @@ export const initialBaiduFanyiValues = {
340
  trans_type: 'translate',
341
  };
342
 
 
 
 
 
 
 
 
343
  export const CategorizeAnchorPointPositions = [
344
  { top: 1, right: 34 },
345
  { top: 8, right: 18 },
@@ -407,6 +421,7 @@ export const RestrictedUpstreamMap = {
407
  [Operator.DeepL]: [Operator.Begin, Operator.Retrieval],
408
  [Operator.GitHub]: [Operator.Begin, Operator.Retrieval],
409
  [Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval],
 
410
  };
411
 
412
  export const NodeMap = {
@@ -430,6 +445,7 @@ export const NodeMap = {
430
  [Operator.DeepL]: 'ragNode',
431
  [Operator.GitHub]: 'ragNode',
432
  [Operator.BaiduFanyi]: 'ragNode',
 
433
  };
434
 
435
  export const LanguageOptions = [
@@ -2513,3 +2529,50 @@ export const BaiduFanyiSourceLangOptions = [
2513
  'cht',
2514
  'vie',
2515
  ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import { ReactComponent as GoogleIcon } from '@/assets/svg/google.svg';
10
  import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
11
  import { ReactComponent as PubMedIcon } from '@/assets/svg/pubmed.svg';
12
+ import { ReactComponent as QWeatherIcon } from '@/assets/svg/qweather.svg';
13
  import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
14
 
15
  import { variableEnabledFieldMap } from '@/constants/chat';
 
53
  DeepL = 'DeepL',
54
  GitHub = 'GitHub',
55
  BaiduFanyi = 'BaiduFanyi',
56
+ QWeather = 'QWeather',
57
  }
58
 
59
  export const operatorIconMap = {
 
77
  [Operator.DeepL]: DeepLIcon,
78
  [Operator.GitHub]: GithubIcon,
79
  [Operator.BaiduFanyi]: baiduFanyiIcon,
80
+ [Operator.QWeather]: QWeatherIcon,
81
  };
82
 
83
  export const operatorMap = {
 
164
  [Operator.DeepL]: {},
165
  [Operator.GitHub]: {},
166
  [Operator.BaiduFanyi]: {},
167
+ [Operator.QWeather]: {},
168
  };
169
 
170
  export const componentMenuList = [
 
225
  {
226
  name: Operator.BaiduFanyi,
227
  },
228
+ {
229
+ name: Operator.QWeather,
230
+ },
231
  ];
232
 
233
  export const initialRetrievalValues = {
 
347
  trans_type: 'translate',
348
  };
349
 
350
+ export const initialQWeatherValues = {
351
+ web_apikey: 'xxx',
352
+ type: 'weather',
353
+ user_type: 'free',
354
+ time_period: 'now',
355
+ };
356
+
357
  export const CategorizeAnchorPointPositions = [
358
  { top: 1, right: 34 },
359
  { top: 8, right: 18 },
 
421
  [Operator.DeepL]: [Operator.Begin, Operator.Retrieval],
422
  [Operator.GitHub]: [Operator.Begin, Operator.Retrieval],
423
  [Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval],
424
+ [Operator.QWeather]: [Operator.Begin, Operator.Retrieval],
425
  };
426
 
427
  export const NodeMap = {
 
445
  [Operator.DeepL]: 'ragNode',
446
  [Operator.GitHub]: 'ragNode',
447
  [Operator.BaiduFanyi]: 'ragNode',
448
+ [Operator.QWeather]: 'ragNode',
449
  };
450
 
451
  export const LanguageOptions = [
 
2529
  'cht',
2530
  'vie',
2531
  ];
2532
+
2533
+ export const QWeatherLangOptions = [
2534
+ 'zh',
2535
+ 'zh-hant',
2536
+ 'en',
2537
+ 'de',
2538
+ 'es',
2539
+ 'fr',
2540
+ 'it',
2541
+ 'ja',
2542
+ 'ko',
2543
+ 'ru',
2544
+ 'hi',
2545
+ 'th',
2546
+ 'ar',
2547
+ 'pt',
2548
+ 'bn',
2549
+ 'ms',
2550
+ 'nl',
2551
+ 'el',
2552
+ 'la',
2553
+ 'sv',
2554
+ 'id',
2555
+ 'pl',
2556
+ 'tr',
2557
+ 'cs',
2558
+ 'et',
2559
+ 'vi',
2560
+ 'fil',
2561
+ 'fi',
2562
+ 'he',
2563
+ 'is',
2564
+ 'nb',
2565
+ ];
2566
+
2567
+ export const QWeatherTypeOptions = ['weather', 'indices', 'airquality'];
2568
+
2569
+ export const QWeatherUserTypeOptions = ['free', 'paid'];
2570
+
2571
+ export const QWeatherTimePeriodOptions = [
2572
+ 'now',
2573
+ '3d',
2574
+ '7d',
2575
+ '10d',
2576
+ '15d',
2577
+ '30d',
2578
+ ];
web/src/pages/flow/flow-drawer/index.tsx CHANGED
@@ -21,6 +21,7 @@ import KeywordExtractForm from '../keyword-extract-form';
21
  import MessageForm from '../message-form';
22
  import OperatorIcon from '../operator-icon';
23
  import PubMedForm from '../pubmed-form';
 
24
  import RelevantForm from '../relevant-form';
25
  import RetrievalForm from '../retrieval-form';
26
  import RewriteQuestionForm from '../rewrite-question-form';
@@ -54,6 +55,7 @@ const FormMap = {
54
  [Operator.DeepL]: DeepLForm,
55
  [Operator.GitHub]: GithubForm,
56
  [Operator.BaiduFanyi]: BaiduFanyiForm,
 
57
  };
58
 
59
  const EmptyContent = () => <div>empty</div>;
 
21
  import MessageForm from '../message-form';
22
  import OperatorIcon from '../operator-icon';
23
  import PubMedForm from '../pubmed-form';
24
+ import QWeatherForm from '../qweather-form';
25
  import RelevantForm from '../relevant-form';
26
  import RetrievalForm from '../retrieval-form';
27
  import RewriteQuestionForm from '../rewrite-question-form';
 
55
  [Operator.DeepL]: DeepLForm,
56
  [Operator.GitHub]: GithubForm,
57
  [Operator.BaiduFanyi]: BaiduFanyiForm,
58
+ [Operator.QWeather]: QWeatherForm,
59
  };
60
 
61
  const EmptyContent = () => <div>empty</div>;
web/src/pages/flow/hooks.ts CHANGED
@@ -45,6 +45,7 @@ import {
45
  initialKeywordExtractValues,
46
  initialMessageValues,
47
  initialPubMedValues,
 
48
  initialRelevantValues,
49
  initialRetrievalValues,
50
  initialRewriteQuestionValues,
@@ -105,6 +106,7 @@ export const useInitializeOperatorParams = () => {
105
  [Operator.DeepL]: initialDeepLValues,
106
  [Operator.GitHub]: initialGithubValues,
107
  [Operator.BaiduFanyi]: initialBaiduFanyiValues,
 
108
  };
109
  }, [llmId]);
110
 
 
45
  initialKeywordExtractValues,
46
  initialMessageValues,
47
  initialPubMedValues,
48
+ initialQWeatherValues,
49
  initialRelevantValues,
50
  initialRetrievalValues,
51
  initialRewriteQuestionValues,
 
106
  [Operator.DeepL]: initialDeepLValues,
107
  [Operator.GitHub]: initialGithubValues,
108
  [Operator.BaiduFanyi]: initialBaiduFanyiValues,
109
+ [Operator.QWeather]: initialQWeatherValues,
110
  };
111
  }, [llmId]);
112
 
web/src/pages/flow/qweather-form/index.tsx ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useTranslate } from '@/hooks/common-hooks';
2
+ import { Form, Input, Select } from 'antd';
3
+ import { useMemo } from 'react';
4
+ import {
5
+ QWeatherLangOptions,
6
+ QWeatherTimePeriodOptions,
7
+ QWeatherTypeOptions,
8
+ QWeatherUserTypeOptions,
9
+ } from '../constant';
10
+ import { IOperatorForm } from '../interface';
11
+
12
+ const QWeatherForm = ({ onValuesChange, form }: IOperatorForm) => {
13
+ const { t } = useTranslate('flow');
14
+ const qWeatherLangOptions = useMemo(() => {
15
+ return QWeatherLangOptions.map((x) => ({
16
+ value: x,
17
+ label: t(`qWeatherLangOptions.${x}`),
18
+ }));
19
+ }, [t]);
20
+
21
+ const qWeatherTypeOptions = useMemo(() => {
22
+ return QWeatherTypeOptions.map((x) => ({
23
+ value: x,
24
+ label: t(`qWeatherTypeOptions.${x}`),
25
+ }));
26
+ }, [t]);
27
+
28
+ const qWeatherUserTypeOptions = useMemo(() => {
29
+ return QWeatherUserTypeOptions.map((x) => ({
30
+ value: x,
31
+ label: t(`qWeatherUserTypeOptions.${x}`),
32
+ }));
33
+ }, [t]);
34
+
35
+ const qWeatherTimePeriodOptions = useMemo(() => {
36
+ return QWeatherTimePeriodOptions.map((x) => ({
37
+ value: x,
38
+ label: t(`qWeatherTimePeriodOptions.${x}`),
39
+ }));
40
+ }, [t]);
41
+
42
+ return (
43
+ <Form
44
+ name="basic"
45
+ labelCol={{ span: 6 }}
46
+ wrapperCol={{ span: 18 }}
47
+ autoComplete="off"
48
+ form={form}
49
+ onValuesChange={onValuesChange}
50
+ >
51
+ <Form.Item label={t('webApiKey')} name={'web_apikey'}>
52
+ <Input></Input>
53
+ </Form.Item>
54
+ <Form.Item label={t('lang')} name={'lang'}>
55
+ <Select options={qWeatherLangOptions}></Select>
56
+ </Form.Item>
57
+ <Form.Item label={t('type')} name={'type'}>
58
+ <Select options={qWeatherTypeOptions}></Select>
59
+ </Form.Item>
60
+ <Form.Item label={t('userType')} name={'user_type'}>
61
+ <Select options={qWeatherUserTypeOptions}></Select>
62
+ </Form.Item>
63
+ <Form.Item noStyle dependencies={['type']}>
64
+ {({ getFieldValue }) =>
65
+ getFieldValue('type') === 'weather' && (
66
+ <Form.Item label={t('timePeriod')} name={'time_period'}>
67
+ <Select options={qWeatherTimePeriodOptions}></Select>
68
+ </Form.Item>
69
+ )
70
+ }
71
+ </Form.Item>
72
+ </Form>
73
+ );
74
+ };
75
+
76
+ export default QWeatherForm;