Skip to content

Commit 02fef53

Browse files
authored
[elsa] 修复大模型节点工具对应插件/工作流被卸载/删除后,编排页面未进行展示的问题 (#27)
1 parent 0c1c0a6 commit 02fef53

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

framework/elsa/fit-elsa-react/src/components/llm/LlmFormWrapper.jsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,42 @@ export default function LlmFormWrapper({data, shapeStatus}) {
103103
return;
104104
}
105105
const urlSuffix = uniqueNameList.map(uniqueName => `uniqueNames=${uniqueName}`).join('&');
106-
httpUtil.get(`${config.urls.toolListEndpoint}?${urlSuffix}`, new Map(), (jsonData) =>
107-
setToolOptions(jsonData.data.map(item => {
108-
return {
109-
id: uuidv4(),
110-
name: item.name,
111-
tags: item.tags,
112-
version: item.version,
113-
value: item.uniqueName,
114-
};
115-
})));
106+
httpUtil.get(`${config.urls.toolListEndpoint}?${urlSuffix}`, new Map(), (jsonData) => {
107+
processToolData(jsonData.data);
108+
},
109+
() => {
110+
processToolData([]);
111+
},
112+
);
113+
114+
const processToolData = (responseData) => {
115+
const responseMap = new Map(responseData.map(item => [item.uniqueName, item]));
116+
117+
const toolOptions = uniqueNameList.map(uniqueName => {
118+
if (responseMap.has(uniqueName)) {
119+
const item = responseMap.get(uniqueName);
120+
return {
121+
id: uuidv4(),
122+
name: item.name,
123+
tags: item.tags,
124+
version: item.version,
125+
value: item.uniqueName,
126+
};
127+
} else {
128+
// 若请求返回体中没有该 uniqueName 或请求失败,则从 toolItem 中获取信息
129+
const fallbackItem = tool.value.find(toolItem => toolItem.value === uniqueName);
130+
return fallbackItem ? {
131+
id: fallbackItem.id,
132+
name: fallbackItem.name || 'Unknown',
133+
tags: fallbackItem.tags || [],
134+
version: fallbackItem.version || 'Unknown',
135+
value: fallbackItem.value,
136+
} : null;
137+
}
138+
}).filter(Boolean); // 过滤掉 null 值
139+
140+
setToolOptions(toolOptions);
141+
};
116142
};
117143

118144
useEffect(() => {

0 commit comments

Comments
 (0)