feat: 工作编排

This commit is contained in:
wangdan-fit2cloud 2024-06-14 17:23:32 +08:00
parent 52c7bb495d
commit 37d30af772
8 changed files with 73 additions and 99 deletions

View File

@ -378,13 +378,13 @@ export const iconMap: any = {
'svg',
{
style: { height: '100%', width: '100%' },
viewBox: '0 0 16 16',
viewBox: '0 0 1024 1024',
version: '1.1',
xmlns: 'http://www.w3.org/2000/svg'
},
[
h('path', {
d: 'M3.33333 5.3335V13.3335H10V5.3335H3.33333ZM11.3333 4.66683V14.0742C11.3333 14.4015 11.0548 14.6668 10.7111 14.6668H2.62222C2.27858 14.6668 2 14.4015 2 14.0742V4.59276C2 4.26548 2.27858 4.00016 2.62222 4.00016H10.6667C11.0349 4.00016 11.3333 4.29864 11.3333 4.66683ZM13.8047 1.52876C13.9254 1.6494 14 1.81607 14 2.00016V10.3335C14 10.5176 13.8508 10.6668 13.6667 10.6668H13C12.8159 10.6668 12.6667 10.5176 12.6667 10.3335V2.66683H6.33333C6.14924 2.66683 6 2.51759 6 2.3335V1.66683C6 1.48273 6.14924 1.3335 6.33333 1.3335H13.3333C13.5174 1.3335 13.6841 1.40812 13.8047 1.52876Z',
d: 'M213.333333 341.333333v512h426.666667V341.333333H213.333333z m512-42.666666v602.069333c0 20.949333-17.834667 37.930667-39.808 37.930667H167.808C145.834667 938.666667 128 921.685333 128 900.736V293.973333C128 272.981333 145.834667 256 167.808 256H682.666667a42.666667 42.666667 0 0 1 42.666666 42.666667z m158.165334-200.832A42.538667 42.538667 0 0 1 896 128v533.333333a21.333333 21.333333 0 0 1-21.333333 21.333334h-42.666667a21.333333 21.333333 0 0 1-21.333333-21.333334V170.666667H405.333333a21.333333 21.333333 0 0 1-21.333333-21.333334v-42.666666a21.333333 21.333333 0 0 1 21.333333-21.333334H853.333333c11.776 0 22.442667 4.778667 30.165334 12.501334z',
fill: 'currentColor'
})
]

View File

@ -30,6 +30,21 @@ class AppNode extends HtmlNode {
for (const [key, component] of Object.entries(ElementPlusIcons)) {
this.app.component(key, component)
}
if (props.model.properties.noRender) {
delete props.model.properties.noRender
} else {
const filterNodes = props.graphModel.nodes.filter((v: any) => v.type === props.model.type)
if (filterNodes.length - 1 > 0) {
props.model.properties.stepName = props.model.properties.stepName + (filterNodes.length - 1)
}
if (props.model.properties?.fields?.length > 0) {
props.model.properties.fields.map((item: any) => {
item['globeLabel'] = `{{${props.model.properties.stepName}.${item.value}}}`
item['globeValue'] = `{{content[${props.model.id}].${item.value}}}`
})
}
}
}
setHtml(rootEl: HTMLElement) {

View File

@ -30,7 +30,9 @@ export const baseNodes = [
fields: [
{
label: '用户问题',
value: 'question'
value: 'question',
globeLabel: '{{开始.question}}',
globeValue: "{{content['start-node'].question}}"
}
]
}

View File

@ -129,10 +129,18 @@ const graphData = {
height: '',
stepName: '知识库检索',
fields: [
{ label: '段落列表', value: 'paragraph_list' },
{ label: '满足直接回答的段落列表', value: 'is_hit_handling_method_list' },
{ label: '检索结果', value: 'data' },
{ label: '满足直接回答的分段内容', value: 'directly_return' }
{
label: '检索结果',
value: 'data',
globeLabel: '{{知识库检索.data}}',
globeValue: "{{content['34902d3d-a3ff-497f-b8e1-0c34a44d7dd5'].data}}"
},
{
label: '满足直接回答的分段内容',
value: 'paragraph',
globeLabel: '{{知识库检索.paragraph}}',
globeValue: "{{content['34902d3d-a3ff-497f-b8e1-0c34a44d7dd5'].paragraph}}"
}
],
node_data: {
dataset_id_list: ['8ba47817-28a1-11ef-90fd-a8a1595801ab'],
@ -147,100 +155,28 @@ const graphData = {
}
},
{
id: 'bd9dd852-d749-4b42-9b95-80f25b9a606d',
type: 'ai-chat-node',
x: 2430,
y: 310,
properties: {
height: '',
stepName: 'AI 对话',
fields: [{ label: 'AI 回答内容', value: 'answer' }],
node_data: {
model_id: '9bdd1ab3-135b-11ef-b688-a8a1595801ab',
system: '你是售前咨询知识库',
prompt:
"已知信息:\n{{context['2ac57a56-9150-4f04-a7b9-6390bdaade19'].data}}\n问题\n{{context['start-node'].question}}",
dialogue_number: 0
}
}
},
{
id: '1cd54877-bfff-4791-b8f5-08c49f8bdf66',
type: 'search-dataset-node',
x: 1770,
y: 840,
properties: {
height: '',
stepName: '知识库检索',
fields: [
{ label: '段落列表', value: 'paragraph_list' },
{ label: '满足直接回答的段落列表', value: 'is_hit_handling_method_list' },
{ label: '检索结果', value: 'data' },
{ label: '满足直接回答的分段内容', value: 'directly_return' }
],
node_data: {
dataset_id_list: ['188c3fa1-28a3-11ef-99e8-a8a1595801ab'],
dataset_setting: {
top_n: 3,
similarity: 0.6,
max_paragraph_char_number: 5000,
search_mode: 'embedding'
},
question_reference_address: ['start-node', 'question']
}
}
},
{
id: 'e99869b2-251f-47a7-9966-c54ffb59b381',
noRender: true,
id: '34902d3d-a3ff-497f-b8e1-0c34a44d7dd6',
type: 'condition-node',
x: 2310,
y: 930,
x: 810,
y: 760,
properties: {
noRender: true,
width: 600,
stepName: '判断器',
node_data: {
branch: [
{
conditions: [
{
field: ['1cd54877-bfff-4791-b8f5-08c49f8bdf66', 'is_hit_handling_method_list'],
compare: 'ge',
value: '1'
}
],
id: '3014',
type: 'IF',
condition: 'and'
},
{
conditions: [
{
field: ['1cd54877-bfff-4791-b8f5-08c49f8bdf66', 'paragraph_list'],
compare: 'ge',
value: '1'
}
],
type: 'ELSE IF 1',
id: '4658',
condition: 'and'
},
{ conditions: [], id: '8871', type: 'ELSE', condition: 'and' }
]
},
branch_condition_list: [
{ index: 0, height: 115.778, id: '3014' },
{ index: 1, height: 115.778, id: '4658' },
{ index: 2, height: 40, id: '8871' }
]
input: [{ key: '输入' }],
output: [{ key: '9208' }, { key: '1143' }, { key: '输出' }]
}
},
{
id: '62ab766b-b218-4bea-895f-b7e83614c8b7',
id: '30c16d31-3881-48cd-991e-da3f99c45681',
type: 'reply-node',
x: 2940,
y: 530,
properties: {
height: '',
noRender: true,
stepName: '指定回复',
node_data: {
reply_type: 'referencing',
@ -294,6 +230,34 @@ const graphData = {
dialogue_number: 0
}
}
},
{
id: '4529cbc1-6389-48f3-afd5-3df7db4292a1',
type: 'ai-chat-node',
x: 530,
y: 730,
properties: {
height: '',
stepName: 'AI 对话',
input: [{ key: '' }],
output: [{ key: '' }],
fields: [
{
label: 'AI 回答内容',
value: 'content',
globeLabel: '{{AI 对话.content}}',
globeValue: '{{content[4529cbc1-6389-48f3-afd5-3df7db4292a1].content}}'
}
],
node_data: {
model_id: '',
system: '',
prompt:
'已知信息:\n{data}\n回答要求\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题\n{question}',
dialogue_number: 1
}
}
}
],
edges: [

View File

@ -122,8 +122,7 @@
</el-form-item>
</el-form>
</el-card>
<h5 class="title-decoration-1 mb-8 mt-8">参数输出</h5>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">AI 回答内容 {content}</div>
<!-- 添加模版 -->
<CreateModelDialog
ref="createModelRef"
@ -145,6 +144,7 @@ import applicationApi from '@/api/application'
import useStore from '@/stores'
import { relatedObject } from '@/utils/utils'
import type { Provider } from '@/api/type/model'
const { model } = useStore()
const {

View File

@ -123,8 +123,6 @@
</el-form-item>
</el-form>
</el-card>
<h5 class="title-decoration-1 mb-8 mt-8">参数输出</h5>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">用户问题 {question}</div>
<!-- 添加模版 -->
<CreateModelDialog
ref="createModelRef"

View File

@ -91,9 +91,6 @@
</el-form-item>
</el-form>
</el-card>
<h5 class="title-decoration-1 mb-8 mt-8">参数输出</h5>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">检索结果 {data}</div>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">满足直接回答的分段内容 {paragraph}</div>
<ParamSettingDialog ref="ParamSettingDialogRef" @refresh="refreshParam" />
<AddDatasetDialog
ref="AddDatasetDialogRef"

View File

@ -2,8 +2,6 @@
<NodeContainer :nodeModel="nodeModel">
<h5 class="title-decoration-1 mb-8">全局变量</h5>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">当前时间 {time}</div>
<h5 class="title-decoration-1 mb-8">参数输出</h5>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">用户问题 {question}</div>
</NodeContainer>
</template>
<script setup lang="ts">