Merge branch 'feature/ui_upgrade_zy' of github.com:SuanmoSuanyangTechnology/MemoryBear into feature/ui_upgrade_zy
This commit is contained in:
@@ -53,7 +53,7 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
||||
const root = $getRoot();
|
||||
root.clear();
|
||||
|
||||
const parts = value.split(/(\{\{[^}]+\}\})/);
|
||||
const parts = value.split(/(\{\{[^}]+\}\}|\n)/);
|
||||
|
||||
if (enableLineNumbers) {
|
||||
const lines = value.split('\n');
|
||||
@@ -63,8 +63,14 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
||||
root.append(paragraph);
|
||||
});
|
||||
} else {
|
||||
const paragraph = $createParagraphNode();
|
||||
let paragraph = $createParagraphNode();
|
||||
|
||||
parts.forEach(part => {
|
||||
if (part === '\n') {
|
||||
root.append(paragraph);
|
||||
paragraph = $createParagraphNode();
|
||||
return;
|
||||
}
|
||||
const match = part.match(/^\{\{([^.]+)\.([^}]+)\}\}$/);
|
||||
const contextMatch = part.match(/^\{\{context\}\}$/);
|
||||
const conversationMatch = part.match(/^\{\{conv\.([^}]+)\}\}$/);
|
||||
@@ -78,10 +84,10 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (conversationMatch) {
|
||||
const [_, variableName] = conversationMatch;
|
||||
const conversationSuggestion = optionsRef.current.find(s =>
|
||||
const conversationSuggestion = optionsRef.current.find(s =>
|
||||
s.group === 'CONVERSATION' && s.label === variableName
|
||||
);
|
||||
if (conversationSuggestion) {
|
||||
@@ -91,7 +97,7 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (match) {
|
||||
const [_, nodeId, label] = match;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { type FC } from 'react'
|
||||
import { type FC, useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Form, Select, Input, Button, InputNumber, Flex } from 'antd'
|
||||
|
||||
import VariableSelect from '../VariableSelect'
|
||||
import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
|
||||
import RadioGroupBtn from '../RadioGroupBtn'
|
||||
import { getChildNodeVariables } from '../hooks/useVariableList'
|
||||
|
||||
interface CycleVar {
|
||||
name: string;
|
||||
@@ -44,40 +45,14 @@ const CycleVarsList: FC<CycleVarsListProps> = ({
|
||||
const { t } = useTranslation();
|
||||
const form = Form.useFormInstance();
|
||||
|
||||
// 获取循环节点的子节点变量
|
||||
const getChildNodeVariables = () => {
|
||||
const availableOptions = useMemo(() => {
|
||||
if (!selectedNode || !graphRef?.current || selectedNode.getData()?.type !== 'loop') {
|
||||
return options;
|
||||
}
|
||||
const childVars = getChildNodeVariables(selectedNode, graphRef);
|
||||
|
||||
const loopNodeId = selectedNode.getData()?.id;
|
||||
const childNodes = graphRef.current.getNodes().filter((node: any) =>
|
||||
node.getData()?.cycle === loopNodeId
|
||||
);
|
||||
|
||||
const childVariables: Suggestion[] = [];
|
||||
childNodes.forEach((childNode: any) => {
|
||||
const childData = childNode.getData();
|
||||
if (childData?.config) {
|
||||
Object.keys(childData.config).forEach(key => {
|
||||
if (childData.config[key]?.defaultValue) {
|
||||
childVariables.push({
|
||||
key: `${childData.id}.${key}`,
|
||||
label: `${childData.name || childData.type}.${key}`,
|
||||
type: 'output',
|
||||
dataType: 'string',
|
||||
value: `${childData.id}.${key}`,
|
||||
nodeData: childData
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return [...options, ...childVariables];
|
||||
};
|
||||
|
||||
const availableOptions = getChildNodeVariables();
|
||||
return options.filter(option => !childVars.some(item => item.value === option.value))
|
||||
}, [options, selectedNode, graphRef]);
|
||||
|
||||
return (
|
||||
<Form.List name={parentName}>
|
||||
|
||||
@@ -42,6 +42,9 @@ const NODE_VARIABLES = {
|
||||
'memory-read': [
|
||||
{ label: 'answer', dataType: 'string', field: 'answer' },
|
||||
{ label: 'intermediate_outputs', dataType: 'array[object]', field: 'intermediate_outputs' }
|
||||
],
|
||||
'document-extractor': [
|
||||
{ label: 'text', dataType: 'string', field: 'text' },
|
||||
]
|
||||
} as const;
|
||||
|
||||
@@ -177,7 +180,8 @@ const hasOutputNodeTypes = [
|
||||
'var-aggregator',
|
||||
'http-request',
|
||||
'tool',
|
||||
'jinja-render'
|
||||
'jinja-render',
|
||||
'document-extractor'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -636,6 +636,8 @@ const Properties: FC<PropertiesProps> = ({
|
||||
size="small"
|
||||
parentName={key}
|
||||
options={getFilteredVariableList(selectedNode?.data?.type, key)}
|
||||
selectedNode={selectedNode}
|
||||
graphRef={graphRef}
|
||||
/>
|
||||
</Form.Item>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user