Feat: Migrate the code operator to the new agent. #3221 (#7731)

### What problem does this PR solve?

Feat: Migrate the code operator to the new agent. #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-05-20 15:30:56 +08:00
committed by GitHub
parent 1ae7b942d9
commit 796f4032b8
6 changed files with 188 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import { ReactComponent as TemplateIcon } from '@/assets/svg/template.svg';
import { ReactComponent as TuShareIcon } from '@/assets/svg/tushare.svg';
import { ReactComponent as WenCaiIcon } from '@/assets/svg/wencai.svg';
import { ReactComponent as YahooFinanceIcon } from '@/assets/svg/yahoo-finance.svg';
import { CodeTemplateStrMap, ProgrammingLanguage } from '@/constants/agent';
// 邮件功能
@ -56,6 +57,7 @@ import upperFirst from 'lodash/upperFirst';
import {
CirclePower,
CloudUpload,
CodeXml,
IterationCcw,
ListOrdered,
OptionIcon,
@ -103,6 +105,7 @@ export enum Operator {
Email = 'Email',
Iteration = 'Iteration',
IterationStart = 'IterationItem',
Code = 'Code',
}
export const CommonOperatorList = Object.values(Operator).filter(
@ -161,6 +164,7 @@ export const operatorIconMap = {
[Operator.Email]: EmailIcon,
[Operator.Iteration]: IterationCcw,
[Operator.IterationStart]: CirclePower,
[Operator.Code]: CodeXml,
};
export const operatorMap: Record<
@ -299,6 +303,7 @@ export const operatorMap: Record<
[Operator.Email]: { backgroundColor: '#e6f7ff' },
[Operator.Iteration]: { backgroundColor: '#e6f7ff' },
[Operator.IterationStart]: { backgroundColor: '#e6f7ff' },
[Operator.Code]: { backgroundColor: '#4c5458' },
};
export const componentMenuList = [
@ -336,6 +341,9 @@ export const componentMenuList = [
{
name: Operator.Iteration,
},
{
name: Operator.Code,
},
{
name: Operator.Note,
},
@ -645,6 +653,19 @@ export const initialIterationValues = {
};
export const initialIterationStartValues = {};
export const initialCodeValues = {
lang: 'python',
script: CodeTemplateStrMap[ProgrammingLanguage.Python],
arguments: [
{
name: 'arg1',
},
{
name: 'arg2',
},
],
};
export const CategorizeAnchorPointPositions = [
{ top: 1, right: 34 },
{ top: 8, right: 18 },
@ -726,6 +747,7 @@ export const RestrictedUpstreamMap = {
[Operator.Email]: [Operator.Begin],
[Operator.Iteration]: [Operator.Begin],
[Operator.IterationStart]: [Operator.Begin],
[Operator.Code]: [Operator.Begin],
};
export const NodeMap = {
@ -765,6 +787,7 @@ export const NodeMap = {
[Operator.Email]: 'emailNode',
[Operator.Iteration]: 'group',
[Operator.IterationStart]: 'iterationStartNode',
[Operator.Code]: 'ragNode',
};
export const LanguageOptions = [