Skip to content

Commit

Permalink
feat: Add component QWeather infiniflow#1739 (infiniflow#1881)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

feat: Add component QWeather infiniflow#1739

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 authored Aug 9, 2024
1 parent 491a9b1 commit 66d2517
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/src/assets/svg/qweather.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions web/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,64 @@ The above is the content you need to summarize.`,
cht: 'Traditional Chinese',
vie: 'Vietnamese',
},
qWeather: 'QWeather',
qWeatherDescription:
'This component is used to get weather related information from https://www.qweather.com/. You can get weather, indices, air quality.',
lang: 'Language',
type: 'Type',
webApiKey: 'Web API key',
userType: 'User type',
timePeriod: 'Time period',
qWeatherLangOptions: {
zh: 'Simplified Chinese',
'zh-hant': 'Traditional Chinese',
en: 'English',
de: 'German',
es: 'Spanish',
fr: 'French',
it: 'Italian',
ja: 'Japanese',
ko: 'Korean',
ru: 'Russian',
hi: 'Hindi',
th: 'Thai',
ar: 'Arabic',
pt: 'Portuguese',
bn: 'Bengali',
ms: 'Malay',
nl: 'Dutch',
el: 'Greek',
la: 'Latin',
sv: 'Swedish',
id: 'Indonesian',
pl: 'Polish',
tr: 'Turkish',
cs: 'Czech',
et: 'Estonian',
vi: 'Vietnamese',
fil: 'Filipino',
fi: 'Finnish',
he: 'Hebrew',
is: 'Icelandic',
nb: 'Norwegian',
},
qWeatherTypeOptions: {
weather: 'Weather forecast',
indices: 'Weather life index',
airquality: 'Air quality',
},
qWeatherUserTypeOptions: {
free: 'Free subscriber',
paid: 'Paid subscriber',
},
qWeatherTimePeriodOptions: {
now: 'Now',
'3d': '3 days',
'7d': '7 days',
'10d': '10 days',
'15d': '12 days',
'30d': '30 days',
},
},
footer: {
profile: 'All rights reserved @ React',
Expand Down
58 changes: 58 additions & 0 deletions web/src/locales/zh-traditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,64 @@ export default {
cht: '繁體中文',
vie: '越南語',
},
qWeather: '和風天氣',
qWeatherDescription:
'此元件用於從 https://www.qweather.com/ 取得天氣相關資訊。您可以獲得天氣、指數、空氣品質。',
lang: '語言',
type: '類型',
webApiKey: 'Web API 密鑰',
userType: '使用者類型',
timePeriod: '時間段',
qWeatherLangOptions: {
zh: '簡體中文',
'zh-hant': '繁體中文',
en: '英文',
de: '德語',
es: '西班牙語',
fr: '法文',
it: '義大利語',
ja: '日文',
ko: '韓語',
ru: '俄文',
hi: '印地語',
th: '泰語',
ar: '阿拉伯語',
pt: '葡萄牙語',
bn: '孟加拉語',
ms: '馬來語',
nl: '荷蘭語',
el: '希臘文',
la: '拉丁文',
sv: '瑞典語',
id: '印尼語',
pl: '波蘭語',
tr: '土耳其語',
cs: '捷克語',
et: '愛沙尼亞語',
vi: '越南語',
fil: '菲律賓語',
fi: '芬蘭語',
he: '希伯來文',
is: '冰島語',
nb: '挪威語',
},
qWeatherTypeOptions: {
weather: '天氣預報',
indices: '天氣生活指數',
airquality: '空氣品質',
},
qWeatherUserTypeOptions: {
free: '免費訂閱用戶',
paid: '付費訂閱用戶',
},
qWeatherTimePeriodOptions: {
now: '現在',
'3d': '3天',
'7d': '7天',
'10d': '10天',
'15d': '12天',
'30d': '30天',
},
},
footer: {
profile: '“保留所有權利 @ react”',
Expand Down
58 changes: 58 additions & 0 deletions web/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,64 @@ export default {
cht: '繁体中文',
vie: '越南语',
},
qWeather: '和风天气',
qWeatherDescription:
'该组件用于从 https://www.qweather.com/ 获取天气相关信息。您可以获取天气、指数、空气质量。',
lang: '语言',
type: '类型',
webApiKey: 'Web API 密钥',
userType: '用户类型',
timePeriod: '时间段',
qWeatherLangOptions: {
zh: '简体中文',
'zh-hant': '繁体中文',
en: '英文',
de: '德语',
es: '西班牙语',
fr: '法语',
it: '意大利语',
ja: '日语',
ko: '韩语',
ru: '俄语',
hi: '印地语',
th: '泰语',
ar: '阿拉伯语',
pt: '葡萄牙语',
bn: '孟加拉语',
ms: '马来语',
nl: '荷兰语',
el: '希腊语',
la: '拉丁语',
sv: '瑞典语',
id: '印尼语',
pl: '波兰语',
tr: '土耳其语',
cs: '捷克语',
et: '爱沙尼亚语',
vi: '越南语',
fil: '菲律宾语',
fi: '芬兰语',
he: '希伯来语',
is: '冰岛语',
nb: '挪威语',
},
qWeatherTypeOptions: {
weather: '天气预报',
indices: '天气生活指数',
airquality: '空气质量',
},
qWeatherUserTypeOptions: {
free: '免费订阅用户',
paid: '付费订阅用户',
},
qWeatherTimePeriodOptions: {
now: '现在',
'3d': '3天',
'7d': '7天',
'10d': '10天',
'15d': '12天',
'30d': '30天',
},
},
footer: {
profile: 'All rights reserved @ React',
Expand Down
63 changes: 63 additions & 0 deletions web/src/pages/flow/constant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ReactComponent as GoogleScholarIcon } from '@/assets/svg/google-scholar
import { ReactComponent as GoogleIcon } from '@/assets/svg/google.svg';
import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
import { ReactComponent as PubMedIcon } from '@/assets/svg/pubmed.svg';
import { ReactComponent as QWeatherIcon } from '@/assets/svg/qweather.svg';
import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';

import { variableEnabledFieldMap } from '@/constants/chat';
Expand Down Expand Up @@ -52,6 +53,7 @@ export enum Operator {
DeepL = 'DeepL',
GitHub = 'GitHub',
BaiduFanyi = 'BaiduFanyi',
QWeather = 'QWeather',
}

export const operatorIconMap = {
Expand All @@ -75,6 +77,7 @@ export const operatorIconMap = {
[Operator.DeepL]: DeepLIcon,
[Operator.GitHub]: GithubIcon,
[Operator.BaiduFanyi]: baiduFanyiIcon,
[Operator.QWeather]: QWeatherIcon,
};

export const operatorMap = {
Expand Down Expand Up @@ -161,6 +164,7 @@ export const operatorMap = {
[Operator.DeepL]: {},
[Operator.GitHub]: {},
[Operator.BaiduFanyi]: {},
[Operator.QWeather]: {},
};

export const componentMenuList = [
Expand Down Expand Up @@ -221,6 +225,9 @@ export const componentMenuList = [
{
name: Operator.BaiduFanyi,
},
{
name: Operator.QWeather,
},
];

export const initialRetrievalValues = {
Expand Down Expand Up @@ -340,6 +347,13 @@ export const initialBaiduFanyiValues = {
trans_type: 'translate',
};

export const initialQWeatherValues = {
web_apikey: 'xxx',
type: 'weather',
user_type: 'free',
time_period: 'now',
};

export const CategorizeAnchorPointPositions = [
{ top: 1, right: 34 },
{ top: 8, right: 18 },
Expand Down Expand Up @@ -407,6 +421,7 @@ export const RestrictedUpstreamMap = {
[Operator.DeepL]: [Operator.Begin, Operator.Retrieval],
[Operator.GitHub]: [Operator.Begin, Operator.Retrieval],
[Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval],
[Operator.QWeather]: [Operator.Begin, Operator.Retrieval],
};

export const NodeMap = {
Expand All @@ -430,6 +445,7 @@ export const NodeMap = {
[Operator.DeepL]: 'ragNode',
[Operator.GitHub]: 'ragNode',
[Operator.BaiduFanyi]: 'ragNode',
[Operator.QWeather]: 'ragNode',
};

export const LanguageOptions = [
Expand Down Expand Up @@ -2513,3 +2529,50 @@ export const BaiduFanyiSourceLangOptions = [
'cht',
'vie',
];

export const QWeatherLangOptions = [
'zh',
'zh-hant',
'en',
'de',
'es',
'fr',
'it',
'ja',
'ko',
'ru',
'hi',
'th',
'ar',
'pt',
'bn',
'ms',
'nl',
'el',
'la',
'sv',
'id',
'pl',
'tr',
'cs',
'et',
'vi',
'fil',
'fi',
'he',
'is',
'nb',
];

export const QWeatherTypeOptions = ['weather', 'indices', 'airquality'];

export const QWeatherUserTypeOptions = ['free', 'paid'];

export const QWeatherTimePeriodOptions = [
'now',
'3d',
'7d',
'10d',
'15d',
'30d',
];
2 changes: 2 additions & 0 deletions web/src/pages/flow/flow-drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import KeywordExtractForm from '../keyword-extract-form';
import MessageForm from '../message-form';
import OperatorIcon from '../operator-icon';
import PubMedForm from '../pubmed-form';
import QWeatherForm from '../qweather-form';
import RelevantForm from '../relevant-form';
import RetrievalForm from '../retrieval-form';
import RewriteQuestionForm from '../rewrite-question-form';
Expand Down Expand Up @@ -54,6 +55,7 @@ const FormMap = {
[Operator.DeepL]: DeepLForm,
[Operator.GitHub]: GithubForm,
[Operator.BaiduFanyi]: BaiduFanyiForm,
[Operator.QWeather]: QWeatherForm,
};

const EmptyContent = () => <div>empty</div>;
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/flow/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
initialKeywordExtractValues,
initialMessageValues,
initialPubMedValues,
initialQWeatherValues,
initialRelevantValues,
initialRetrievalValues,
initialRewriteQuestionValues,
Expand Down Expand Up @@ -105,6 +106,7 @@ export const useInitializeOperatorParams = () => {
[Operator.DeepL]: initialDeepLValues,
[Operator.GitHub]: initialGithubValues,
[Operator.BaiduFanyi]: initialBaiduFanyiValues,
[Operator.QWeather]: initialQWeatherValues,
};
}, [llmId]);

Expand Down
Loading

0 comments on commit 66d2517

Please sign in to comment.