feat: llm node add context

This commit is contained in:
zhaoying
2026-01-04 12:06:24 +08:00
parent 02c8fd0e3f
commit 351be8aaf3
10 changed files with 233 additions and 150 deletions

View File

@@ -330,9 +330,30 @@ const Properties: FC<PropertiesProps> = ({
}
if (selectedNode?.data?.type === 'llm' && key === 'messages' && config.type === 'define') {
// 为llm节点且isArray=true时添加context变量支持
let contextVariableList = [...variableList];
const isArrayMode = config.isArray !== false; // 默认为true
if (isArrayMode) {
const contextKey = `${selectedNode.id}_context`;
const hasContextVariable = contextVariableList.some(v => v.key === contextKey);
if (!hasContextVariable) {
contextVariableList.unshift({
key: contextKey,
label: 'context',
type: 'variable',
dataType: 'String',
value: `{{context}}`,
nodeData: selectedNode.getData(),
isContext: true,
});
}
}
return (
<Form.Item key={key} name={key}>
<MessageEditor options={variableList} parentName={key} />
<MessageEditor options={contextVariableList} parentName={key} />
</Form.Item>
)
}