chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -173,7 +173,7 @@ describe('getLLMModels', () => {
it('should set model_scene when isBindDouyin is true', async () => {
const mockInfo = { schema_json: JSON.stringify(mockSchemaForLLM) };
// 上一个接口有 3s 缓存,需要等待 3s 后再调用
// The previous interface has 3s cache, you need to wait 3s before calling it.
await new Promise(resolve => setTimeout(resolve, 3100));
// Act
@@ -197,7 +197,7 @@ describe('getLLMModels', () => {
const apiError = new Error('API Error');
vi.mocked(developerApi.GetTypeList).mockRejectedValue(apiError);
// 上一个接口有 3s 缓存,需要等待 3s 后再调用
// The previous interface has 3s cache, you need to wait 3s before calling it.
await new Promise(resolve => setTimeout(resolve, 3100));
const models = await getLLMModels({

View File

@@ -63,7 +63,7 @@ describe('llm-utils', () => {
expect(params.modelType).toBe(mockModels[0].model_type);
expect(params.modelName).toBe(mockModels[0].name);
expect(params.generationDiversity).toBe(GenerationDiversity.Balance);
expect(params.temperature).toBe(0.8); // 来自mockModels[0]的balance默认值
expect(params.temperature).toBe(0.8); // Balance default from mockModels [0]
});
});

View File

@@ -27,7 +27,7 @@ import { type NodeData, WorkflowNodeData } from '../entity-datas';
*
* @param node
* @param data
* 给基础类型节点设置节点数据,不要随意修改
* Set the node data for the basic type node, do not modify it at will
*/
export const addBasicNodeData = (
node: FlowNodeEntity,
@@ -39,7 +39,7 @@ export const addBasicNodeData = (
);
const nodeData = nodeDataEntity.getNodeData<keyof NodeData>();
// 在部分节点的 formMeta 方法,会重复执行,因此这里加个检测
// The formMeta method on some nodes will be executed repeatedly, so add a check here
if (!nodeData && meta) {
nodeDataEntity.setNodeData<BasicStandardNodeTypes>({
icon: meta.icon,

View File

@@ -22,7 +22,7 @@ import {
import { type WorkflowNodeRegistry } from '@coze-workflow/base';
/**
* 根据node meta中定义的getLLMModelIdsByNodeJSON方法获取大模型id
* Get the large model id according to the getLLMModelIdsByNodeJSON method defined in node meta
* @param nodeJSON
* @param ids
* @param document
@@ -56,7 +56,7 @@ function getLLMModelIdsByNodeJSON(
}
/**
* 获取模型ids
* Get model ids
* @param json
* @param document
* @returns

View File

@@ -32,7 +32,7 @@ import { DeveloperApi as developerApi } from '@coze-arch/bot-api';
import { getLLMModelIds } from './get-llm-model-ids';
/** 默认的 response format */
/** Default response format value */
export const getDefaultResponseFormat = () => ({
name: RESPONSE_FORMAT_NAME,
label: I18n.t('model_config_response_format'),
@@ -68,20 +68,20 @@ const queryClient = new QueryClient({
});
/**
* 1. 给模型列表中每个模型的 response_format 参数项补全
* 2. 硬编码设置 response_format 的默认值为 JSON
* @param modelList 模型列表
* @returns 补全 response_format 参数后的模型列表
* 1. Complete the response_format parameter items for each model in the model list
* 2. hardcoding settings response_format default value is JSON
* @param modelList
* @Returns List of models after completing response_format parameters
*/
const repairResponseFormatInModelList = (modelList: Model[]) => {
// 找到模型列表中 model_params 的第一个 response_format 参数项
// 这段代码从下边循环中提出来,不需要每次循环计算一次
// Find the first response_format item model_params in the model list
// This code is taken from the following loop and does not need to be evaluated every time
const modelHasResponseFormatItem = modelList
.find(_m => _m.model_params?.find(p => p.name === RESPONSE_FORMAT_NAME))
?.model_params?.find(p => p.name === RESPONSE_FORMAT_NAME);
return modelList.map(m => {
// 兼容后端未刷带的数据,没有 responseFormat 就补上
// Compatible with unflashed data on the backend, it will be added without responseFormat.
const responseFormat = m.model_params?.find(
p => p?.name === RESPONSE_FORMAT_NAME,
) as ModelParameter;
@@ -90,23 +90,23 @@ const repairResponseFormatInModelList = (modelList: Model[]) => {
if (modelHasResponseFormatItem) {
m.model_params?.push(modelHasResponseFormatItem as ModelParameter);
} else {
// 填充一个默认的 response_format 参数
// Fill in a default response_format parameter
m.model_params?.push(getDefaultResponseFormat());
}
}
// 此时再找一次 responseFormat因为上边补全了 responseFormat
// At this point, find the responseFormat again, because the responseFormat is completed above.
const newResponseFormat = m.model_params?.find(
p => p?.name === RESPONSE_FORMAT_NAME,
) as ModelParameter;
// 重置默认值为 JSON
// Reset the default value to JSON
Object.keys(newResponseFormat?.default_val ?? {}).forEach(k => {
newResponseFormat.default_val[k] = ResponseFormat.JSON;
});
if (newResponseFormat) {
// 重置选项,text markdown json 都要支持
// Reset options, text markdown json must be supported
newResponseFormat.options = [
{
label: I18n.t('model_config_history_text'),
@@ -154,8 +154,8 @@ export const getLLMModels = async ({
const resp = await developerApi.GetTypeList(getTypeListParams);
const _modelList: Model[] = resp?.data?.model_list ?? [];
// 从这里开始到 return modelList 全是给后端擦屁股
// 这里有 hard code ,需要把输出格式的默认值设置为 JSON
// From here to return modelList is all about wiping the butt of the backend
// There is hard code here, you need to set the default value of the output format to JSON
return repairResponseFormatInModelList(_modelList);
},
staleTime: 3000,
@@ -166,7 +166,7 @@ export const getLLMModels = async ({
error: error as Error,
eventName: 'api/bot/get_type_list fetch error',
});
// 上报js错误
// Report a js error
captureException(
new Error(
I18n.t('workflow_detail_error_message', {
@@ -174,7 +174,7 @@ export const getLLMModels = async ({
}),
),
);
// 兜底返回空数组
// Return empty array
return [];
}
};

View File

@@ -20,7 +20,7 @@ import { type DTODefine } from '@coze-workflow/base';
export type InputVariableDTO = DTODefine.InputVariableDTO;
/**
* 对输入参数进行排序,然后按照 required 字段进行分组,必填的放最前边
* Sort the input parameters, then group them by required fields, and put the required fields at the front
* @param inputs
* @param groupKey
* @param sortKey
@@ -35,17 +35,17 @@ export const getSortedInputParameters = <
): T[] => {
const processedItems = (inputs || []).map(item => ({
...item,
required: item.required !== undefined ? item.required : false, // 默认设置为 false
required: item.required !== undefined ? item.required : false, // Default setting is false
}));
// 先按照 required 属性分组
// Group by required attributes first
const grouped = groupBy(processedItems, groupKey);
// 在每个组内按照 name 属性进行排序
// Sort by name attribute within each group
const sortedTrueGroup = sortBy(grouped.true, sortKey) || [];
const sortedFalseGroup = sortBy(grouped.false, sortKey) || [];
// 合并 true 分组和 false 分组
// Merge true and false groupings
const mergedArray = [...sortedTrueGroup, ...sortedFalseGroup];
return mergedArray;

View File

@@ -31,7 +31,7 @@ const getDefaultModels = (modelMeta: Model): Record<string, unknown> => {
const k = camelCase(p.name) as string;
const { type } = p;
// 优先取平衡,自定义兜底
// Priority to take the balance, custom bottom line
const defaultValue =
p.default_val[GenerationDiversity.Balance] ??
p.default_val[GenerationDiversity.Customize];
@@ -50,7 +50,7 @@ const getDefaultModels = (modelMeta: Model): Record<string, unknown> => {
};
/**
* 格式化模型数据,根据 modelMeta 将特定字符串转化成数字
* Format model data to convert specific strings to numbers according to modelMeta
* @param model
* @param modelMeta
* @returns

View File

@@ -141,7 +141,7 @@ export namespace nodeUtils {
}
/**
* @deprecated 使用 variableUtils.valueExpressionToDTO)
* @Deprecated using variableUtils.valueExpressionToDTO)
* @param value
* @param nodeFormContext
* @returns
@@ -165,7 +165,7 @@ export namespace nodeUtils {
}
/**
* @deprecated 使用 variableUtils.valueExpressionToDTO
* @Deprecated using variableUtils.valueExpressionToDTO
* @param value
* @returns
*/
@@ -201,7 +201,7 @@ export namespace nodeUtils {
}
/**
* @deprecated 使用 variableUtils.valueExpressionToVO
* @deprecated using variableUtils.valueExpressionToVO
* @param value
* @param nodeFormContext
* @returns
@@ -217,7 +217,7 @@ export namespace nodeUtils {
}
/**
* @deprecated 使用 variableUtils.valueExpressionToVO
* @deprecated using variableUtils.valueExpressionToVO
* @param input
* @returns
*/
@@ -233,7 +233,7 @@ export namespace nodeUtils {
};
}
// 获取batch表单项默认值
// Get the default value of batch order item
export function getBatchInputListFormDefaultValue(index: number) {
return {
name: `item${index}`,
@@ -244,9 +244,9 @@ export namespace nodeUtils {
};
}
// 节点支持批量
// Node support batch
export function getBatchModeFormMeta(isBatchV2: boolean): IFormItemMeta {
// TODO DELETE schemaGray 临时字段,后端灰度刷数据标记,全量后删除
// TODO DELETE schemaGray temporary field, backend grey release brush data mark, delete after full amount
return {
name: 'batchMode',
type: 'string',
@@ -294,7 +294,7 @@ export namespace nodeUtils {
};
}
// formValueToDto & dtoToFormValue 只迁移了api-node中对inputParameters、batch的适配
// formValueToDto & dtoToFormValue only migrates the adaptation of inputParameters and batch in api-node
export function formValueToDto(value: any, context) {
const inputParams = get(value, INPUT_PARAMS_PATH);
const formattedInputParams = inputParams

View File

@@ -15,10 +15,10 @@
*/
/**
* 为什么要这么维护 triggerId
* 新的流程 fetchStartNodeTriggerFormValue 时没有 triggerId ,初次保存后,后端返回 triggerId
* 已经保存过的流程, fetchStartNodeTriggerFormValue 时,会返回 triggerId
* 获取时机不同,把 triggerId 硬塞到 formData 中比较麻烦,所以直接维护在 cacheTriggerId
* Why maintain triggerId so much?
* The new process fetchStartNodeTriggerFormValue without triggerId, after the initial save, the backend returns triggerId
* The saved process, when fetchStartNodeTriggerFormValue, will return triggerId
* The acquisition time is different, and it is more troublesome to hard-plug the triggerId into formData, so it is directly maintained in the cacheTriggerId.
*/
const cacheTriggerId: Record<string, string> = {};
export const setTriggerId = (wfId: string, triggerId: string) => {