ソースを参照

feat: Add component YahooFinance #1739 (#2561)

### What problem does this PR solve?

feat: Add component YahooFinance #1739

### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
tags/v0.12.0
balibabu 1年前
コミット
949a999478
コミッターのメールアドレスに関連付けられたアカウントが存在しません

+ 34
- 0
web/src/assets/svg/yahoo-finance.svg ファイルの表示

<?xml version="1.0" encoding="UTF-8"?>
<svg width="28px" height="28px" viewBox="0 0 28 28" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 57.1 (83088) - https://sketch.com -->
<title>favicon_y19_28x28_custom</title>
<desc>Created with Sketch.</desc>
<defs>
<polygon id="path-1"
points="0.171073913 0.0931111111 9.4455087 0.0931111111 9.4455087 9.92442222 0.171073913 9.92442222">
</polygon>
</defs>
<g id="favicon_y19_28x28_custom" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect fill="#6001D2" x="0" y="0" width="28" height="28"></rect>
<g id="y!" transform="translate(5.000000, 6.000000)">
<polygon id="Fill-1" fill="#FFFFFF"
points="9.70835927 5 7.04604411 11.4197051 4.40657437 5 0 5 4.91176421 16.0265583 3.14442407 20 7.45914574 20 14 5">
</polygon>
<g id="!" transform="translate(12.000000, 0.000000)">
<path
d="M2.88747609,10.8773778 C1.30283696,10.8773778 0.114280435,12.0684889 0.114280435,13.4547111 C0.114280435,14.8184889 1.25660652,15.9449333 2.79421522,15.9449333 C4.37917174,15.9449333 5.56741087,14.7756 5.56741087,13.3678222 C5.56741087,11.9818222 4.42580217,10.8773778 2.88747609,10.8773778"
id="Fill-2" fill="#FFFFFF"></path>
<g id="Group-6" transform="translate(1.434783, 0.000000)">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<g id="Clip-5"></g>
<polygon id="Fill-4" fill="#FFFFFF" mask="url(#mask-2)"
points="4.55194348 0.0930888889 0.171073913 9.92442222 5.06487826 9.92442222 9.4455087 0.0930888889">
</polygon>
</g>
</g>
</g>
</g>
</svg>

+ 6
- 0
web/src/locales/en.ts ファイルの表示

akShare: 'AkShare', akShare: 'AkShare',
akShareDescription: akShareDescription:
'This component can be used to obtain news information for the corresponding stock from the Eastmoney website.', 'This component can be used to obtain news information for the corresponding stock from the Eastmoney website.',
yahooFinance: 'YahooFinance',
info: 'Info',
history: 'History',
financials: 'Financials',
balanceSheet: 'Balance sheet',
cashFlowStatement: 'Cash flow statement',
}, },
footer: { footer: {
profile: 'All rights reserved @ React', profile: 'All rights reserved @ React',

+ 6
- 0
web/src/locales/zh-traditional.ts ファイルの表示

}, },
akShare: 'AkShare', akShare: 'AkShare',
akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。', akShareDescription: '此組件可用於從東方財富網取得對應股票的新聞資訊。',
yahooFinance: '雅虎財經',
info: '訊息',
history: '歷史',
financials: '財務',
balanceSheet: '資產負債表',
cashFlowStatement: '現金流量表',
}, },
footer: { footer: {
profile: '“保留所有權利 @ react”', profile: '“保留所有權利 @ react”',

+ 6
- 0
web/src/locales/zh.ts ファイルの表示

}, },
akShare: 'AkShare', akShare: 'AkShare',
akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。', akShareDescription: '该组件可用于从东方财富网站获取相应股票的新闻信息。',
yahooFinance: '雅虎财经',
info: '信息',
history: '历史',
financials: '财务',
balanceSheet: '资产负债表',
cashFlowStatement: '现金流量表',
}, },
footer: { footer: {
profile: 'All rights reserved @ React', profile: 'All rights reserved @ React',

+ 18
- 0
web/src/pages/flow/constant.tsx ファイルの表示

import { ReactComponent as SwitchIcon } from '@/assets/svg/switch.svg'; import { ReactComponent as SwitchIcon } from '@/assets/svg/switch.svg';
import { ReactComponent as WenCaiIcon } from '@/assets/svg/wencai.svg'; import { ReactComponent as WenCaiIcon } from '@/assets/svg/wencai.svg';
import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg'; import { ReactComponent as WikipediaIcon } from '@/assets/svg/wikipedia.svg';
import { ReactComponent as YahooFinanceIcon } from '@/assets/svg/yahoo-finance.svg';


import { variableEnabledFieldMap } from '@/constants/chat'; import { variableEnabledFieldMap } from '@/constants/chat';
import i18n from '@/locales/config'; import i18n from '@/locales/config';
Switch = 'Switch', Switch = 'Switch',
WenCai = 'WenCai', WenCai = 'WenCai',
AkShare = 'AkShare', AkShare = 'AkShare',
YahooFinance = 'YahooFinance',
} }


export const operatorIconMap = { export const operatorIconMap = {
[Operator.Switch]: SwitchIcon, [Operator.Switch]: SwitchIcon,
[Operator.WenCai]: WenCaiIcon, [Operator.WenCai]: WenCaiIcon,
[Operator.AkShare]: AkShareIcon, [Operator.AkShare]: AkShareIcon,
[Operator.YahooFinance]: YahooFinanceIcon,
}; };


export const operatorMap: Record< export const operatorMap: Record<
[Operator.Switch]: { backgroundColor: '#dbaff6' }, [Operator.Switch]: { backgroundColor: '#dbaff6' },
[Operator.WenCai]: { backgroundColor: '#faac5b' }, [Operator.WenCai]: { backgroundColor: '#faac5b' },
[Operator.AkShare]: { backgroundColor: '#8085f5' }, [Operator.AkShare]: { backgroundColor: '#8085f5' },
[Operator.YahooFinance]: { backgroundColor: '#b474ff' },
}; };


export const componentMenuList = [ export const componentMenuList = [
{ {
name: Operator.AkShare, name: Operator.AkShare,
}, },
{
name: Operator.YahooFinance,
},
]; ];


export const initialRetrievalValues = { export const initialRetrievalValues = {


export const initialAkShareValues = { top_n: 10 }; export const initialAkShareValues = { top_n: 10 };


export const initialYahooFinanceValues = {
info: true,
history: false,
financials: false,
balance_sheet: false,
cash_flow_statement: false,
news: true,
};

export const CategorizeAnchorPointPositions = [ export const CategorizeAnchorPointPositions = [
{ top: 1, right: 34 }, { top: 1, right: 34 },
{ top: 8, right: 18 }, { top: 8, right: 18 },
[Operator.Switch]: [Operator.Begin], [Operator.Switch]: [Operator.Begin],
[Operator.WenCai]: [Operator.Begin], [Operator.WenCai]: [Operator.Begin],
[Operator.AkShare]: [Operator.Begin], [Operator.AkShare]: [Operator.Begin],
[Operator.YahooFinance]: [Operator.Begin],
}; };


export const NodeMap = { export const NodeMap = {
[Operator.Switch]: 'categorizeNode', [Operator.Switch]: 'categorizeNode',
[Operator.WenCai]: 'ragNode', [Operator.WenCai]: 'ragNode',
[Operator.AkShare]: 'ragNode', [Operator.AkShare]: 'ragNode',
[Operator.YahooFinance]: 'ragNode',
}; };


export const LanguageOptions = [ export const LanguageOptions = [

+ 2
- 0
web/src/pages/flow/flow-drawer/index.tsx ファイルの表示

import WenCaiForm from '../wencai-form'; import WenCaiForm from '../wencai-form';
import WikipediaForm from '../wikipedia-form'; import WikipediaForm from '../wikipedia-form';


import YahooFinanceForm from '../yahoo-finance-form';
import styles from './index.less'; import styles from './index.less';


interface IProps { interface IProps {
[Operator.Switch]: SwitchForm, [Operator.Switch]: SwitchForm,
[Operator.WenCai]: WenCaiForm, [Operator.WenCai]: WenCaiForm,
[Operator.AkShare]: AkShareForm, [Operator.AkShare]: AkShareForm,
[Operator.YahooFinance]: YahooFinanceForm,
}; };


const EmptyContent = () => <div>empty</div>; const EmptyContent = () => <div>empty</div>;

+ 2
- 0
web/src/pages/flow/hooks.ts ファイルの表示

initialSwitchValues, initialSwitchValues,
initialWenCaiValues, initialWenCaiValues,
initialWikipediaValues, initialWikipediaValues,
initialYahooFinanceValues,
} from './constant'; } from './constant';
import { ICategorizeForm, IRelevantForm, ISwitchForm } from './interface'; import { ICategorizeForm, IRelevantForm, ISwitchForm } from './interface';
import useGraphStore, { RFState } from './store'; import useGraphStore, { RFState } from './store';
[Operator.Switch]: initialSwitchValues, [Operator.Switch]: initialSwitchValues,
[Operator.WenCai]: initialWenCaiValues, [Operator.WenCai]: initialWenCaiValues,
[Operator.AkShare]: initialAkShareValues, [Operator.AkShare]: initialAkShareValues,
[Operator.YahooFinance]: initialYahooFinanceValues,
}; };
}, [llmId]); }, [llmId]);



+ 39
- 0
web/src/pages/flow/yahoo-finance-form/index.tsx ファイルの表示

import { useTranslate } from '@/hooks/common-hooks';
import { Form, Switch } from 'antd';
import { IOperatorForm } from '../interface';

const YahooFinanceForm = ({ onValuesChange, form }: IOperatorForm) => {
const { t } = useTranslate('flow');

return (
<Form
name="basic"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}
autoComplete="off"
form={form}
onValuesChange={onValuesChange}
>
<Form.Item label={t('info')} name={'info'}>
<Switch></Switch>
</Form.Item>
<Form.Item label={t('history')} name={'history'}>
<Switch></Switch>
</Form.Item>
<Form.Item label={t('financials')} name={'financials'}>
<Switch></Switch>
</Form.Item>
<Form.Item label={t('balanceSheet')} name={'balance_sheet'}>
<Switch></Switch>
</Form.Item>
<Form.Item label={t('cashFlowStatement')} name={'cash_flow_statement'}>
<Switch></Switch>
</Form.Item>
<Form.Item label={t('news')} name={'news'}>
<Switch></Switch>
</Form.Item>
</Form>
);
};

export default YahooFinanceForm;

読み込み中…
キャンセル
保存