36 lines
971 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 通用Schema加载函数
* @param {string} nodeType - 节点类型
* @returns {Promise<Object>} Schema配置对象
*/
export async function loadNodeSchema(nodeType) {
try {
const response = await jingrow.call({
method: 'jingrow.ai.utils.node_schema.get_node_schema',
args: { node_type: nodeType }
});
if (response.message) {
return response.message;
} else {
throw new Error('Schema加载失败响应为空');
}
} catch (error) {
console.error('Schema加载失败:', error);
jingrow.msgprint({
title: 'Schema加载失败',
message: `无法加载${nodeType}节点配置,请检查网络连接`,
indicator: 'red'
});
throw error;
}
}
/**
* 创建针对特定节点类型的Schema加载器
* @param {string} nodeType - 节点类型
* @returns {Function} 异步加载函数
*/
export function createSchemaLoader(nodeType) {
return () => loadNodeSchema(nodeType);
}