Merge #95 into develop_web from feature/20251219_zy
fix(web): knowledge-retrieval node update * feature/20251219_zy: (2 commits) feat(web): hidden node fix(web): knowledge-retrieval node update Signed-off-by: zhaoying <zhaoying@redbearai.com> Merged-by: zhaoying <zhaoying@redbearai.com> CR-link: https://codeup.aliyun.com/redbearai/python/redbear-mem-open/change/95
This commit is contained in:
@@ -16,6 +16,7 @@ import KnowledgeListModal from './KnowledgeListModal'
|
|||||||
import KnowledgeConfigModal from './KnowledgeConfigModal'
|
import KnowledgeConfigModal from './KnowledgeConfigModal'
|
||||||
import KnowledgeGlobalConfigModal from './KnowledgeGlobalConfigModal'
|
import KnowledgeGlobalConfigModal from './KnowledgeGlobalConfigModal'
|
||||||
import Tag from '@/components/Tag'
|
import Tag from '@/components/Tag'
|
||||||
|
import { getKnowledgeBaseList } from '@/api/knowledgeBase'
|
||||||
|
|
||||||
const Knowledge: FC<{value?: KnowledgeConfig; onChange?: (config: KnowledgeConfig) => void}> = ({value = {knowledge_bases: []}, onChange}) => {
|
const Knowledge: FC<{value?: KnowledgeConfig; onChange?: (config: KnowledgeConfig) => void}> = ({value = {knowledge_bases: []}, onChange}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -29,7 +30,26 @@ const Knowledge: FC<{value?: KnowledgeConfig; onChange?: (config: KnowledgeConfi
|
|||||||
if (value && JSON.stringify(value) !== JSON.stringify(editConfig)) {
|
if (value && JSON.stringify(value) !== JSON.stringify(editConfig)) {
|
||||||
setEditConfig({ ...(value || {}) })
|
setEditConfig({ ...(value || {}) })
|
||||||
const knowledge_bases = [...(value.knowledge_bases || [])]
|
const knowledge_bases = [...(value.knowledge_bases || [])]
|
||||||
setKnowledgeList(knowledge_bases)
|
|
||||||
|
// 检查是否有knowledge_bases缺少name字段
|
||||||
|
const basesWithoutName = knowledge_bases.filter(base => !base.name)
|
||||||
|
if (basesWithoutName.length > 0) {
|
||||||
|
// 调用接口获取完整的知识库信息
|
||||||
|
getKnowledgeBaseList().then(res => {
|
||||||
|
const fullBases = knowledge_bases.map(base => {
|
||||||
|
if (!base.name) {
|
||||||
|
const fullBase = res.items.find((item: any) => item.id === base.kb_id)
|
||||||
|
return fullBase ? { ...base, ...fullBase } : base
|
||||||
|
}
|
||||||
|
return base
|
||||||
|
})
|
||||||
|
setKnowledgeList(fullBases)
|
||||||
|
}).catch(() => {
|
||||||
|
setKnowledgeList(knowledge_bases)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
setKnowledgeList(knowledge_bases)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [value])
|
}, [value])
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ const Properties: FC<PropertiesProps> = ({
|
|||||||
if (selectedNode?.data?.type === 'llm' && key === 'messages' && config.type === 'define') {
|
if (selectedNode?.data?.type === 'llm' && key === 'messages' && config.type === 'define') {
|
||||||
return (
|
return (
|
||||||
<Form.Item key={key} name={key}>
|
<Form.Item key={key} name={key}>
|
||||||
<MessageEditor options={variableList} />
|
<MessageEditor options={variableList} parentName={key} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export const nodeLibrary: NodeLibrary[] = [
|
|||||||
type: 'define',
|
type: 'define',
|
||||||
defaultValue: [
|
defaultValue: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'SYSTEM',
|
||||||
content: undefined,
|
content: undefined,
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
@@ -142,27 +142,27 @@ export const nodeLibrary: NodeLibrary[] = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// { type: "classification", icon: classificationIcon },
|
// { type: "classification", icon: classificationIcon },
|
||||||
{ type: "parameter-extractor", icon: parameterExtractionIcon,
|
// { type: "parameter-extractor", icon: parameterExtractionIcon,
|
||||||
config: {
|
// config: {
|
||||||
model_id: {
|
// model_id: {
|
||||||
type: 'customSelect',
|
// type: 'customSelect',
|
||||||
url: getModelListUrl,
|
// url: getModelListUrl,
|
||||||
params: { type: 'llm,chat' }, // llm/chat
|
// params: { type: 'llm,chat' }, // llm/chat
|
||||||
valueKey: 'id',
|
// valueKey: 'id',
|
||||||
labelKey: 'name',
|
// labelKey: 'name',
|
||||||
},
|
// },
|
||||||
text: {
|
// text: {
|
||||||
type: 'variableList',
|
// type: 'variableList',
|
||||||
},
|
// },
|
||||||
params: {
|
// params: {
|
||||||
type: 'paramList',
|
// type: 'paramList',
|
||||||
},
|
// },
|
||||||
prompt: {
|
// prompt: {
|
||||||
type: 'messageEditor',
|
// type: 'messageEditor',
|
||||||
isArray: false,
|
// isArray: false,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
@@ -182,115 +182,115 @@ export const nodeLibrary: NodeLibrary[] = [
|
|||||||
// { type: "agent_arbitration", icon: agentArbitrationIcon }
|
// { type: "agent_arbitration", icon: agentArbitrationIcon }
|
||||||
// ]
|
// ]
|
||||||
// },
|
// },
|
||||||
{
|
// {
|
||||||
category: "flowControl",
|
// category: "flowControl",
|
||||||
nodes: [
|
// nodes: [
|
||||||
{ type: "if-else", icon: conditionIcon,
|
// { type: "if-else", icon: conditionIcon,
|
||||||
config: {
|
// config: {
|
||||||
cases: {
|
// cases: {
|
||||||
type: 'caseList',
|
// type: 'caseList',
|
||||||
defaultValue: [
|
// defaultValue: [
|
||||||
{
|
// {
|
||||||
logical_operator: 'and',
|
// logical_operator: 'and',
|
||||||
expressions: []
|
// expressions: []
|
||||||
}
|
// }
|
||||||
]
|
// ]
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
// { type: "iteration", icon: iterationIcon },
|
// // { type: "iteration", icon: iterationIcon },
|
||||||
// { type: "loop", icon: loopIcon },
|
// { type: "loop", icon: loopIcon },
|
||||||
// { type: "parallel", icon: parallelIcon },
|
// // { type: "parallel", icon: parallelIcon },
|
||||||
{ type: "var-aggregator", icon: aggregatorIcon,
|
// { type: "var-aggregator", icon: aggregatorIcon,
|
||||||
config: {
|
// config: {
|
||||||
group: {
|
// group: {
|
||||||
type: 'switch',
|
// type: 'switch',
|
||||||
defaultValue: false
|
// defaultValue: false
|
||||||
},
|
// },
|
||||||
group_names: {
|
// group_names: {
|
||||||
type: 'groupVariableList',
|
// type: 'groupVariableList',
|
||||||
defaultValue: [{ key: 'Group1', value: []}]
|
// defaultValue: [{ key: 'Group1', value: []}]
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
]
|
// ]
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
category: "externalInteraction",
|
// category: "externalInteraction",
|
||||||
nodes: [
|
// nodes: [
|
||||||
{ type: "http-request", icon: httpRequestIcon,
|
// { type: "http-request", icon: httpRequestIcon,
|
||||||
config: {
|
// config: {
|
||||||
method: {
|
// method: {
|
||||||
type: 'select',
|
// type: 'select',
|
||||||
options: [
|
// options: [
|
||||||
{ label: 'GET', value: 'GET' },
|
// { label: 'GET', value: 'GET' },
|
||||||
{ label: 'POST', value: 'POST' },
|
// { label: 'POST', value: 'POST' },
|
||||||
{ label: 'HEAD', value: 'HEAD' },
|
// { label: 'HEAD', value: 'HEAD' },
|
||||||
{ label: 'PATCH', value: 'PATCH' },
|
// { label: 'PATCH', value: 'PATCH' },
|
||||||
{ label: 'PUT', value: 'PUT' },
|
// { label: 'PUT', value: 'PUT' },
|
||||||
{ label: 'DELETE', value: 'DELETE' },
|
// { label: 'DELETE', value: 'DELETE' },
|
||||||
],
|
// ],
|
||||||
defaultValue: 'GET'
|
// defaultValue: 'GET'
|
||||||
},
|
// },
|
||||||
url: {
|
// url: {
|
||||||
type: 'messageEditor',
|
// type: 'messageEditor',
|
||||||
isArray: false,
|
// isArray: false,
|
||||||
},
|
// },
|
||||||
auth: {
|
// auth: {
|
||||||
type: 'define',
|
// type: 'define',
|
||||||
defaultValue: {
|
// defaultValue: {
|
||||||
auth_type: 'none'
|
// auth_type: 'none'
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
headers: {
|
// headers: {
|
||||||
type: 'define',
|
// type: 'define',
|
||||||
defaultValue: {}
|
// defaultValue: {}
|
||||||
},
|
// },
|
||||||
params: {
|
// params: {
|
||||||
type: 'define',
|
// type: 'define',
|
||||||
defaultValue: {}
|
// defaultValue: {}
|
||||||
},
|
// },
|
||||||
body: {
|
// body: {
|
||||||
type: 'define',
|
// type: 'define',
|
||||||
defaultValue: {
|
// defaultValue: {
|
||||||
'content_type': 'none'
|
// 'content_type': 'none'
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
verify_ssl: {
|
// verify_ssl: {
|
||||||
type: 'switch',
|
// type: 'switch',
|
||||||
defaultValue: false
|
// defaultValue: false
|
||||||
},
|
// },
|
||||||
timeouts: {
|
// timeouts: {
|
||||||
type: 'define',
|
// type: 'define',
|
||||||
defaultValue: {}
|
// defaultValue: {}
|
||||||
},
|
// },
|
||||||
retry: {
|
// retry: {
|
||||||
type: 'define',
|
// type: 'define',
|
||||||
},
|
// },
|
||||||
error_handle: {
|
// error_handle: {
|
||||||
type: 'define',
|
// type: 'define',
|
||||||
defaultValue: {
|
// defaultValue: {
|
||||||
method: 'default'
|
// method: 'default'
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
// { type: "tools", icon: toolsIcon },
|
// // { type: "tools", icon: toolsIcon },
|
||||||
// { type: "code_execution", icon: codeExecutionIcon },
|
// // { type: "code_execution", icon: codeExecutionIcon },
|
||||||
{ type: "jinja-render", icon: templateRenderingIcon,
|
// { type: "jinja-render", icon: templateRenderingIcon,
|
||||||
config: {
|
// config: {
|
||||||
mapping: {
|
// mapping: {
|
||||||
type: 'mappingList',
|
// type: 'mappingList',
|
||||||
defaultValue: []
|
// defaultValue: []
|
||||||
},
|
// },
|
||||||
template: {
|
// template: {
|
||||||
type: 'messageEditor',
|
// type: 'messageEditor',
|
||||||
isArray: false,
|
// isArray: false,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
]
|
// ]
|
||||||
},
|
// },
|
||||||
// {
|
// {
|
||||||
// category: "safetyAndCompliance",
|
// category: "safetyAndCompliance",
|
||||||
// nodes: [
|
// nodes: [
|
||||||
@@ -311,8 +311,8 @@ export const nodeLibrary: NodeLibrary[] = [
|
|||||||
export const nodeRegisterLibrary: ReactShapeConfig[] = [
|
export const nodeRegisterLibrary: ReactShapeConfig[] = [
|
||||||
{
|
{
|
||||||
shape: 'loop-node',
|
shape: 'loop-node',
|
||||||
width: 200,
|
width: 240,
|
||||||
height: 200,
|
height: 80,
|
||||||
component: LoopNode,
|
component: LoopNode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -335,8 +335,8 @@ export const nodeRegisterLibrary: ReactShapeConfig[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
shape: 'group-start-node',
|
shape: 'group-start-node',
|
||||||
width: 120,
|
width: 44,
|
||||||
height: 40,
|
height: 44,
|
||||||
component: GroupStartNode,
|
component: GroupStartNode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -388,7 +388,7 @@ export const graphNodeLibrary: Record<string, NodeConfig> = {
|
|||||||
},
|
},
|
||||||
loop: {
|
loop: {
|
||||||
width: 240,
|
width: 240,
|
||||||
height: 200,
|
height: 120,
|
||||||
shape: 'loop-node',
|
shape: 'loop-node',
|
||||||
ports: {
|
ports: {
|
||||||
groups: defaultPortGroups,
|
groups: defaultPortGroups,
|
||||||
|
|||||||
@@ -762,9 +762,11 @@ export const useWorkflowGraph = ({
|
|||||||
if (data.config[key] && 'defaultValue' in data.config[key] && key !== 'knowledge_retrieval') {
|
if (data.config[key] && 'defaultValue' in data.config[key] && key !== 'knowledge_retrieval') {
|
||||||
itemConfig[key] = data.config[key].defaultValue
|
itemConfig[key] = data.config[key].defaultValue
|
||||||
} else if (key === 'knowledge_retrieval' && data.config[key] && 'defaultValue' in data.config[key]) {
|
} else if (key === 'knowledge_retrieval' && data.config[key] && 'defaultValue' in data.config[key]) {
|
||||||
|
const { knowledge_bases } = data.config[key].defaultValue
|
||||||
itemConfig = {
|
itemConfig = {
|
||||||
...itemConfig,
|
...itemConfig,
|
||||||
...data.config[key].defaultValue
|
...data.config[key].defaultValue,
|
||||||
|
knowledge_bases: knowledge_bases.map((vo: any) => ({ kb_id: vo.id, ...vo.config }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user