Skip to content

Commit 63078ff

Browse files
committed
update:切换llm和智能体时动态变化系统提示词
1 parent 5734677 commit 63078ff

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

web/src/views/page/Role.vue

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,17 @@
411411
<a-icon type="snippets" /> 模板管理
412412
</a-button>
413413
</div>
414-
415-
<!-- 提示词编辑区域 -->
416-
<a-form-item>
417-
<a-textarea v-decorator="[
418-
'roleDesc',
419-
{
420-
rules: [],
421-
},
422-
]" :rows="10" placeholder="请输入角色提示词,描述角色的特点、知识背景和行为方式等" />
423-
</a-form-item>
424414
</template>
415+
416+
<!-- 提示词编辑区域 -->
417+
<a-form-item>
418+
<a-textarea v-decorator="[
419+
'roleDesc',
420+
{
421+
rules: [],
422+
},
423+
]" :disabled="selectedModelType === 'agent'" :rows="10" placeholder="请输入角色提示词,描述角色的特点、知识背景和行为方式等" />
424+
</a-form-item>
425425
<!-- 表单操作按钮 -->
426426
<a-form-item>
427427
<a-button type="primary" html-type="submit" :loading="submitLoading">
@@ -470,6 +470,7 @@ export default {
470470
submitLoading: false,
471471
activeTabKey: '1',
472472
editingRoleId: null,
473+
editingRoleDesc: '',
473474
474475
// 查询相关
475476
query: {},
@@ -1272,7 +1273,7 @@ export default {
12721273
// 编辑角色
12731274
edit(record) {
12741275
this.editingRoleId = record.roleId;
1275-
1276+
this.editingRoleDesc = record.roleDesc;
12761277
// 切换到创建角色标签页
12771278
this.activeTabKey = '2';
12781279
@@ -1602,7 +1603,8 @@ export default {
16021603
this.$nextTick(() => {
16031604
this.roleForm.setFieldsValue({
16041605
modelProvider: undefined,
1605-
modelId: undefined
1606+
modelId: undefined,
1607+
roleDesc: this.selectedModelType === MODEL_TYPE.LLM ? this.editingRoleDesc : '' // 如果切换回 LLM 恢复原始 roleDesc
16061608
});
16071609
});
16081610
},
@@ -1625,13 +1627,17 @@ export default {
16251627
if (this.selectedModelType === MODEL_TYPE.LLM) {
16261628
const model = this.modelItems.find(m => m.configId === value);
16271629
if (model) {
1628-
// 可以在这里设置与模型相关的其他字段
1630+
this.roleForm.setFieldsValue({
1631+
roleDesc: this.editingRoleDesc
1632+
});
16291633
}
16301634
} else if (this.selectedModelType === MODEL_TYPE.AGENT) {
16311635
const agentList = this.selectedModelProvider === PROVIDER.COZE ? this.cozeAgents : this.difyAgents;
16321636
const agent = agentList.find(a => a.configId === value);
16331637
if (agent) {
1634-
// 可以在这里设置与智能体相关的其他字段
1638+
this.roleForm.setFieldsValue({
1639+
roleDesc: agent.agentDesc || ''
1640+
});
16351641
}
16361642
}
16371643
},

0 commit comments

Comments
 (0)