feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { nanoid } from 'nanoid';
|
||||
import { ValueExpressionType, ViewVariableType } from '@coze-workflow/variable';
|
||||
import { I18n } from '@coze-arch/i18n';
|
||||
|
||||
import { CONVERSATION_NAME } from '../constants';
|
||||
|
||||
export const FIELD_CONFIG = {
|
||||
conversationName: {
|
||||
description: I18n.t('workflow_250407_023'),
|
||||
name: CONVERSATION_NAME,
|
||||
required: true,
|
||||
type: 'string',
|
||||
},
|
||||
};
|
||||
|
||||
export const DEFAULT_CONVERSATION_VALUE = Object.keys(FIELD_CONFIG).map(
|
||||
fieldName => ({
|
||||
name: fieldName,
|
||||
input: {
|
||||
type: ValueExpressionType.REF,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
export const DEFAULT_OUTPUTS = [
|
||||
{
|
||||
key: nanoid(),
|
||||
name: 'isSuccess',
|
||||
type: ViewVariableType.Boolean,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { type FormMetaV2 } from '@flowgram-adapter/free-layout-editor';
|
||||
|
||||
import { createFormMeta } from '../create-form-meta';
|
||||
import FormRender from './form-render';
|
||||
import {
|
||||
DEFAULT_CONVERSATION_VALUE,
|
||||
DEFAULT_OUTPUTS,
|
||||
FIELD_CONFIG,
|
||||
} from './constants';
|
||||
|
||||
export const FORM_META: FormMetaV2 = createFormMeta({
|
||||
fieldConfig: FIELD_CONFIG,
|
||||
needSyncConversationName: false,
|
||||
defaultInputValue: DEFAULT_CONVERSATION_VALUE,
|
||||
defaultOutputValue: DEFAULT_OUTPUTS,
|
||||
formRenderComponent: FormRender,
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { I18n } from '@coze-arch/i18n';
|
||||
|
||||
import { useReadonly } from '@/nodes-v2/hooks/use-readonly';
|
||||
|
||||
import { createFormRender } from '../create-form-render';
|
||||
import {
|
||||
FIELD_CONFIG,
|
||||
DEFAULT_CONVERSATION_VALUE,
|
||||
DEFAULT_OUTPUTS,
|
||||
} from './constants';
|
||||
|
||||
const Render = () => {
|
||||
const readonly = useReadonly();
|
||||
|
||||
return createFormRender({
|
||||
defaultInputValue: DEFAULT_CONVERSATION_VALUE,
|
||||
defaultOutputValue: DEFAULT_OUTPUTS,
|
||||
fieldConfig: FIELD_CONFIG,
|
||||
readonly,
|
||||
inputTooltip: I18n.t('Input'),
|
||||
outputTooltip: I18n.t('Output'),
|
||||
});
|
||||
};
|
||||
|
||||
export default Render;
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** 删除会话节点 */
|
||||
|
||||
export { DELETE_CONVERSATION_NODE_REGISTRY } from './node-registry';
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { StandardNodeType } from '@coze-workflow/base';
|
||||
|
||||
import { createNodeRegistry } from '../create-node-registry';
|
||||
import { test } from './node-test';
|
||||
import { FORM_META } from './form-meta';
|
||||
import { FIELD_CONFIG } from './constants';
|
||||
|
||||
export const DELETE_CONVERSATION_NODE_REGISTRY = createNodeRegistry(
|
||||
StandardNodeType.DeleteConversation,
|
||||
FORM_META,
|
||||
FIELD_CONFIG,
|
||||
{ test },
|
||||
);
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { I18n } from '@coze-arch/i18n';
|
||||
import { FlowNodeFormData } from '@flowgram-adapter/free-layout-editor';
|
||||
|
||||
import {
|
||||
generateParametersToProperties,
|
||||
generateEnvToRelatedContextProperties,
|
||||
} from '@/test-run-kit';
|
||||
import { type NodeTestMeta } from '@/test-run-kit';
|
||||
|
||||
export const test: NodeTestMeta = {
|
||||
generateRelatedContext(node, context) {
|
||||
const { isInProject } = context;
|
||||
if (isInProject) {
|
||||
return {};
|
||||
}
|
||||
return generateEnvToRelatedContextProperties({
|
||||
isNeedBot: true,
|
||||
hasConversationNode: true,
|
||||
disableBot: true,
|
||||
disableBotTooltip: I18n.t('wf_chatflow_141'),
|
||||
});
|
||||
},
|
||||
generateFormInputProperties(node) {
|
||||
const formData = node
|
||||
.getData(FlowNodeFormData)
|
||||
.formModel.getFormItemValueByPath('/');
|
||||
return generateParametersToProperties(formData?.inputParameters, { node });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user