File size: 7,110 Bytes
ba19dbf b2b0160 8da11cb 457df3d 70b1cb8 8a7a5d9 8da11cb ed19e93 8da11cb 454aa85 8da11cb be99f83 70b1cb8 ed19e93 457df3d ba19dbf be99f83 13080d4 454aa85 70b1cb8 ed19e93 457df3d 8a7a5d9 ba19dbf 454aa85 ddd1aa2 b2b0160 f43283a b2b0160 f43283a 64b1da0 f43283a 8a7a5d9 ddd1aa2 454aa85 ddd1aa2 454aa85 ddd1aa2 454aa85 ddd1aa2 454aa85 70b1cb8 ed19e93 457df3d ba19dbf 8da11cb 13080d4 b2b0160 d944812 b2b0160 13080d4 d944812 13080d4 67a5f12 13080d4 67a5f12 13080d4 c939fd2 d944812 c939fd2 d944812 c939fd2 36669dc 457b4e6 ba19dbf b2b0160 ba19dbf b2b0160 ba19dbf b9ad0fd ba19dbf b9ad0fd 60dc256 457b4e6 ed19e93 64b1da0 457df3d 457b4e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
import { ReactComponent as DuckIcon } from '@/assets/svg/duck.svg';
import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
import { variableEnabledFieldMap } from '@/constants/chat';
import {
BranchesOutlined,
DatabaseOutlined,
FormOutlined,
MergeCellsOutlined,
MessageOutlined,
RocketOutlined,
SendOutlined,
SlidersOutlined,
} from '@ant-design/icons';
export enum Operator {
Begin = 'Begin',
Retrieval = 'Retrieval',
Generate = 'Generate',
Answer = 'Answer',
Categorize = 'Categorize',
Message = 'Message',
Relevant = 'Relevant',
RewriteQuestion = 'RewriteQuestion',
KeywordExtract = 'KeywordExtract',
Baidu = 'Baidu',
DuckDuckGo = 'DuckDuckGo',
}
export const operatorIconMap = {
[Operator.Retrieval]: RocketOutlined,
[Operator.Generate]: MergeCellsOutlined,
[Operator.Answer]: SendOutlined,
[Operator.Begin]: SlidersOutlined,
[Operator.Categorize]: DatabaseOutlined,
[Operator.Message]: MessageOutlined,
[Operator.Relevant]: BranchesOutlined,
[Operator.RewriteQuestion]: FormOutlined,
[Operator.KeywordExtract]: KeywordIcon,
[Operator.DuckDuckGo]: DuckIcon,
[Operator.Baidu]: BaiduIcon,
};
export const operatorMap = {
[Operator.Retrieval]: {
description: 'This is where the flow begin',
backgroundColor: '#cad6e0',
color: '#385974',
},
[Operator.Generate]: {
description: 'Generate description',
backgroundColor: '#ebd6d6',
width: 150,
height: 150,
fontSize: 20,
iconFontSize: 30,
color: '#996464',
},
[Operator.Answer]: {
description:
'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.',
backgroundColor: '#f4816d',
color: 'white',
},
[Operator.Begin]: {
description: 'Begin description',
backgroundColor: '#4f51d6',
},
[Operator.Categorize]: {
description: 'Categorize description',
backgroundColor: '#ffebcd',
color: '#cc8a26',
},
[Operator.Message]: {
description: 'Message description',
backgroundColor: '#c5ddc7',
color: 'green',
},
[Operator.Relevant]: {
description: 'BranchesOutlined description',
backgroundColor: '#9fd94d',
color: 'white',
width: 70,
height: 70,
fontSize: 12,
iconFontSize: 16,
},
[Operator.RewriteQuestion]: {
description: 'RewriteQuestion description',
backgroundColor: '#f8c7f8',
color: 'white',
width: 70,
height: 70,
fontSize: 12,
iconFontSize: 16,
},
};
export const componentMenuList = [
{
name: Operator.Retrieval,
description: operatorMap[Operator.Retrieval].description,
},
{
name: Operator.Generate,
description: operatorMap[Operator.Generate].description,
},
{
name: Operator.Answer,
description: operatorMap[Operator.Answer].description,
},
{
name: Operator.Categorize,
description: operatorMap[Operator.Categorize].description,
},
{
name: Operator.Message,
description: operatorMap[Operator.Message].description,
},
{
name: Operator.Relevant,
description: operatorMap[Operator.Relevant].description,
},
{
name: Operator.RewriteQuestion,
description: operatorMap[Operator.RewriteQuestion].description,
},
// {
// name: Operator.KeywordExtract,
// description: operatorMap[Operator.Message].description,
// },
// {
// name: Operator.DuckDuckGo,
// description: operatorMap[Operator.Relevant].description,
// },
// {
// name: Operator.Baidu,
// description: operatorMap[Operator.RewriteQuestion].description,
// },
];
export const initialRetrievalValues = {
similarity_threshold: 0.2,
keywords_similarity_weight: 0.3,
top_n: 8,
};
export const initialBeginValues = {
prologue: `Hi! I'm your assistant, what can I do for you?`,
};
export const variableCheckBoxFieldMap = Object.keys(
variableEnabledFieldMap,
).reduce<Record<string, boolean>>((pre, cur) => {
pre[cur] = true;
return pre;
}, {});
const initialLlmBaseValues = {
...variableCheckBoxFieldMap,
temperature: 0.1,
top_p: 0.3,
frequency_penalty: 0.7,
presence_penalty: 0.4,
max_tokens: 256,
};
export const initialGenerateValues = {
...initialLlmBaseValues,
prompt: `Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:
{input}
The above is the content you need to summarize.`,
cite: true,
parameters: [],
};
export const initialRewriteQuestionValues = {
...initialLlmBaseValues,
loop: 1,
};
export const initialRelevantValues = {
...initialLlmBaseValues,
};
export const initialCategorizeValues = {
...initialLlmBaseValues,
category_description: {},
};
export const initialMessageValues = {
messages: [],
};
export const initialFormValuesMap = {
[Operator.Begin]: initialBeginValues,
[Operator.Retrieval]: initialRetrievalValues,
[Operator.Generate]: initialGenerateValues,
[Operator.Answer]: {},
[Operator.Categorize]: initialCategorizeValues,
[Operator.Relevant]: initialRelevantValues,
[Operator.RewriteQuestion]: initialRewriteQuestionValues,
[Operator.Message]: initialMessageValues,
};
export const CategorizeAnchorPointPositions = [
{ top: 1, right: 34 },
{ top: 8, right: 18 },
{ top: 15, right: 10 },
{ top: 24, right: 4 },
{ top: 31, right: 1 },
{ top: 38, right: -2 },
{ top: 62, right: -2 }, //bottom
{ top: 71, right: 1 },
{ top: 79, right: 6 },
{ top: 86, right: 12 },
{ top: 91, right: 20 },
{ top: 98, right: 34 },
];
// key is the source of the edge, value is the target of the edge
// no connection lines are allowed between key and value
export const RestrictedUpstreamMap = {
[Operator.Begin]: [Operator.Relevant],
[Operator.Categorize]: [
Operator.Begin,
Operator.Categorize,
Operator.Answer,
Operator.Relevant,
],
[Operator.Answer]: [
Operator.Begin,
Operator.Answer,
Operator.Message,
Operator.Relevant,
],
[Operator.Retrieval]: [Operator.Begin, Operator.Retrieval],
[Operator.Generate]: [Operator.Begin, Operator.Relevant],
[Operator.Message]: [
Operator.Begin,
Operator.Message,
Operator.Generate,
Operator.Retrieval,
Operator.RewriteQuestion,
Operator.Categorize,
Operator.Relevant,
],
[Operator.Relevant]: [Operator.Begin, Operator.Answer, Operator.Relevant],
[Operator.RewriteQuestion]: [
Operator.Begin,
Operator.Message,
Operator.Generate,
Operator.RewriteQuestion,
Operator.Categorize,
Operator.Relevant,
],
[Operator.KeywordExtract]: [Operator.Begin],
[Operator.Baidu]: [Operator.Begin],
[Operator.DuckDuckGo]: [Operator.Begin],
};
export const NodeMap = {
[Operator.Begin]: 'beginNode',
[Operator.Categorize]: 'categorizeNode',
[Operator.Retrieval]: 'ragNode',
[Operator.Generate]: 'ragNode',
[Operator.Answer]: 'ragNode',
[Operator.Message]: 'ragNode',
[Operator.Relevant]: 'relevantNode',
[Operator.RewriteQuestion]: 'ragNode',
};
|