chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -35,33 +35,33 @@ interface FormData {
|
||||
}
|
||||
|
||||
export const CLEAR_CONTEXT_FORM_META: FormMetaV2<FormData> = {
|
||||
// 节点表单渲染
|
||||
// Node form rendering
|
||||
render: () => <FormRender />,
|
||||
|
||||
// 验证触发时机
|
||||
// verification trigger timing
|
||||
validateTrigger: ValidateTrigger.onChange,
|
||||
|
||||
// 验证规则
|
||||
// validation rules
|
||||
validate: {
|
||||
// 必填
|
||||
// Required
|
||||
'inputParameters.0.input': createValueExpressionInputValidate({
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
|
||||
// 副作用管理
|
||||
// Side effect management
|
||||
effect: {
|
||||
nodeMeta: fireNodeTitleChange,
|
||||
outputs: provideNodeOutputVariablesEffect,
|
||||
inputParameters: syncConversationNameEffect,
|
||||
},
|
||||
|
||||
// 节点后端数据 -> 前端表单数据
|
||||
// Node Backend Data - > Frontend Form Data
|
||||
formatOnInit: createTransformOnInit(
|
||||
DEFAULT_CONVERSATION_VALUE,
|
||||
DEFAULT_OUTPUTS,
|
||||
),
|
||||
|
||||
// 前端表单数据 -> 节点后端数据
|
||||
// Front-end form data - > node back-end data
|
||||
formatOnSubmit: transformOnSubmit,
|
||||
};
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 清空会话历史节点 */
|
||||
/** Clear session history node */
|
||||
|
||||
export { CLEAR_CONTEXT_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -34,32 +34,32 @@ interface FormData {
|
||||
}
|
||||
|
||||
export const CREATE_CONVERSATION_FORM_META: FormMetaV2<FormData> = {
|
||||
// 节点表单渲染
|
||||
// Node form rendering
|
||||
render: () => <FormRender />,
|
||||
|
||||
// 验证触发时机
|
||||
// verification trigger timing
|
||||
validateTrigger: ValidateTrigger.onChange,
|
||||
|
||||
// 验证规则
|
||||
// validation rules
|
||||
validate: {
|
||||
// 必填
|
||||
// Required
|
||||
'inputParameters.0.input': createValueExpressionInputValidate({
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
|
||||
// 副作用管理
|
||||
// Side effect management
|
||||
effect: {
|
||||
nodeMeta: fireNodeTitleChange,
|
||||
outputs: provideNodeOutputVariablesEffect,
|
||||
},
|
||||
|
||||
// 节点后端数据 -> 前端表单数据
|
||||
// Node Backend Data - > Frontend Form Data
|
||||
formatOnInit: createTransformOnInit(
|
||||
DEFAULT_CONVERSATION_VALUE,
|
||||
DEFAULT_OUTPUTS,
|
||||
),
|
||||
|
||||
// 前端表单数据 -> 节点后端数据
|
||||
// Front-end form data - > node back-end data
|
||||
formatOnSubmit: transformOnSubmit,
|
||||
};
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 创建会话节点 */
|
||||
/** Create a session node */
|
||||
|
||||
export { CREATE_CONVERSATION_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -44,19 +44,19 @@ export const createFormMeta = ({
|
||||
formRenderComponent,
|
||||
customValidators = {},
|
||||
}): FormMetaV2<ChatFormData> => {
|
||||
// 定义首字母大写的变量引用组件
|
||||
// Define an uppercase variable reference component
|
||||
const FormRender = formRenderComponent;
|
||||
|
||||
const formMeta = {
|
||||
// 节点表单渲染
|
||||
// Node form rendering
|
||||
render: () => <FormRender />,
|
||||
|
||||
// 验证触发时机
|
||||
// verification trigger timing
|
||||
validateTrigger: ValidateTrigger.onChange,
|
||||
|
||||
// 验证规则
|
||||
// validation rules
|
||||
validate: {
|
||||
// 必填
|
||||
// Required
|
||||
'inputParameters.*.input': createValueExpressionInputValidate({
|
||||
required: ({ name }) => {
|
||||
const fieldName = name
|
||||
@@ -69,20 +69,20 @@ export const createFormMeta = ({
|
||||
...customValidators,
|
||||
},
|
||||
|
||||
// 副作用管理
|
||||
// Side effect management
|
||||
effect: {
|
||||
nodeMeta: fireNodeTitleChange,
|
||||
outputs: provideNodeOutputVariablesEffect,
|
||||
},
|
||||
|
||||
// 节点后端数据 -> 前端表单数据
|
||||
// Node Backend Data - > Frontend Form Data
|
||||
formatOnInit: createTransformOnInit(defaultInputValue, defaultOutputValue),
|
||||
|
||||
// 前端表单数据 -> 节点后端数据
|
||||
// Front-end form data - > node back-end data
|
||||
formatOnSubmit: transformOnSubmit,
|
||||
};
|
||||
|
||||
// 需要同步联动 CONVERSATION_NAME 字段的值
|
||||
// Need to synchronize the value of CONVERSATION_NAME field
|
||||
if (needSyncConversationName) {
|
||||
Object.assign(formMeta.effect, {
|
||||
inputParameters: syncConversationNameEffect,
|
||||
|
||||
@@ -35,10 +35,10 @@ export const FIELD_CONFIG = {
|
||||
required: true,
|
||||
type: VariableTypeDTO.string,
|
||||
|
||||
// 选项默认值
|
||||
// option default
|
||||
defaultValue: 'user',
|
||||
|
||||
// 选项列表
|
||||
// list of options
|
||||
optionsList: [
|
||||
{ label: 'user', value: 'user' },
|
||||
{ label: 'assistant', value: 'assistant' },
|
||||
@@ -56,7 +56,7 @@ export const FIELD_CONFIG = {
|
||||
export const DEFAULT_CONVERSATION_VALUE: InputValueVO[] = Object.keys(
|
||||
FIELD_CONFIG,
|
||||
).map(fieldName => {
|
||||
// 针对 role 字段,需要设置字面量默认值
|
||||
// For the role field, you need to set the literal default
|
||||
if (fieldName === 'role') {
|
||||
return {
|
||||
name: fieldName,
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 创建消息节点 */
|
||||
/** Create message node */
|
||||
|
||||
export { CREATE_MESSAGE_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -76,7 +76,7 @@ export const createNodeRegistry = (
|
||||
},
|
||||
size: { width: NODE_WIDTH, height: NODE_HEIGHT },
|
||||
nodeMetaPath: DEFAULT_NODE_META_PATH,
|
||||
inputParametersPath: INPUT_PATH, // 入参路径,试运行等功能依赖该路径提取参数
|
||||
inputParametersPath: INPUT_PATH, // Imported parameter path, practice running and other functions rely on this path to extract parameters
|
||||
getInputVariableTag(name, input, extra) {
|
||||
const field = fieldConfig[name || ''];
|
||||
|
||||
@@ -86,16 +86,16 @@ export const createNodeRegistry = (
|
||||
const content = input?.content as RefExpressionContent;
|
||||
const isRef = content?.keyPath?.length > 0;
|
||||
|
||||
// 初始化流程时,可能变量模块还没有初始化,这里会获取不到变量...
|
||||
// When initializing the process, it is possible that the variable module has not been initialized, and the variable will not be obtained here...
|
||||
const variable = extra?.variableService.getWorkflowVariableByKeyPath(
|
||||
content?.keyPath,
|
||||
{ node: extra?.node, checkScope: true },
|
||||
);
|
||||
|
||||
// 必填场景,如果:
|
||||
// 1. 为空,报错
|
||||
// 2. 不为空
|
||||
// 2.1 引用变量,且变量不存在,报错
|
||||
// Required scene if:
|
||||
// 1. Empty, error reported
|
||||
// 2. Not empty
|
||||
// 2.1 Reference to a variable, and the variable does not exist, an error is reported
|
||||
invalid = ValueExpression.isEmpty(input) || (isRef && !variable);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export const createNodeRegistry = (
|
||||
[],
|
||||
) as InputValueDTO[];
|
||||
|
||||
// 对于固定参数类型,需要将 type 字段设置为预定义的类型,而不是右侧填入的变量类型
|
||||
// For fixed parameter types, you need to set the type field to a predefined type, rather than the variable type populated on the right
|
||||
inputParameters.forEach(param => {
|
||||
const config = fieldConfig[param.name || ''];
|
||||
if (config && param.input.type) {
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 删除会话节点 */
|
||||
/** Delete session node */
|
||||
|
||||
export { DELETE_CONVERSATION_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 删除消息节点 */
|
||||
/** Delete message node */
|
||||
|
||||
export { DELETE_MESSAGE_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 查询会话历史节点 */
|
||||
/** Query session history node */
|
||||
|
||||
export { QUERY_CONVERSATION_HISTORY_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 查询会话列表 */
|
||||
/** Query session list */
|
||||
|
||||
export { QUERY_CONVERSATION_LIST_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -35,33 +35,33 @@ interface FormData {
|
||||
}
|
||||
|
||||
export const QUERY_MESSAGE_LIST_FORM_META: FormMetaV2<FormData> = {
|
||||
// 节点表单渲染
|
||||
// Node form rendering
|
||||
render: props => <FormRender {...props} />,
|
||||
|
||||
// 验证触发时机
|
||||
// verification trigger timing
|
||||
validateTrigger: ValidateTrigger.onChange,
|
||||
|
||||
// 验证规则
|
||||
// validation rules
|
||||
validate: {
|
||||
// 必填
|
||||
// Required
|
||||
'inputParameters.0.input': createValueExpressionInputValidate({
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
|
||||
// 副作用管理
|
||||
// Side effect management
|
||||
effect: {
|
||||
nodeMeta: fireNodeTitleChange,
|
||||
outputs: provideNodeOutputVariablesEffect,
|
||||
inputParameters: syncConversationNameEffect,
|
||||
},
|
||||
|
||||
// 节点后端数据 -> 前端表单数据
|
||||
// Node Backend Data - > Frontend Form Data
|
||||
formatOnInit: createTransformOnInit(
|
||||
DEFAULT_CONVERSATION_VALUE,
|
||||
DEFAULT_OUTPUTS,
|
||||
),
|
||||
|
||||
// 前端表单数据 -> 节点后端数据
|
||||
// Front-end form data - > node back-end data
|
||||
formatOnSubmit: transformOnSubmit,
|
||||
};
|
||||
|
||||
@@ -14,5 +14,5 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 查看消息列表(某个会话) */
|
||||
/** View a list of messages (for a session) */
|
||||
export { QUERY_MESSAGE_LIST_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -26,7 +26,7 @@ import { ValueExpression, WorkflowMode } from '@coze-workflow/base';
|
||||
|
||||
import { CONVERSATION_NAME } from './constants';
|
||||
|
||||
/** 延迟200ms,此时等边连上后,才能检测变量作用域 */
|
||||
/** Delay 200ms. At this time, the variable scope can only be detected after the equilateral connection is connected. */
|
||||
const DELAY = 200;
|
||||
|
||||
const effect: Effect = ({ value, context }) => {
|
||||
@@ -59,7 +59,7 @@ const effect: Effect = ({ value, context }) => {
|
||||
conversationNameItem?.input as ValueExpression,
|
||||
);
|
||||
|
||||
// 如果能够找到开始节点的 CONVERSATION_NAME 参数
|
||||
// If you can find the CONVERSATION_NAME parameters of the start node
|
||||
if (
|
||||
startConversationNameVar &&
|
||||
conversationNameItem &&
|
||||
@@ -76,7 +76,7 @@ const effect: Effect = ({ value, context }) => {
|
||||
formModel.setValueIn('inputParameters', clonedValue);
|
||||
}
|
||||
} else if (!isInIDE && !isChatflow && conversationNameItem && noValue) {
|
||||
// 非项目中的工作流,如果存在没有值的 CONVERSATION_NAME 字段,填入默认值 default
|
||||
// Non-project workflow, if there is a CONVERSATION_NAME field with no value, fill in the default value default
|
||||
if (formModel) {
|
||||
set(conversationNameItem, 'input', {
|
||||
type: 'literal',
|
||||
|
||||
@@ -25,7 +25,7 @@ const isEmptyArrayOrNil = (value: unknown) =>
|
||||
// eslint-disable-next-line eqeqeq
|
||||
(Array.isArray(value) && value.length === 0) || value == null;
|
||||
/**
|
||||
* 节点后端数据 -> 前端表单数据
|
||||
* Node Backend Data - > Frontend Form Data
|
||||
*/
|
||||
export const createTransformOnInit =
|
||||
(
|
||||
@@ -36,8 +36,8 @@ export const createTransformOnInit =
|
||||
const { inputs, outputs } = value || {};
|
||||
const inputParameters = inputs?.inputParameters || [];
|
||||
|
||||
// 由于在提交时,会将没有填值的变量给过滤掉,所以需要在初始化时,将默认值补充进来
|
||||
// 参见:packages/workflow/nodes/src/workflow-json-format.ts:241
|
||||
// Since variables that are not filled in will be filtered out during commit, the default value needs to be added during initialization
|
||||
// See also: packages/workflow/nodes/src/workflow-json-format: 241
|
||||
const refillInputParamters = defaultInputValue.map(cur => {
|
||||
const { name } = cur;
|
||||
const target = inputParameters.find(item => item.name === name);
|
||||
|
||||
@@ -22,7 +22,7 @@ interface FormData {
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端表单数据 -> 节点后端数据
|
||||
* Front-end form data - > node back-end data
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 更新会话节点 */
|
||||
/** Update session node */
|
||||
|
||||
export { UPDATE_CONVERSATION_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 修改消息节点 */
|
||||
/** Modify message node */
|
||||
|
||||
export { UPDATE_MESSAGE_NODE_REGISTRY } from './node-registry';
|
||||
|
||||
Reference in New Issue
Block a user