chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -22,10 +22,10 @@ export const concatTestId = (...testIds: string[]) =>
|
||||
testIds.filter(id => !!id).join('.');
|
||||
|
||||
/**
|
||||
* 生成节点的测试id
|
||||
* Generate the test ID of the node.
|
||||
* @example concatNodeTestId(node, 'right-panel') => playground.node.100001.right-panel
|
||||
* @param node 节点
|
||||
* @param testIds 其它id
|
||||
* @param node
|
||||
* @param testIds other id
|
||||
* @returns
|
||||
*/
|
||||
export const concatNodeTestId = (node: FlowNodeEntity, ...testIds: string[]) =>
|
||||
|
||||
@@ -20,7 +20,7 @@ import { FlowNodeFormData } from '@flowgram-adapter/free-layout-editor';
|
||||
import { type FlowNodeEntity } from '@flowgram-adapter/free-layout-editor';
|
||||
|
||||
/**
|
||||
* 找到以 pathEnds 为结尾的 FormItem,并获取它的值
|
||||
* Find the FormItem ending in pathEnds and get its value
|
||||
* @param node
|
||||
* @param pathEnds
|
||||
* @returns
|
||||
@@ -76,12 +76,12 @@ const findValueByPathEnds = <T = unknown>(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// 检查当前路径是否以 pathEnds 结尾
|
||||
// Check if the current path ends with pathEnds
|
||||
if (currentPath.endsWith(pathEnds)) {
|
||||
return obj as T;
|
||||
}
|
||||
|
||||
// 处理对象
|
||||
// processing object
|
||||
if (typeof obj === 'object' && !Array.isArray(obj)) {
|
||||
for (const key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
@@ -91,7 +91,7 @@ const findValueByPathEnds = <T = unknown>(
|
||||
return obj[key] as T;
|
||||
}
|
||||
|
||||
// 递归查找子对象
|
||||
// recursive search for child objects
|
||||
const result = findValueByPathEnds(obj[key], pathEnds, newPath);
|
||||
if (result !== undefined) {
|
||||
return result as T;
|
||||
@@ -100,7 +100,7 @@ const findValueByPathEnds = <T = unknown>(
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数组
|
||||
// Processing Array
|
||||
if (Array.isArray(obj)) {
|
||||
for (let i = 0; i < obj.length; i++) {
|
||||
const newPath = `${currentPath}/${i}`;
|
||||
@@ -109,7 +109,7 @@ const findValueByPathEnds = <T = unknown>(
|
||||
return obj[i] as T;
|
||||
}
|
||||
|
||||
// 递归查找数组元素
|
||||
// Recursive lookup of array elements
|
||||
const result = findValueByPathEnds(obj[i], pathEnds, newPath);
|
||||
if (result !== undefined) {
|
||||
return result as T;
|
||||
|
||||
@@ -18,7 +18,7 @@ import { WorkflowMode } from '@coze-arch/bot-api/workflow_api';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param flowMode 是否广义上的 workflow,包含原来的 Workflow 和 Coze 2.0 新增的 Chatflow
|
||||
* @Param flowMode Whether it is a workflow in a broad sense, including the original Workflow and the Chatflow added by Coze 2.0
|
||||
* @returns
|
||||
*/
|
||||
export const isGeneralWorkflow = (flowMode: WorkflowMode) =>
|
||||
|
||||
@@ -91,14 +91,14 @@ const parseData = (
|
||||
nodeSchema?.type === StandardNodeType.Text &&
|
||||
isString(rawOutput) &&
|
||||
rawOutput?.length > 0;
|
||||
// 文本节点的 raw_out 不需要反序列化,一定是 string,badcase:用户拼接的 json 字符串如 '{}'、'123',反序列化后会变成object 和 number
|
||||
// The raw_out of the text node does not need to be deserialized, it must be a string, badcase: the json string spliced by the user such as '{}'、' 123 'will become object and number after deserialization
|
||||
const rawOutputData = textHasRawout
|
||||
? rawOutput?.toString?.()
|
||||
: rawOutput
|
||||
? typeSafeJSONParse(rawOutput) || rawOutput?.toString?.()
|
||||
: undefined;
|
||||
|
||||
/** Code、Llm 节点需要展示 raw */
|
||||
/** Code, Llm nodes need to display raw */
|
||||
const hasRawOutput =
|
||||
(Boolean(nodeSchema?.type) &&
|
||||
[
|
||||
@@ -107,7 +107,7 @@ const parseData = (
|
||||
StandardNodeType.Question,
|
||||
].includes(nodeSchema?.type as StandardNodeType)) ||
|
||||
textHasRawout;
|
||||
// Start、Input 节点只展示输入
|
||||
// Start and Input nodes only display input
|
||||
const hasOutput =
|
||||
nodeSchema?.type !== StandardNodeType.Start &&
|
||||
nodeSchema?.type !== StandardNodeType.Input;
|
||||
@@ -151,7 +151,7 @@ const parseData = (
|
||||
return {
|
||||
dataList,
|
||||
imgList: parseImagesFromOutputData({
|
||||
// batch data 的 output 下钻了一层,需要再包一层和 output 的 schema 保持一致
|
||||
// The output of batch data is drilled down one layer, and another layer needs to be wrapped to be consistent with the schema of the output.
|
||||
outputData: isBatch
|
||||
? {
|
||||
outputList: [typeSafeJSONParse(outputJsonString)].filter(Boolean),
|
||||
|
||||
@@ -69,10 +69,10 @@ function getImgList(data: unknown, schema: Schema): string[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从节点 output data 中解析图片链接
|
||||
* @param outputData 节点输出数据 JSON 序列化后的字符串
|
||||
* @param nodeSchema 节点 schema
|
||||
* @param excludeNodeTypes 不解析该类型节点的图片链接
|
||||
* Parse image links from node output data
|
||||
* @Param outputData node output data JSON serialized string
|
||||
* @param nodeSchema
|
||||
* @Param excludeNodeTypes does not resolve image links for nodes of this type
|
||||
*/
|
||||
export function parseImagesFromOutputData({
|
||||
outputData,
|
||||
|
||||
@@ -69,10 +69,10 @@ it('extract schema with dataset param parser', () => {
|
||||
],
|
||||
});
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
// knowledge 知识库节点 6
|
||||
// Knowledge Base Node 6
|
||||
[StandardNodeType.Dataset]: [
|
||||
{
|
||||
// 对应知识库名称
|
||||
// Corresponding knowledge base name
|
||||
name: 'datasetParam',
|
||||
path: 'inputs.datasetParam',
|
||||
parser: SchemaExtractorParserName.DATASET_PARAM,
|
||||
|
||||
@@ -41,10 +41,10 @@ it('extract schema with default parser', () => {
|
||||
],
|
||||
});
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
// end 结束节点 2
|
||||
// End End Node 2
|
||||
[StandardNodeType.End]: [
|
||||
{
|
||||
// 对应输出指定内容
|
||||
// Corresponding output specified content
|
||||
name: 'content',
|
||||
path: 'inputs.content.value.content',
|
||||
},
|
||||
|
||||
@@ -73,10 +73,10 @@ it('extract schema with inputParameters parser', () => {
|
||||
],
|
||||
});
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
// llm 大模型节点 3
|
||||
// LLM Large Model Node 3
|
||||
[StandardNodeType.LLM]: [
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
|
||||
@@ -94,10 +94,10 @@ it('extract schema with intents param parser', () => {
|
||||
],
|
||||
});
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
// end 结束节点 2
|
||||
// End End Node 2
|
||||
[StandardNodeType.Intent]: [
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
|
||||
@@ -38,10 +38,10 @@ it('extract schema with json string parser', () => {
|
||||
],
|
||||
});
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
// end 结束节点 2
|
||||
// End End Node 2
|
||||
[StandardNodeType.SceneChat]: [
|
||||
{
|
||||
// 对应输出指定内容
|
||||
// Corresponding output specified content
|
||||
name: 'messages',
|
||||
path: 'inputs.Messages',
|
||||
parser: SchemaExtractorParserName.JSON_STRING_PARSER,
|
||||
|
||||
@@ -61,10 +61,10 @@ it('extract schema with outputs parser', () => {
|
||||
],
|
||||
});
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
// code 代码节点 5
|
||||
// Code Code Node 5
|
||||
[StandardNodeType.Code]: [
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
|
||||
@@ -125,7 +125,7 @@ it('extract schema with variableAssign parser', () => {
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
[StandardNodeType.SetVariable]: [
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.VARIABLE_ASSIGN,
|
||||
@@ -165,7 +165,7 @@ it('variableAssign parser with empty inputParameters', () => {
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
[StandardNodeType.SetVariable]: [
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.VARIABLE_ASSIGN,
|
||||
@@ -253,7 +253,7 @@ it('variableAssign parser with invalid schema', () => {
|
||||
const extractedSchema = schemaExtractor.extract({
|
||||
[StandardNodeType.SetVariable]: [
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.VARIABLE_ASSIGN,
|
||||
|
||||
@@ -20,10 +20,10 @@ import { SchemaExtractorParserName } from '../../constant';
|
||||
import { StandardNodeType } from '../../../../types';
|
||||
|
||||
export const imageflowExtractorConfig: SchemaExtractorConfig = {
|
||||
// api 节点 4
|
||||
// API Node 4
|
||||
[StandardNodeType.Api]: [
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
|
||||
@@ -19,211 +19,211 @@ import { SchemaExtractorParserName } from '../../constant';
|
||||
import { StandardNodeType } from '../../../../types';
|
||||
|
||||
export const workflowExtractorConfig: SchemaExtractorConfig = {
|
||||
// Start 开始节点 1
|
||||
// Start Start Node 1
|
||||
[StandardNodeType.Start]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应 input name / description
|
||||
// Corresponding input name/description
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// End 结束节点 2
|
||||
// End End Node 2
|
||||
[StandardNodeType.End]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应输出指定内容
|
||||
// Corresponding output specified content
|
||||
name: 'content',
|
||||
path: 'inputs.content.value.content',
|
||||
},
|
||||
],
|
||||
// LLM 大模型节点 3
|
||||
// LLM Large Model Node 3
|
||||
[StandardNodeType.LLM]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应batch value / batch description
|
||||
// Corresponding batch value/batch description
|
||||
name: 'batch',
|
||||
path: 'inputs.batch.inputLists',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应提示词
|
||||
// Cue word
|
||||
name: 'llmParam',
|
||||
path: 'inputs.llmParam',
|
||||
parser: SchemaExtractorParserName.LLM_PARAM,
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Plugin 节点 4
|
||||
// Plugin Node 4
|
||||
[StandardNodeType.Api]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应batch value / batch description
|
||||
// Corresponding batch value/batch description
|
||||
name: 'batch',
|
||||
path: 'inputs.batch.inputLists',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应input value / input description
|
||||
// Corresponding input value/input description
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Code 代码节点 5
|
||||
// Code Node 5
|
||||
[StandardNodeType.Code]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input value / input description
|
||||
// Corresponding input value/input description
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应code内容
|
||||
// Corresponding code content
|
||||
name: 'code',
|
||||
path: 'inputs.code',
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Knowledge 知识库节点 6
|
||||
// Knowledge Base Node 6
|
||||
[StandardNodeType.Dataset]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应知识库名称
|
||||
// Corresponding knowledge base name
|
||||
name: 'datasetParam',
|
||||
path: 'inputs.datasetParam',
|
||||
parser: SchemaExtractorParserName.DATASET_PARAM,
|
||||
},
|
||||
],
|
||||
// If 判断节点 8
|
||||
// If the decision node 8
|
||||
[StandardNodeType.If]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'branches',
|
||||
path: 'inputs.branches',
|
||||
parser: SchemaExtractorParserName.DEFAULT,
|
||||
},
|
||||
],
|
||||
// Sub Workflow 工作流节点 9
|
||||
// Sub Workflow Node 9
|
||||
[StandardNodeType.SubWorkflow]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应batch value / batch description
|
||||
// Corresponding batch value/batch description
|
||||
name: 'batch',
|
||||
path: 'inputs.batch.inputLists',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应input value / input description
|
||||
// Corresponding input value/input description
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Variable 变量节点 11
|
||||
// Variable Node 11
|
||||
[StandardNodeType.Variable]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Database 数据库节点 12
|
||||
// Database Node 12
|
||||
[StandardNodeType.Database]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
@@ -234,21 +234,21 @@ export const workflowExtractorConfig: SchemaExtractorConfig = {
|
||||
path: 'inputs.sql',
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Message 消息节点 13
|
||||
// Message Node 13
|
||||
[StandardNodeType.Output]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
@@ -259,78 +259,78 @@ export const workflowExtractorConfig: SchemaExtractorConfig = {
|
||||
path: 'inputs.content.value.content',
|
||||
},
|
||||
],
|
||||
// Sub Imageflow 图像流节点 14
|
||||
// Sub ImageFlow Node 14
|
||||
[StandardNodeType.Imageflow]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应batch value / batch description
|
||||
// Corresponding batch value/batch description
|
||||
name: 'batch',
|
||||
path: 'inputs.batch.inputLists',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应input value / input description
|
||||
// Corresponding input value/input description
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Text 文本处理节点 15
|
||||
// Text processing node 15
|
||||
[StandardNodeType.Text]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 拼接结果,以及拼接字符串
|
||||
// Splicing results, and splicing strings
|
||||
name: 'concatResult',
|
||||
path: 'inputs.concatParams',
|
||||
parser: SchemaExtractorParserName.CONCAT_RESULT,
|
||||
},
|
||||
{
|
||||
// 自定义数组拼接符号
|
||||
// Custom array stitching symbols
|
||||
name: 'arrayConcatChar',
|
||||
path: 'inputs.concatParams',
|
||||
parser: SchemaExtractorParserName.CUSTOM_ARRAY_CONCAT_CHAR,
|
||||
},
|
||||
{
|
||||
// 自定义分隔符
|
||||
// custom separator
|
||||
name: 'splitChar',
|
||||
path: 'inputs.splitParams',
|
||||
parser: SchemaExtractorParserName.CUSTOM_SPLIT_CHAR,
|
||||
},
|
||||
],
|
||||
// Question 问题节点 18
|
||||
// Question Node 18
|
||||
[StandardNodeType.Question]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// question 问题
|
||||
// Question question
|
||||
name: 'question',
|
||||
path: 'inputs.question',
|
||||
},
|
||||
{
|
||||
// answer_type 回答类型 option|text
|
||||
// answer_type answer type option | text
|
||||
name: 'answerType',
|
||||
path: 'inputs.answer_type',
|
||||
},
|
||||
@@ -340,69 +340,69 @@ export const workflowExtractorConfig: SchemaExtractorConfig = {
|
||||
path: 'inputs.options',
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Break 终止循环节点 19
|
||||
// Break Stop Loop Node 19
|
||||
[StandardNodeType.Break]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
],
|
||||
// Set Variable 设置变量节点 20
|
||||
// Set Variables Set Variables Node 20
|
||||
[StandardNodeType.SetVariable]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.VARIABLE_ASSIGN,
|
||||
},
|
||||
],
|
||||
// Loop 循环节点 21
|
||||
// Loop node 21
|
||||
[StandardNodeType.Loop]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应variable name
|
||||
// Corresponding variable name
|
||||
name: 'variables',
|
||||
path: 'inputs.variableParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应output name
|
||||
// Corresponding output name
|
||||
name: 'outputs',
|
||||
path: 'outputs',
|
||||
parser: SchemaExtractorParserName.OUTPUTS,
|
||||
},
|
||||
],
|
||||
// Intent 意图识别节点 22
|
||||
// Intent recognition node 22
|
||||
[StandardNodeType.Intent]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
@@ -419,21 +419,21 @@ export const workflowExtractorConfig: SchemaExtractorConfig = {
|
||||
path: 'inputs.llmParam.systemPrompt.value.content',
|
||||
},
|
||||
],
|
||||
// Knowledge Write 知识库写入节点 27
|
||||
// Knowledge Writing Knowledge Base Writing Node 27
|
||||
[StandardNodeType.DatasetWrite]: [
|
||||
{
|
||||
// 节点自定义名称
|
||||
// Node custom name
|
||||
name: 'title',
|
||||
path: 'nodeMeta.title',
|
||||
},
|
||||
{
|
||||
// 对应input name
|
||||
// Corresponding input name
|
||||
name: 'inputs',
|
||||
path: 'inputs.inputParameters',
|
||||
parser: SchemaExtractorParserName.INPUT_PARAMETERS,
|
||||
},
|
||||
{
|
||||
// 对应知识库名称
|
||||
// Corresponding knowledge base name
|
||||
name: 'datasetParam',
|
||||
path: 'inputs.datasetParam',
|
||||
parser: SchemaExtractorParserName.DATASET_PARAM,
|
||||
|
||||
@@ -51,10 +51,10 @@ export class SchemaExtractor {
|
||||
}
|
||||
public extract(config: SchemaExtractorConfig): SchemaExtracted[] {
|
||||
this.bindParser(config);
|
||||
// 1. 遍历schema中node数组,对每个node做处理
|
||||
// 1. Traverse the node array in the schema and process each node
|
||||
return this.schema.nodes
|
||||
.map((node: WorkflowNodeJSON): SchemaExtracted | null => {
|
||||
// 2. 获取节点对应的配置
|
||||
// 2. Get the configuration corresponding to the node
|
||||
const nodeConfigs: SchemaExtractorNodeConfig[] = config[node.type];
|
||||
if (!nodeConfigs) {
|
||||
return null;
|
||||
@@ -76,13 +76,13 @@ export class SchemaExtractor {
|
||||
extractedConfig: Record<string, unknown>,
|
||||
nodeConfig: SchemaExtractorNodeConfig,
|
||||
): Record<string, unknown> => {
|
||||
// 3. 根据节点配置路径获取属性值
|
||||
// 3. Get the attribute value according to the node configuration path
|
||||
const rawData: unknown = this.extractProperties(
|
||||
nodeData,
|
||||
nodeConfig.path,
|
||||
);
|
||||
if (nodeConfig.parser && typeof nodeConfig.parser === 'function') {
|
||||
// 4. 使用解析器对属性值进行转换
|
||||
// 4. Use the parser to convert the property value
|
||||
extractedConfig[nodeConfig.name] = nodeConfig.parser(rawData);
|
||||
}
|
||||
return extractedConfig;
|
||||
@@ -121,7 +121,7 @@ export class SchemaExtractor {
|
||||
const flattenNodeJSONs: WorkflowNodeJSON[] = [...rootNodes];
|
||||
const flattenEdgeJSONs: WorkflowEdgeJSON[] = [...rootEdges];
|
||||
|
||||
// 如需支持多层结构,以下部分改为递归
|
||||
// To support multi-layer structures, the following section is changed to recursive
|
||||
rootNodes.forEach(nodeJSON => {
|
||||
const { blocks, edges } = nodeJSON;
|
||||
if (blocks) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import { isWorkflowImageTypeURL } from '../utils';
|
||||
import { type SchemaExtractorOutputsParser } from '../type';
|
||||
import { AssistTypeDTO, VariableTypeDTO } from '../../../types/dto';
|
||||
export const outputsParser: SchemaExtractorOutputsParser = outputs => {
|
||||
// 判断是否为数组
|
||||
// Determine whether it is an array
|
||||
if (!Array.isArray(outputs)) {
|
||||
return [];
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export const outputsParser: SchemaExtractorOutputsParser = outputs => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value?: any;
|
||||
isImage?: boolean;
|
||||
// 默认值里包含图片时,图片信息单独放到这里
|
||||
// When the default value includes pictures, the picture information is put here separately.
|
||||
images?: string[];
|
||||
} = {
|
||||
name: output.name || '',
|
||||
@@ -45,7 +45,7 @@ export const outputsParser: SchemaExtractorOutputsParser = outputs => {
|
||||
if (output.type === 'list' && Array.isArray(output.schema?.schema)) {
|
||||
parsed.children = outputsParser(output.schema.schema);
|
||||
}
|
||||
// Start 节点默认值放到 value 上
|
||||
// Start node default value put on value
|
||||
if (output.defaultValue) {
|
||||
parsed.value = output.defaultValue;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ export const variableAssignParser: SchemaExtractorVariableAssignParser =
|
||||
.map(variableAssign => {
|
||||
const leftContent = getValueExpressionName(variableAssign.left);
|
||||
const rightContent = getValueExpressionName(variableAssign.right);
|
||||
// 变量赋值节点的右值字段
|
||||
// Rvalue field of variable assignment node
|
||||
const inputContent = variableAssign.input
|
||||
? getValueExpressionName(variableAssign.input)
|
||||
: null;
|
||||
|
||||
@@ -29,7 +29,7 @@ export type SchemaExtractorConfig = Partial<
|
||||
|
||||
export interface SchemaExtractorNodeConfig {
|
||||
name: string;
|
||||
/** lodash.get 入参格式 */
|
||||
/** Lodash.get imported parameter format */
|
||||
path: string;
|
||||
parser?: SchemaExtractorParserName | Function;
|
||||
displayName?: string;
|
||||
@@ -93,7 +93,7 @@ export type SchemaExtractorOutputsParser = (outputs: VariableMetaDTO[]) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value?: any;
|
||||
isImage?: boolean;
|
||||
// 默认值里包含图片时,图片信息单独放到这里
|
||||
// When the default value includes pictures, the picture information is put here separately.
|
||||
images?: string[];
|
||||
}[];
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ import { get } from 'lodash-es';
|
||||
|
||||
import { type ValueExpressionDTO } from '../../types';
|
||||
|
||||
// 是否我们自己上传生成的url, 这是个临时方案,等修复 schema 中的 type:string -> type:image 后,删掉此逻辑
|
||||
// Whether we upload the generated url ourselves, this is a temporary solution, after fixing the type: string - > type: image in the schema, delete this logic
|
||||
export function isWorkflowImageTypeURL(str: string): boolean {
|
||||
// base64 加工
|
||||
// base64 processing
|
||||
const hostWhiteList = [
|
||||
'cC1ib3Qtd29ya2Zsb3ctc2lnbi5ieXRlZGFuY2UubmV0',
|
||||
'cC1ib3Qtd29ya2Zsb3cuYnl0ZWQub3Jn',
|
||||
|
||||
@@ -18,14 +18,14 @@ import { reporter as infraReporter } from '@coze-arch/logger';
|
||||
const namespace = 'workflow';
|
||||
|
||||
/**
|
||||
* 流程使用的 slardar 上报实例
|
||||
* The slardar reporting instance used by the process
|
||||
*/
|
||||
export const reporter = infraReporter.createReporterWithPreset({
|
||||
namespace,
|
||||
});
|
||||
|
||||
/**
|
||||
* 异常捕获,会被当js error上报
|
||||
* Exception capture will be reported as a js error
|
||||
* @param exception
|
||||
* @param importErrorInfo
|
||||
*/
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
import { BOT_USER_INPUT, CONVERSATION_NAME, USER_INPUT } from '../constants';
|
||||
/**
|
||||
* 是否预设的开始节点的输入参数
|
||||
* Whether to preset the input parameters of the start node
|
||||
*/
|
||||
export const isPresetStartParams = (name?: string): boolean =>
|
||||
[BOT_USER_INPUT, USER_INPUT, CONVERSATION_NAME].includes(name ?? '');
|
||||
|
||||
/**
|
||||
* Start 节点参数是 BOT 聊天时用户的输入内容
|
||||
* The Start node parameter is the user's input during BOT chat
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
|
||||
@@ -38,9 +38,9 @@ export interface TraverseContext {
|
||||
export type TraverseHandler = (context: TraverseContext) => void;
|
||||
|
||||
/**
|
||||
* 深度遍历对象,对每个值做处理
|
||||
* @param value 遍历对象
|
||||
* @param handle 处理函数
|
||||
* Traverse the object in depth, processing each value
|
||||
* @param value over object
|
||||
* @param handling function
|
||||
*/
|
||||
export const traverse = <T extends TraverseValue = TraverseValue>(
|
||||
value: T,
|
||||
@@ -57,9 +57,9 @@ export const traverse = <T extends TraverseValue = TraverseValue>(
|
||||
|
||||
namespace TraverseUtils {
|
||||
/**
|
||||
* 深度遍历对象,对每个值做处理
|
||||
* @param node 遍历节点
|
||||
* @param handle 处理函数
|
||||
* Traverse the object in depth, processing each value
|
||||
* @param node traverse node
|
||||
* @param handling function
|
||||
*/
|
||||
export const traverseNodes = (
|
||||
node: TraverseNode,
|
||||
@@ -67,11 +67,11 @@ namespace TraverseUtils {
|
||||
): void => {
|
||||
const { value } = node;
|
||||
if (!value) {
|
||||
// 异常处理
|
||||
// exception handling
|
||||
return;
|
||||
}
|
||||
if (Object.prototype.toString.call(value) === '[object Object]') {
|
||||
// 对象,遍历对象的每个属性
|
||||
// Object, iterate through each property of the object
|
||||
Object.entries(value).forEach(([key, item]) =>
|
||||
traverseNodes(
|
||||
{
|
||||
@@ -84,8 +84,8 @@ namespace TraverseUtils {
|
||||
),
|
||||
);
|
||||
} else if (Array.isArray(value)) {
|
||||
// 数组,遍历数组的每个元素
|
||||
// 从数组的末尾开始遍历,这样即使中途移除了某个元素,也不会影响到未处理的元素的索引
|
||||
// Array, iterate through each element of the array
|
||||
// The iteration starts at the end of the array, so that even if an element is removed halfway through, it will not affect the index of the unprocessed element
|
||||
for (let index = value.length - 1; index >= 0; index--) {
|
||||
const item: string = value[index];
|
||||
traverseNodes(
|
||||
@@ -117,14 +117,14 @@ namespace TraverseUtils {
|
||||
});
|
||||
|
||||
const setValue = (node: TraverseNode, value: unknown) => {
|
||||
// 设置值函数
|
||||
// 引用类型,需要借助父元素修改值
|
||||
// 由于是递归遍历,所以需要根据node来判断是给对象的哪个属性赋值,还是给数组的哪个元素赋值
|
||||
// Set Value Function
|
||||
// Reference type, you need to modify the value with the help of the parent element
|
||||
// Since it is a recursive traversal, it is necessary to determine which property of the object to assign a value to, or which element of the array to assign a value to, according to node
|
||||
if (!value || !node) {
|
||||
return;
|
||||
}
|
||||
node.value = value;
|
||||
// 从上级作用域node中取出container,key,index
|
||||
// Remove container, key, index from upper scope node
|
||||
const { container, key, index } = node;
|
||||
if (key && container) {
|
||||
container[key] = value;
|
||||
@@ -162,7 +162,7 @@ namespace TraverseUtils {
|
||||
if (typeof pathItem === 'string') {
|
||||
const re = /\W/g;
|
||||
if (re.test(pathItem)) {
|
||||
// 包含特殊字符
|
||||
// Contains special characters
|
||||
return `${stringifyPath}["${pathItem}"]`;
|
||||
}
|
||||
return `${stringifyPath}.${pathItem}`;
|
||||
|
||||
Reference in New Issue
Block a user