mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 14:04:47 +08:00
Demo:AI续写支持修改提示词
This commit is contained in:
@@ -511,7 +511,10 @@ export default {
|
||||
aiCreatePartMsgCenter:
|
||||
'】Can you help me continue writing one of the contents of the mind map【',
|
||||
aiCreatePartMsgPostfix:
|
||||
'】The subordinate content of the node needs to be returned in Markdown format and can only use two syntax: Markdown title and unordered list. It can support multi-level nesting. Just return the content.'
|
||||
'】The subordinate content of the node',
|
||||
aiCreatePartMsgHelp:
|
||||
'. Needs to be returned in Markdown format and can only use two syntax: Markdown title and unordered list. It can support multi-level nesting. Just return the content.',
|
||||
aiCreatePart: 'AI Continuation'
|
||||
},
|
||||
note: {
|
||||
title: 'Note'
|
||||
|
||||
@@ -491,8 +491,10 @@ export default {
|
||||
'】,需要以Markdown格式返回,并且只能使用Markdown的标题和无序列表两种语法,可以支持多层嵌套。只需返回内容即可。',
|
||||
aiCreatePartMsgPrefix: '我有一个主题为【',
|
||||
aiCreatePartMsgCenter: '】的思维导图,帮我续写其中一个内容为【',
|
||||
aiCreatePartMsgPostfix:
|
||||
'】的节点的下级内容,需要以Markdown格式返回,并且只能使用Markdown的标题和无序列表两种语法,可以支持多层嵌套。只需返回内容即可。'
|
||||
aiCreatePartMsgPostfix: '】的节点的下级内容',
|
||||
aiCreatePartMsgHelp:
|
||||
'。需要以Markdown格式返回,并且只能使用Markdown的标题和无序列表两种语法,可以支持多层嵌套。只需返回内容即可。',
|
||||
aiCreatePart: 'AI续写'
|
||||
},
|
||||
note: {
|
||||
title: '备注'
|
||||
|
||||
@@ -492,7 +492,10 @@ export default {
|
||||
aiCreatePartMsgPrefix: '我有一個主題爲【',
|
||||
aiCreatePartMsgCenter: '】的思維導圖,幫我續寫其中一個內容爲【',
|
||||
aiCreatePartMsgPostfix:
|
||||
'】的節點的下級內容,需要以Markdown格式返回,並且只能使用Markdown的標題和無序列表兩種語法,可以支持多層嵌套。只需返回內容即可。'
|
||||
'】的節點的下級內容',
|
||||
aiCreatePartMsgHelp:
|
||||
'。需要以Markdown格式返回,並且只能使用Markdown的標題和無序列表兩種語法,可以支持多層嵌套。只需返回內容即可。',
|
||||
aiCreatePart: 'AI續寫'
|
||||
},
|
||||
note: {
|
||||
title: '備註'
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
<el-option key="GET" label="GET" value="GET"></el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<p class="title">{{ $t('ai.mindMappingClientConfiguration') }}</p>
|
||||
<!-- <p class="title">{{ $t('ai.mindMappingClientConfiguration') }}</p>
|
||||
<el-form-item :label="$t('ai.port')" prop="port">
|
||||
<el-input v-model="ruleForm.port"></el-input>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
|
||||
@@ -78,6 +78,26 @@
|
||||
}}</el-button>
|
||||
</div>
|
||||
<AiConfigDialog v-model="aiConfigDialogVisible"></AiConfigDialog>
|
||||
<!-- AI续写 -->
|
||||
<el-dialog
|
||||
class="createDialog"
|
||||
:title="$t('ai.aiCreatePart')"
|
||||
:visible.sync="createPartDialogVisible"
|
||||
width="450px"
|
||||
append-to-body
|
||||
>
|
||||
<div class="inputBox">
|
||||
<el-input type="textarea" :rows="5" v-model="aiPartInput"> </el-input>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="closeAiCreatePartDialog">{{
|
||||
$t('ai.cancel')
|
||||
}}</el-button>
|
||||
<el-button type="primary" @click="confirmAiCreatePart">{{
|
||||
$t('ai.confirm')
|
||||
}}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -119,7 +139,11 @@ export default {
|
||||
aiConfigDialogVisible: false,
|
||||
|
||||
mindMapDataCache: '',
|
||||
beingAiCreateNodeUid: ''
|
||||
beingAiCreateNodeUid: '',
|
||||
|
||||
createPartDialogVisible: false,
|
||||
aiPartInput: '',
|
||||
beingCreatePartNode: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -127,7 +151,7 @@ export default {
|
||||
},
|
||||
created() {
|
||||
this.$bus.$on('ai_create_all', this.aiCrateAll)
|
||||
this.$bus.$on('ai_create_part', this.aiCreatePart)
|
||||
this.$bus.$on('ai_create_part', this.showAiCreatePartDialog)
|
||||
this.$bus.$on('ai_chat', this.aiChat)
|
||||
this.$bus.$on('ai_chat_stop', this.aiChatStop)
|
||||
this.$bus.$on('showAiConfigDialog', this.showAiConfigDialog)
|
||||
@@ -137,7 +161,7 @@ export default {
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$bus.$off('ai_create_all', this.aiCrateAll)
|
||||
this.$bus.$off('ai_create_part', this.aiCreatePart)
|
||||
this.$bus.$off('ai_create_part', this.showAiCreatePartDialog)
|
||||
this.$bus.$off('ai_chat', this.aiChat)
|
||||
this.$bus.$off('ai_chat_stop', this.aiChatStop)
|
||||
this.$bus.$off('showAiConfigDialog', this.showAiConfigDialog)
|
||||
@@ -372,11 +396,47 @@ export default {
|
||||
walk(data)
|
||||
},
|
||||
|
||||
// 显示AI续写弹窗
|
||||
showAiCreatePartDialog(node) {
|
||||
this.beingCreatePartNode = node
|
||||
const currentMindMapData = this.mindMap.getData()
|
||||
// 填充默认内容
|
||||
this.aiPartInput = `${this.$t(
|
||||
'ai.aiCreatePartMsgPrefix'
|
||||
)}${getStrWithBrFromHtml(currentMindMapData.data.text)}${this.$t(
|
||||
'ai.aiCreatePartMsgCenter'
|
||||
)}${getStrWithBrFromHtml(node.getData('text'))}${this.$t(
|
||||
'ai.aiCreatePartMsgPostfix'
|
||||
)}`
|
||||
this.createPartDialogVisible = true
|
||||
},
|
||||
|
||||
// 关闭AI续写弹窗
|
||||
closeAiCreatePartDialog() {
|
||||
this.createPartDialogVisible = false
|
||||
},
|
||||
|
||||
// 复位AI续写弹窗数据
|
||||
resetAiCreatePartDialog() {
|
||||
this.beingCreatePartNode = null
|
||||
this.aiPartInput = ''
|
||||
},
|
||||
|
||||
// 确认AI续写
|
||||
confirmAiCreatePart() {
|
||||
if (!this.aiPartInput.trim()) return
|
||||
this.closeAiCreatePartDialog()
|
||||
this.aiCreatePart()
|
||||
},
|
||||
|
||||
// AI生成部分
|
||||
async aiCreatePart(node) {
|
||||
async aiCreatePart() {
|
||||
try {
|
||||
if (!this.beingCreatePartNode) {
|
||||
return
|
||||
}
|
||||
await this.aiTest()
|
||||
this.beingAiCreateNodeUid = node.getData('uid')
|
||||
this.beingAiCreateNodeUid = this.beingCreatePartNode.getData('uid')
|
||||
const currentMindMapData = this.mindMap.getData()
|
||||
this.mindMapDataCache = JSON.stringify(currentMindMapData)
|
||||
this.aiCreatingMaskVisible = true
|
||||
@@ -391,13 +451,8 @@ export default {
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: `${this.$t(
|
||||
'ai.aiCreatePartMsgPrefix'
|
||||
)}${getStrWithBrFromHtml(
|
||||
currentMindMapData.data.text
|
||||
)}${this.$t('ai.aiCreatePartMsgCenter')}${getStrWithBrFromHtml(
|
||||
node.getData('text')
|
||||
)}${this.$t('ai.aiCreatePartMsgPostfix')}`
|
||||
content:
|
||||
this.aiPartInput.trim() + this.$t('ai.aiCreatePartMsgHelp')
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -412,9 +467,11 @@ export default {
|
||||
content => {
|
||||
this.aiCreatingContent = content
|
||||
this.resetOnAiCreatingStop()
|
||||
this.resetAiCreatePartDialog()
|
||||
},
|
||||
() => {
|
||||
this.resetOnAiCreatingStop()
|
||||
this.resetAiCreatePartDialog()
|
||||
this.resetOnRenderEnd()
|
||||
this.$message.error(this.$t('ai.generationFailed'))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user