Feature: Added global variable functionality #10703 (#11117)

### What problem does this PR solve?

Feature: Added global variable functionality

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
chanx
2025-11-10 10:16:12 +08:00
committed by GitHub
parent b6cd282ccd
commit 7423a5806e
10 changed files with 402 additions and 4 deletions

View File

@ -1,4 +1,6 @@
import {
DSL,
GobalVariableType,
IAgentForm,
ICategorizeForm,
ICategorizeItem,
@ -346,6 +348,28 @@ export const buildDslComponentsByGraph = (
return components;
};
export const buildDslGobalVariables = (
dsl: DSL,
gobalVariables?: Record<string, GobalVariableType>,
) => {
if (!gobalVariables) {
return { globals: dsl.globals, variables: dsl.variables || {} };
}
let gobalVariablesTemp = {};
Object.keys(gobalVariables).forEach((key) => {
gobalVariablesTemp = {
['env.' + key]: gobalVariables[key].value,
};
});
const gobalVariablesResult = {
...dsl.globals,
...gobalVariablesTemp,
};
return { globals: gobalVariablesResult, variables: gobalVariables };
};
export const receiveMessageError = (res: any) =>
res && (res?.response.status !== 200 || res?.data?.code !== 0);