balibabu
commited on
Commit
·
b25a0c6
1
Parent(s):
4c076a1
feat: modify DuckDuckGo's style #918 (#1485)
Browse files### What problem does this PR solve?
feat: modify DuckDuckGo's style #918
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/locales/en.ts
CHANGED
@@ -598,7 +598,7 @@ The above is the content you need to summarize.`,
|
|
598 |
addItem: 'Add Item',
|
599 |
nameRequiredMsg: 'Name is required',
|
600 |
nameRepeatedMsg: 'The name cannot be repeated',
|
601 |
-
keywordExtract: '
|
602 |
keywordExtractDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
|
603 |
baidu: 'Baidu',
|
604 |
baiduDescription: `This component is used to get search result from www.baidu.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adopt.`,
|
|
|
598 |
addItem: 'Add Item',
|
599 |
nameRequiredMsg: 'Name is required',
|
600 |
nameRepeatedMsg: 'The name cannot be repeated',
|
601 |
+
keywordExtract: 'Keyword',
|
602 |
keywordExtractDescription: `This component is used to extract keywords from user's question. Top N specifies the number of keywords you need to extract.`,
|
603 |
baidu: 'Baidu',
|
604 |
baiduDescription: `This component is used to get search result from www.baidu.com. Typically, it performs as a supplement to knowledgebases. Top N specifies the number of search results you need to adopt.`,
|
web/src/pages/flow/canvas/node/index.tsx
CHANGED
@@ -11,6 +11,8 @@ import NodeDropdown from './dropdown';
|
|
11 |
import styles from './index.less';
|
12 |
import NodePopover from './popover';
|
13 |
|
|
|
|
|
14 |
export function RagNode({
|
15 |
id,
|
16 |
data,
|
@@ -47,20 +49,29 @@ export function RagNode({
|
|
47 |
<Flex
|
48 |
vertical
|
49 |
align="center"
|
50 |
-
justify={'
|
51 |
-
gap={
|
52 |
>
|
53 |
-
<
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</Flex>
|
65 |
|
66 |
<section className={styles.bottomBox}>
|
|
|
11 |
import styles from './index.less';
|
12 |
import NodePopover from './popover';
|
13 |
|
14 |
+
const ZeroGapOperators = [Operator.RewriteQuestion, Operator.KeywordExtract];
|
15 |
+
|
16 |
export function RagNode({
|
17 |
id,
|
18 |
data,
|
|
|
49 |
<Flex
|
50 |
vertical
|
51 |
align="center"
|
52 |
+
justify={'space-around'}
|
53 |
+
gap={ZeroGapOperators.some((x) => x === data.label) ? 0 : 6}
|
54 |
>
|
55 |
+
<Flex flex={1} justify="center" align="center">
|
56 |
+
<OperatorIcon
|
57 |
+
name={data.label as Operator}
|
58 |
+
fontSize={style?.iconFontSize ?? 24}
|
59 |
+
width={style?.iconWidth}
|
60 |
+
></OperatorIcon>
|
61 |
+
</Flex>
|
62 |
+
|
63 |
+
<Flex flex={1}>
|
64 |
+
<span
|
65 |
+
className={styles.type}
|
66 |
+
style={{ fontSize: style?.fontSize ?? 14 }}
|
67 |
+
>
|
68 |
+
{t(lowerFirst(data.label))}
|
69 |
+
</span>
|
70 |
+
</Flex>
|
71 |
+
<Flex flex={1}>
|
72 |
+
{' '}
|
73 |
+
<NodeDropdown id={id}></NodeDropdown>
|
74 |
+
</Flex>
|
75 |
</Flex>
|
76 |
|
77 |
<section className={styles.bottomBox}>
|
web/src/pages/flow/canvas/node/relevant-node.tsx
CHANGED
@@ -47,18 +47,24 @@ export function RelevantNode({ id, data, selected }: NodeProps<NodeData>) {
|
|
47 |
></Handle>
|
48 |
<CategorizeHandle top={20} right={6} text={'yes'}></CategorizeHandle>
|
49 |
<CategorizeHandle top={80} right={6} text={'no'}></CategorizeHandle>
|
50 |
-
<Flex vertical align="center" justify="center">
|
51 |
-
<
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
</Flex>
|
63 |
<section className={styles.bottomBox}>
|
64 |
<div className={styles.nodeName}>{data.name}</div>
|
|
|
47 |
></Handle>
|
48 |
<CategorizeHandle top={20} right={6} text={'yes'}></CategorizeHandle>
|
49 |
<CategorizeHandle top={80} right={6} text={'no'}></CategorizeHandle>
|
50 |
+
<Flex vertical align="center" justify="center" gap={0}>
|
51 |
+
<Flex flex={1}>
|
52 |
+
<OperatorIcon
|
53 |
+
name={data.label as Operator}
|
54 |
+
fontSize={style.iconFontSize}
|
55 |
+
></OperatorIcon>
|
56 |
+
</Flex>
|
57 |
+
<Flex flex={1}>
|
58 |
+
<span
|
59 |
+
className={styles.type}
|
60 |
+
style={{ fontSize: style.fontSize ?? 14 }}
|
61 |
+
>
|
62 |
+
{t(lowerFirst(data.label))}
|
63 |
+
</span>
|
64 |
+
</Flex>
|
65 |
+
<Flex flex={1}>
|
66 |
+
<NodeDropdown id={id}></NodeDropdown>
|
67 |
+
</Flex>
|
68 |
</Flex>
|
69 |
<section className={styles.bottomBox}>
|
70 |
<div className={styles.nodeName}>{data.name}</div>
|
web/src/pages/flow/constant.tsx
CHANGED
@@ -43,12 +43,10 @@ export const operatorIconMap = {
|
|
43 |
|
44 |
export const operatorMap = {
|
45 |
[Operator.Retrieval]: {
|
46 |
-
description: 'This is where the flow begin',
|
47 |
backgroundColor: '#cad6e0',
|
48 |
color: '#385974',
|
49 |
},
|
50 |
[Operator.Generate]: {
|
51 |
-
description: 'Generate description',
|
52 |
backgroundColor: '#ebd6d6',
|
53 |
width: 150,
|
54 |
height: 150,
|
@@ -57,27 +55,21 @@ export const operatorMap = {
|
|
57 |
color: '#996464',
|
58 |
},
|
59 |
[Operator.Answer]: {
|
60 |
-
description:
|
61 |
-
'This component is used as an interface between bot and human. It receives input of user and display the result of the computation of the bot.',
|
62 |
backgroundColor: '#f4816d',
|
63 |
color: 'white',
|
64 |
},
|
65 |
[Operator.Begin]: {
|
66 |
-
description: 'Begin description',
|
67 |
backgroundColor: '#4f51d6',
|
68 |
},
|
69 |
[Operator.Categorize]: {
|
70 |
-
description: 'Categorize description',
|
71 |
backgroundColor: '#ffebcd',
|
72 |
color: '#cc8a26',
|
73 |
},
|
74 |
[Operator.Message]: {
|
75 |
-
description: 'Message description',
|
76 |
backgroundColor: '#c5ddc7',
|
77 |
color: 'green',
|
78 |
},
|
79 |
[Operator.Relevant]: {
|
80 |
-
description: 'BranchesOutlined description',
|
81 |
backgroundColor: '#9fd94d',
|
82 |
color: 'white',
|
83 |
width: 70,
|
@@ -86,7 +78,6 @@ export const operatorMap = {
|
|
86 |
iconFontSize: 16,
|
87 |
},
|
88 |
[Operator.RewriteQuestion]: {
|
89 |
-
description: 'RewriteQuestion description',
|
90 |
backgroundColor: '#f8c7f8',
|
91 |
color: 'white',
|
92 |
width: 70,
|
@@ -94,48 +85,52 @@ export const operatorMap = {
|
|
94 |
fontSize: 12,
|
95 |
iconFontSize: 16,
|
96 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
};
|
98 |
|
99 |
export const componentMenuList = [
|
100 |
{
|
101 |
name: Operator.Retrieval,
|
102 |
-
description: operatorMap[Operator.Retrieval].description,
|
103 |
},
|
104 |
{
|
105 |
name: Operator.Generate,
|
106 |
-
description: operatorMap[Operator.Generate].description,
|
107 |
},
|
108 |
{
|
109 |
name: Operator.Answer,
|
110 |
-
description: operatorMap[Operator.Answer].description,
|
111 |
},
|
112 |
{
|
113 |
name: Operator.Categorize,
|
114 |
-
description: operatorMap[Operator.Categorize].description,
|
115 |
},
|
116 |
{
|
117 |
name: Operator.Message,
|
118 |
-
description: operatorMap[Operator.Message].description,
|
119 |
},
|
120 |
{
|
121 |
name: Operator.Relevant,
|
122 |
-
description: operatorMap[Operator.Relevant].description,
|
123 |
},
|
124 |
{
|
125 |
name: Operator.RewriteQuestion,
|
126 |
-
description: operatorMap[Operator.RewriteQuestion].description,
|
127 |
},
|
128 |
{
|
129 |
name: Operator.KeywordExtract,
|
130 |
-
description: operatorMap[Operator.Message].description,
|
131 |
},
|
132 |
{
|
133 |
name: Operator.DuckDuckGo,
|
134 |
-
description: operatorMap[Operator.Relevant].description,
|
135 |
},
|
136 |
{
|
137 |
name: Operator.Baidu,
|
138 |
-
description: operatorMap[Operator.RewriteQuestion].description,
|
139 |
},
|
140 |
];
|
141 |
|
@@ -254,9 +249,13 @@ export const RestrictedUpstreamMap = {
|
|
254 |
Operator.Categorize,
|
255 |
Operator.Relevant,
|
256 |
],
|
257 |
-
[Operator.KeywordExtract]: [
|
258 |
-
|
259 |
-
|
|
|
|
|
|
|
|
|
260 |
};
|
261 |
|
262 |
export const NodeMap = {
|
@@ -268,4 +267,7 @@ export const NodeMap = {
|
|
268 |
[Operator.Message]: 'ragNode',
|
269 |
[Operator.Relevant]: 'relevantNode',
|
270 |
[Operator.RewriteQuestion]: 'ragNode',
|
|
|
|
|
|
|
271 |
};
|
|
|
43 |
|
44 |
export const operatorMap = {
|
45 |
[Operator.Retrieval]: {
|
|
|
46 |
backgroundColor: '#cad6e0',
|
47 |
color: '#385974',
|
48 |
},
|
49 |
[Operator.Generate]: {
|
|
|
50 |
backgroundColor: '#ebd6d6',
|
51 |
width: 150,
|
52 |
height: 150,
|
|
|
55 |
color: '#996464',
|
56 |
},
|
57 |
[Operator.Answer]: {
|
|
|
|
|
58 |
backgroundColor: '#f4816d',
|
59 |
color: 'white',
|
60 |
},
|
61 |
[Operator.Begin]: {
|
|
|
62 |
backgroundColor: '#4f51d6',
|
63 |
},
|
64 |
[Operator.Categorize]: {
|
|
|
65 |
backgroundColor: '#ffebcd',
|
66 |
color: '#cc8a26',
|
67 |
},
|
68 |
[Operator.Message]: {
|
|
|
69 |
backgroundColor: '#c5ddc7',
|
70 |
color: 'green',
|
71 |
},
|
72 |
[Operator.Relevant]: {
|
|
|
73 |
backgroundColor: '#9fd94d',
|
74 |
color: 'white',
|
75 |
width: 70,
|
|
|
78 |
iconFontSize: 16,
|
79 |
},
|
80 |
[Operator.RewriteQuestion]: {
|
|
|
81 |
backgroundColor: '#f8c7f8',
|
82 |
color: 'white',
|
83 |
width: 70,
|
|
|
85 |
fontSize: 12,
|
86 |
iconFontSize: 16,
|
87 |
},
|
88 |
+
[Operator.KeywordExtract]: {
|
89 |
+
width: 70,
|
90 |
+
height: 70,
|
91 |
+
backgroundColor: '#0f0e0f',
|
92 |
+
color: '#e1dcdc',
|
93 |
+
fontSize: 12,
|
94 |
+
iconWidth: 16,
|
95 |
+
// iconFontSize: 16,
|
96 |
+
},
|
97 |
+
[Operator.DuckDuckGo]: {
|
98 |
+
backgroundColor: '#e7e389',
|
99 |
+
color: '#aea00c',
|
100 |
+
},
|
101 |
+
[Operator.Baidu]: {},
|
102 |
};
|
103 |
|
104 |
export const componentMenuList = [
|
105 |
{
|
106 |
name: Operator.Retrieval,
|
|
|
107 |
},
|
108 |
{
|
109 |
name: Operator.Generate,
|
|
|
110 |
},
|
111 |
{
|
112 |
name: Operator.Answer,
|
|
|
113 |
},
|
114 |
{
|
115 |
name: Operator.Categorize,
|
|
|
116 |
},
|
117 |
{
|
118 |
name: Operator.Message,
|
|
|
119 |
},
|
120 |
{
|
121 |
name: Operator.Relevant,
|
|
|
122 |
},
|
123 |
{
|
124 |
name: Operator.RewriteQuestion,
|
|
|
125 |
},
|
126 |
{
|
127 |
name: Operator.KeywordExtract,
|
|
|
128 |
},
|
129 |
{
|
130 |
name: Operator.DuckDuckGo,
|
|
|
131 |
},
|
132 |
{
|
133 |
name: Operator.Baidu,
|
|
|
134 |
},
|
135 |
];
|
136 |
|
|
|
249 |
Operator.Categorize,
|
250 |
Operator.Relevant,
|
251 |
],
|
252 |
+
[Operator.KeywordExtract]: [
|
253 |
+
Operator.Begin,
|
254 |
+
Operator.Message,
|
255 |
+
Operator.Relevant,
|
256 |
+
],
|
257 |
+
[Operator.Baidu]: [Operator.Begin, Operator.Retrieval],
|
258 |
+
[Operator.DuckDuckGo]: [Operator.Begin, Operator.Retrieval],
|
259 |
};
|
260 |
|
261 |
export const NodeMap = {
|
|
|
267 |
[Operator.Message]: 'ragNode',
|
268 |
[Operator.Relevant]: 'relevantNode',
|
269 |
[Operator.RewriteQuestion]: 'ragNode',
|
270 |
+
[Operator.KeywordExtract]: 'ragNode',
|
271 |
+
[Operator.DuckDuckGo]: 'ragNode',
|
272 |
+
[Operator.Baidu]: 'ragNode',
|
273 |
};
|
web/src/pages/flow/operator-icon/index.tsx
CHANGED
@@ -6,11 +6,14 @@ import styles from './index.less';
|
|
6 |
interface IProps {
|
7 |
name: Operator;
|
8 |
fontSize?: number;
|
|
|
9 |
}
|
10 |
|
11 |
-
const OperatorIcon = ({ name, fontSize }: IProps) => {
|
12 |
const Icon = operatorIconMap[name] || React.Fragment;
|
13 |
-
return
|
|
|
|
|
14 |
};
|
15 |
|
16 |
export default OperatorIcon;
|
|
|
6 |
interface IProps {
|
7 |
name: Operator;
|
8 |
fontSize?: number;
|
9 |
+
width?: number;
|
10 |
}
|
11 |
|
12 |
+
const OperatorIcon = ({ name, fontSize, width }: IProps) => {
|
13 |
const Icon = operatorIconMap[name] || React.Fragment;
|
14 |
+
return (
|
15 |
+
<Icon className={styles.icon} style={{ fontSize }} width={width}></Icon>
|
16 |
+
);
|
17 |
};
|
18 |
|
19 |
export default OperatorIcon;
|