66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import type {NodeProps} from '@xyflow/react'
|
|
import {commonInfo} from '../../../util/amis.tsx'
|
|
import AmisNode, {inputsFormColumns, outputsFormColumns} from './AmisNode.tsx'
|
|
import React from 'react'
|
|
|
|
const KnowledgeNode = (props: NodeProps) => AmisNode({
|
|
nodeProps: props,
|
|
type: 'normal',
|
|
defaultNodeName: '知识库',
|
|
defaultNodeDescription: '查询知识库获取外部知识',
|
|
columnSchema: [
|
|
...inputsFormColumns(),
|
|
{
|
|
type: 'divider',
|
|
},
|
|
{
|
|
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,
|
|
},
|
|
{
|
|
type: 'divider',
|
|
},
|
|
...outputsFormColumns(false, true, {result: {type: 'array-string'}}),
|
|
],
|
|
})
|
|
|
|
export default React.memo(KnowledgeNode) |