feat: manually mirror opencoze's code from bytedance

Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
fanlv
2025-07-20 17:36:12 +08:00
commit 890153324f
14811 changed files with 1923430 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
[
{
"caseResult": [
{
"dataList": [
{
"data": {
"input": "世界上有多少个国家?",
"timeout": 2000,
},
"title": "输入",
},
],
"imgList": [],
},
],
"isBatch": undefined,
"nodeId": "100001",
"nodeType": "1",
},
{
"caseResult": [
{
"dataList": [
{
"data": {
"output": "截至2024年7月世界上共有233个国家和地区其中国家有197个主权国家195个地区有36个。
联合国会员国目前有193个此外梵蒂冈是联合国观察员国巴勒斯坦是联合国观察员实体这两个在国际上也被广泛承认为国家。 ",
},
"title": "输出变量",
},
],
"imgList": [],
},
],
"isBatch": undefined,
"nodeId": "900001",
"nodeType": "2",
},
{
"caseResult": [
{
"dataList": [
{
"data": {
"input": "世界上有多少个国家?",
"timeout": 2000,
},
"title": "输入",
},
{
"data": {
"key0": "请回答问题:世界上有多少个国家?",
"key1": [
"hello",
"world",
],
"key2": {
"key21": "hi",
},
},
"title": "原始输出",
},
{
"data": {
"key0": "请回答问题:世界上有多少个国家?",
"key1": [
"hello",
"world",
],
"key2": {
"key21": "hi",
},
},
"title": "最终输出",
},
],
"imgList": [],
},
],
"isBatch": undefined,
"nodeId": "172934",
"nodeType": "5",
},
{
"caseResult": [
{
"dataList": [
{
"data": {
"input": "请回答问题:世界上有多少个国家?",
},
"title": "输入",
},
{
"data": "截至2024年7月世界上共有233个国家和地区其中国家有197个主权国家195个地区有36个。
联合国会员国目前有193个此外梵蒂冈是联合国观察员国巴勒斯坦是联合国观察员实体这两个在国际上也被广泛承认为国家。 ",
"title": "原始输出",
},
{
"data": {
"output": "截至2024年7月世界上共有233个国家和地区其中国家有197个主权国家195个地区有36个。
联合国会员国目前有193个此外梵蒂冈是联合国观察员国巴勒斯坦是联合国观察员实体这两个在国际上也被广泛承认为国家。 ",
},
"title": "最终输出",
},
],
"imgList": [],
},
],
"isBatch": undefined,
"nodeId": "126762",
"nodeType": "3",
},
]

View File

@@ -0,0 +1,20 @@
[
{
"nodeId": "172934",
"nodeType": "5",
"properties": {
"title": "代码",
},
},
{
"nodeId": "126762",
"nodeType": "3",
"properties": {
"llmParam": {
"prompt": "{{input}}",
"systemPrompt": "",
},
"title": "大模型",
},
},
]

View File

@@ -0,0 +1,35 @@
/*
* 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 { vi, describe, it, expect } from 'vitest';
import { type WorkflowJSON } from '@coze-workflow/base';
import { mockNodeResults } from '../__mock_data__/node-results';
import { mockCanvasSchema } from '../__mock_data__/canvas-schema';
import { nodeResultExtractor } from '../../src/utils';
vi.mock('lottie-web', () => ({}));
describe('node-result-extractor test in @coze-workflow/sdk', () => {
it('should extract node result', async () => {
const result = nodeResultExtractor({
nodeResults: mockNodeResults,
schema: mockCanvasSchema as unknown as WorkflowJSON,
});
await expect(result).toMatchFileSnapshot(
'./__snapshots__/node-result-extractor.test.ts.snap',
);
});
});

View File

@@ -0,0 +1,60 @@
/*
* 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 { vi, describe, it, expect } from 'vitest';
import {
type SchemaExtractorConfig,
SchemaExtractorParserName,
StandardNodeType,
type WorkflowJSON,
} from '@coze-workflow/base';
import { mockCanvasSchema } from '../__mock_data__/canvas-schema';
import { schemaExtractor } from '../../src/utils';
vi.mock('lottie-web', () => ({}));
const config: SchemaExtractorConfig = {
[StandardNodeType.Code]: [
{
name: 'title',
path: 'nodeMeta.title',
},
],
[StandardNodeType.LLM]: [
{
name: 'title',
path: 'nodeMeta.title',
},
{
name: 'llmParam',
path: 'inputs.llmParam',
parser: SchemaExtractorParserName.LLM_PARAM,
},
],
};
describe('schema-extractor test in @coze-workflow/sdk', () => {
it('should extract schema result', async () => {
const result = schemaExtractor({
schema: mockCanvasSchema as unknown as WorkflowJSON,
config,
});
await expect(result).toMatchFileSnapshot(
'./__snapshots__/schema-extractor.test.ts.snap',
);
});
});