feat(web): 增加知识库节点
This commit is contained in:
@@ -20,6 +20,7 @@ import styled from 'styled-components'
|
|||||||
import '@xyflow/react/dist/style.css'
|
import '@xyflow/react/dist/style.css'
|
||||||
import {amisRender, commonInfo, horizontalFormOptions} from '../../../util/amis.tsx'
|
import {amisRender, commonInfo, horizontalFormOptions} from '../../../util/amis.tsx'
|
||||||
import EndNode from './node/EndNode.tsx'
|
import EndNode from './node/EndNode.tsx'
|
||||||
|
import KnowledgeNode from './node/KnowledgeNode.tsx'
|
||||||
import LlmNode from './node/LlmNode.tsx'
|
import LlmNode from './node/LlmNode.tsx'
|
||||||
import StartNode from './node/StartNode.tsx'
|
import StartNode from './node/StartNode.tsx'
|
||||||
import {useDataStore} from './store/DataStore.ts'
|
import {useDataStore} from './store/DataStore.ts'
|
||||||
@@ -84,6 +85,11 @@ function FlowEditor() {
|
|||||||
name: '大模型',
|
name: '大模型',
|
||||||
component: LlmNode,
|
component: LlmNode,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'knowledge-amis-node',
|
||||||
|
name: '知识库',
|
||||||
|
component: KnowledgeNode,
|
||||||
|
},
|
||||||
])
|
])
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
@@ -229,52 +235,78 @@ function FlowEditor() {
|
|||||||
"id": "BMFP3Eov94",
|
"id": "BMFP3Eov94",
|
||||||
"type": "start-amis-node",
|
"type": "start-amis-node",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 10,
|
"x": 8,
|
||||||
"y": 100
|
"y": 272
|
||||||
},
|
},
|
||||||
"data": {},
|
"data": {},
|
||||||
"measured": {
|
"measured": {
|
||||||
"width": 256,
|
"width": 256,
|
||||||
"height": 83
|
"height": 75
|
||||||
},
|
},
|
||||||
"selected": false
|
"selected": false,
|
||||||
|
"dragging": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "PYK8LjduQ1",
|
"id": "PYK8LjduQ1",
|
||||||
"type": "end-amis-node",
|
"type": "end-amis-node",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 654,
|
"x": 736,
|
||||||
"y": 332
|
"y": 317
|
||||||
},
|
},
|
||||||
"data": {},
|
"data": {},
|
||||||
"measured": {
|
"measured": {
|
||||||
"width": 256,
|
"width": 256,
|
||||||
"height": 83
|
"height": 75
|
||||||
},
|
},
|
||||||
"selected": false,
|
"selected": true,
|
||||||
"dragging": false
|
"dragging": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "nCm-ij5I6o",
|
"id": "nCm-ij5I6o",
|
||||||
"type": "llm-amis-node",
|
"type": "llm-amis-node",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 318,
|
"x": 438,
|
||||||
"y": 208
|
"y": 113
|
||||||
},
|
},
|
||||||
"data": {},
|
"data": {},
|
||||||
"measured": {
|
"measured": {
|
||||||
"width": 256,
|
"width": 256,
|
||||||
"height": 83
|
"height": 75
|
||||||
},
|
},
|
||||||
"selected": true,
|
"selected": false,
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "9RIg65O0YQ",
|
||||||
|
"type": "knowledge-amis-node",
|
||||||
|
"position": {
|
||||||
|
"x": 352,
|
||||||
|
"y": 387
|
||||||
|
},
|
||||||
|
"data": {},
|
||||||
|
"measured": {
|
||||||
|
"width": 256,
|
||||||
|
"height": 75
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
"dragging": false
|
"dragging": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"edges": [
|
"edges": [
|
||||||
{
|
{
|
||||||
"source": "BMFP3Eov94",
|
"source": "BMFP3Eov94",
|
||||||
|
"target": "9RIg65O0YQ",
|
||||||
|
"id": "xy-edge__BMFP3Eov94-9RIg65O0YQ"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "9RIg65O0YQ",
|
||||||
"target": "nCm-ij5I6o",
|
"target": "nCm-ij5I6o",
|
||||||
"id": "xy-edge__BMFP3Eov94-nCm-ij5I6o"
|
"id": "xy-edge__9RIg65O0YQ-nCm-ij5I6o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "nCm-ij5I6o",
|
||||||
|
"target": "PYK8LjduQ1",
|
||||||
|
"id": "xy-edge__nCm-ij5I6o-PYK8LjduQ1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"data": {
|
"data": {
|
||||||
@@ -297,6 +329,12 @@ function FlowEditor() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systemPrompt": "你是个沙雕"
|
"systemPrompt": "你是个沙雕"
|
||||||
|
},
|
||||||
|
"9RIg65O0YQ": {
|
||||||
|
"count": 3,
|
||||||
|
"score": 0.75,
|
||||||
|
"knowledgeId": 3585368238960640,
|
||||||
|
"query": "hello world"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`)
|
}`)
|
||||||
|
|||||||
59
service-web/client/src/pages/ai/flow/node/KnowledgeNode.tsx
Normal file
59
service-web/client/src/pages/ai/flow/node/KnowledgeNode.tsx
Normal 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
|
||||||
@@ -4,7 +4,7 @@ import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
|||||||
const LlmNode = (props: NodeProps) => AmisNode(
|
const LlmNode = (props: NodeProps) => AmisNode(
|
||||||
props,
|
props,
|
||||||
'normal',
|
'normal',
|
||||||
'大模型节点',
|
'大模型',
|
||||||
'使用大模型对话',
|
'使用大模型对话',
|
||||||
undefined,
|
undefined,
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user