feat(web): 增加知识库节点

This commit is contained in:
v-zhangjc9
2025-06-25 17:25:50 +08:00
parent 3a51d1e33f
commit 33df256863
3 changed files with 111 additions and 14 deletions

View File

@@ -0,0 +1,59 @@
import type {NodeProps} from '@xyflow/react'
import {commonInfo} from '../../../../util/amis.tsx'
import AmisNode from './AmisNode.tsx'
// @ts-ignore
const KnowledgeNode = (props: NodeProps) => AmisNode(
props,
'normal',
'知识库',
'查询知识库获取外部知识',
undefined,
[
{
type: 'select',
name: 'knowledgeId',
label: '知识库',
required: true,
options: [],
source: {
method: 'get',
url: `${commonInfo.baseAiUrl}/knowledge/list`,
// @ts-ignore
adaptor: (payload, response, api, context) => {
return {
...payload,
data: {
items: payload.data.items.map((item: any) => ({value: item['id'], label: item['name']})),
}
}
},
},
},
{
type: 'input-text',
name: 'query',
label: '查询文本',
required: true,
},
{
type: 'input-range',
name: 'count',
label: '返回数量',
required: true,
value: 3,
max: 10,
},
{
type: 'input-range',
name: 'score',
label: '匹配阀值',
required: true,
value: 0.6,
max: 1,
step: 0.05,
},
],
)
export default KnowledgeNode