Feat: Add the JS code (or other) executor component to Agent. #4977 (#7677)

### What problem does this PR solve?

Feat: Add the JS code (or other) executor component to Agent. #4977

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-05-16 09:53:00 +08:00
committed by GitHub
parent 772992812a
commit 008e55a65e
14 changed files with 293 additions and 7 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,
Database,
IterationCcw,
ListOrdered,
@ -104,6 +106,7 @@ export enum Operator {
Email = 'Email',
Iteration = 'Iteration',
IterationStart = 'IterationItem',
Code = 'Code',
}
export const CommonOperatorList = Object.values(Operator).filter(
@ -147,6 +150,7 @@ export const operatorIconMap = {
[Operator.Email]: EmailIcon,
[Operator.Iteration]: IterationCcw,
[Operator.IterationStart]: CirclePower,
[Operator.Code]: CodeXml,
};
export const operatorMap: Record<
@ -285,6 +289,7 @@ export const operatorMap: Record<
[Operator.Email]: { backgroundColor: '#e6f7ff' },
[Operator.Iteration]: { backgroundColor: '#e6f7ff' },
[Operator.IterationStart]: { backgroundColor: '#e6f7ff' },
[Operator.Code]: { backgroundColor: '#4c5458' },
};
export const componentMenuList = [
@ -322,6 +327,9 @@ export const componentMenuList = [
{
name: Operator.Iteration,
},
{
name: Operator.Code,
},
{
name: Operator.Note,
},
@ -633,6 +641,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 },
@ -714,6 +735,7 @@ export const RestrictedUpstreamMap = {
[Operator.Email]: [Operator.Begin],
[Operator.Iteration]: [Operator.Begin],
[Operator.IterationStart]: [Operator.Begin],
[Operator.Code]: [Operator.Begin],
};
export const NodeMap = {
@ -753,6 +775,7 @@ export const NodeMap = {
[Operator.Email]: 'emailNode',
[Operator.Iteration]: 'group',
[Operator.IterationStart]: 'iterationStartNode',
[Operator.Code]: 'ragNode',
};
export const LanguageOptions = [