forked from infiniflow/ragflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add bing and google operator infiniflow#918 (infiniflow#1745)
### What problem does this PR solve? feat: Add bing and google operator infiniflow#918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
16 changed files
with
2,018 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import TopNItem from '@/components/top-n-item'; | ||
import { useTranslate } from '@/hooks/common-hooks'; | ||
import { Form, Input, Select } from 'antd'; | ||
import { useMemo } from 'react'; | ||
import { BingCountryOptions, BingLanguageOptions } from '../constant'; | ||
import { IOperatorForm } from '../interface'; | ||
|
||
const BingForm = ({ onValuesChange, form }: IOperatorForm) => { | ||
const { t } = useTranslate('flow'); | ||
|
||
const options = useMemo(() => { | ||
return ['Webpages', 'News'].map((x) => ({ label: x, value: x })); | ||
}, []); | ||
|
||
return ( | ||
<Form | ||
name="basic" | ||
labelCol={{ span: 6 }} | ||
wrapperCol={{ span: 18 }} | ||
autoComplete="off" | ||
form={form} | ||
onValuesChange={onValuesChange} | ||
> | ||
<TopNItem initialValue={10}></TopNItem> | ||
<Form.Item label={t('channel')} name={'channel'}> | ||
<Select options={options}></Select> | ||
</Form.Item> | ||
<Form.Item label={t('apiKey')} name={'api_key'}> | ||
<Input></Input> | ||
</Form.Item> | ||
<Form.Item label={t('country')} name={'country'}> | ||
<Select options={BingCountryOptions}></Select> | ||
</Form.Item> | ||
<Form.Item label={t('language')} name={'language'}> | ||
<Select options={BingLanguageOptions}></Select> | ||
</Form.Item> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default BingForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { useTranslate } from '@/hooks/common-hooks'; | ||
import { Flex } from 'antd'; | ||
import classNames from 'classnames'; | ||
import lowerFirst from 'lodash/lowerFirst'; | ||
import pick from 'lodash/pick'; | ||
import { Handle, NodeProps, Position } from 'reactflow'; | ||
import { Operator, operatorMap } from '../../constant'; | ||
import { NodeData } from '../../interface'; | ||
import OperatorIcon from '../../operator-icon'; | ||
import NodeDropdown from './dropdown'; | ||
import styles from './index.less'; | ||
import NodePopover from './popover'; | ||
|
||
const ZeroGapOperators = [ | ||
Operator.RewriteQuestion, | ||
Operator.KeywordExtract, | ||
Operator.ArXiv, | ||
]; | ||
|
||
export function LogicNode({ | ||
id, | ||
data, | ||
isConnectable = true, | ||
selected, | ||
}: NodeProps<NodeData>) { | ||
const style = operatorMap[data.label as Operator]; | ||
const { t } = useTranslate('flow'); | ||
|
||
return ( | ||
<NodePopover nodeId={id}> | ||
<section | ||
className={classNames(styles.logicNode, { | ||
[styles.selectedNode]: selected, | ||
})} | ||
style={pick(style, ['backgroundColor', 'width', 'height', 'color'])} | ||
> | ||
<Handle | ||
id="c" | ||
type="source" | ||
position={Position.Left} | ||
isConnectable={isConnectable} | ||
className={styles.handle} | ||
></Handle> | ||
<Handle type="source" position={Position.Top} id="d" isConnectable /> | ||
<Handle | ||
type="source" | ||
position={Position.Right} | ||
isConnectable={isConnectable} | ||
className={styles.handle} | ||
id="b" | ||
></Handle> | ||
<Handle type="source" position={Position.Bottom} id="a" isConnectable /> | ||
<Flex | ||
vertical | ||
align="center" | ||
justify={'space-around'} | ||
gap={ZeroGapOperators.some((x) => x === data.label) ? 0 : 6} | ||
> | ||
<Flex flex={1} justify="center" align="center"> | ||
<OperatorIcon | ||
name={data.label as Operator} | ||
fontSize={style?.iconFontSize ?? 24} | ||
width={style?.iconWidth} | ||
></OperatorIcon> | ||
</Flex> | ||
|
||
<Flex flex={1}> | ||
<span | ||
className={styles.type} | ||
style={{ fontSize: style?.fontSize ?? 14 }} | ||
> | ||
{t(lowerFirst(data.label))} | ||
</span> | ||
</Flex> | ||
<Flex flex={1}> | ||
<NodeDropdown | ||
id={id} | ||
iconFontColor={style?.moreIconColor} | ||
></NodeDropdown> | ||
</Flex> | ||
</Flex> | ||
|
||
<section className={styles.bottomBox}> | ||
<div className={styles.nodeName}>{data.name}</div> | ||
</section> | ||
</section> | ||
</NodePopover> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.