|
@@ -24,22 +24,18 @@
|
|
<div class="title">角色昵称<span>*</span></div>
|
|
<div class="title">角色昵称<span>*</span></div>
|
|
<input type="text" v-model="agentDto.agentName" placeholder="请输入角色昵称" placeholder-class="ph">
|
|
<input type="text" v-model="agentDto.agentName" placeholder="请输入角色昵称" placeholder-class="ph">
|
|
</div>
|
|
</div>
|
|
- <div class="box adfacjb" @tap="selectModel">
|
|
|
|
- <div class="title">角色模板<span>*</span></div>
|
|
|
|
- <div class="right adfac">
|
|
|
|
- <div class="mtext" :class="{'active':modelText!=='请选择角色模版'}">{{modelText}}</div>
|
|
|
|
- <image src="http://106.54.209.120:8188/static/arrow_right.png"></image>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
<div class="box">
|
|
<div class="box">
|
|
<div class="top adfacjb">
|
|
<div class="top adfacjb">
|
|
- <div class="title">设备描述</div>
|
|
|
|
- <div class="tip">回显不可编辑</div>
|
|
|
|
|
|
+ <div class="title">设定描述<span>*</span></div>
|
|
|
|
+ <div class="tip" @tap="selectModel">角色设定辅助 ></div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="desc">
|
|
|
|
+ <u-parse :content="placeholder" @tap="showta=true;focus=true" v-if="!showta" style="color: #A6A6A6;font-size: 28rpx;line-height: 48rpx;"></u-parse>
|
|
|
|
+ <u-textarea v-model="agentDto.systemPrompt" :focus="focus" autoHeight :maxlength="-1" border="none" v-else></u-textarea>
|
|
</div>
|
|
</div>
|
|
- <div class="desc">{{deviceMemo||''}}</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="box adfacjb">
|
|
<div class="box adfacjb">
|
|
- <div class="title">音色<span>*</span></div>
|
|
|
|
|
|
+ <div class="title">声音<span>*</span></div>
|
|
<div class="right adfac" @tap="show=true">
|
|
<div class="right adfac" @tap="show=true">
|
|
<div class="mtext" :class="{'active':voiceText!=='请选择音色'}">{{voiceText}}</div>
|
|
<div class="mtext" :class="{'active':voiceText!=='请选择音色'}">{{voiceText}}</div>
|
|
<image src="http://106.54.209.120:8188/static/arrow_right.png"></image>
|
|
<image src="http://106.54.209.120:8188/static/arrow_right.png"></image>
|
|
@@ -58,15 +54,17 @@
|
|
data(){
|
|
data(){
|
|
return {
|
|
return {
|
|
title:'创建角色',
|
|
title:'创建角色',
|
|
- modelText:'请选择角色模版',
|
|
|
|
voiceText:'请选择音色',
|
|
voiceText:'请选择音色',
|
|
fileList:[],
|
|
fileList:[],
|
|
show:false,
|
|
show:false,
|
|
voiceList:[],
|
|
voiceList:[],
|
|
- deviceMemo:'',
|
|
|
|
modelMap:new Map(),
|
|
modelMap:new Map(),
|
|
agentId:'',
|
|
agentId:'',
|
|
deviceId:'',
|
|
deviceId:'',
|
|
|
|
+ showta:false,
|
|
|
|
+ focus:false,
|
|
|
|
+ placeholder:`详细描写设定信息,示例:<br>
|
|
|
|
+ 你是一位经验丰富的英语老师,拥有激发学生学习热情的教学方法。你善于运用幽默和实际应用案例,使对话充满趣味。`,
|
|
agentDto:{
|
|
agentDto:{
|
|
"agentName": "",
|
|
"agentName": "",
|
|
"asrModelId": "",
|
|
"asrModelId": "",
|
|
@@ -79,7 +77,8 @@
|
|
"systemPrompt": "",
|
|
"systemPrompt": "",
|
|
"langCode": "",
|
|
"langCode": "",
|
|
"language": "",
|
|
"language": "",
|
|
- "deviceId": ""
|
|
|
|
|
|
+ "deviceId": "",
|
|
|
|
+ "chatHistoryConf": ""
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -90,6 +89,17 @@
|
|
this.deviceId = option.deviceId;
|
|
this.deviceId = option.deviceId;
|
|
this.getDetail();
|
|
this.getDetail();
|
|
}
|
|
}
|
|
|
|
+ this.getModelVoiceList();
|
|
|
|
+ },
|
|
|
|
+ watch:{
|
|
|
|
+ "agentDto.systemPrompt":{
|
|
|
|
+ handler(newVal,oldVal){
|
|
|
|
+ if(newVal!==oldVal&&!newVal){
|
|
|
|
+ this.showta = false;
|
|
|
|
+ this.focus = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
methods:{
|
|
methods:{
|
|
// 删除图片
|
|
// 删除图片
|
|
@@ -149,19 +159,18 @@
|
|
url:'/pagesRole/roleModel',
|
|
url:'/pagesRole/roleModel',
|
|
events:{
|
|
events:{
|
|
selectRoleModel:data=>{
|
|
selectRoleModel:data=>{
|
|
|
|
+ this.showta = true;
|
|
this.agentDto = {...this.agentDto,...data};
|
|
this.agentDto = {...this.agentDto,...data};
|
|
- this.modelText = data.agentName||'';
|
|
|
|
- this.deviceMemo = data.systemPrompt||'';
|
|
|
|
this.getModelVoiceList();
|
|
this.getModelVoiceList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
getModelVoiceList(){
|
|
getModelVoiceList(){
|
|
- this.$api.get(`/models/${this.agentDto.ttsModelId}/voices`).then(res=>{
|
|
|
|
|
|
+ this.$api.get(`/models/${'TTS_EdgeTTS'}/voices`).then(res=>{
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
this.voiceList = [res.data.data];
|
|
this.voiceList = [res.data.data];
|
|
- this.voiceText = res.data.data.find(v=>v.id===this.agentDto.ttsVoiceId)?.name||'';
|
|
|
|
|
|
+ this.voiceText = res.data.data.find(v=>v.id===this.agentDto.ttsVoiceId)?.name||'请选择音色';
|
|
})
|
|
})
|
|
},
|
|
},
|
|
confirm(e){
|
|
confirm(e){
|
|
@@ -171,17 +180,25 @@
|
|
},
|
|
},
|
|
comfirmSure(){
|
|
comfirmSure(){
|
|
if(!this.agentDto.agentName) return this.$showToast('请输入角色昵称')
|
|
if(!this.agentDto.agentName) return this.$showToast('请输入角色昵称')
|
|
- if(this.agentDto.modelText==='请选择角色模版') return this.$showToast('请选择角色模板')
|
|
|
|
if(this.agentDto.voiceText==='请选择音色') return this.$showToast('请选择音色')
|
|
if(this.agentDto.voiceText==='请选择音色') return this.$showToast('请选择音色')
|
|
|
|
|
|
let dto = JSON.parse(JSON.stringify(this.agentDto));
|
|
let dto = JSON.parse(JSON.stringify(this.agentDto));
|
|
if(this.agentId) dto.deviceId = this.deviceId;
|
|
if(this.agentId) dto.deviceId = this.deviceId;
|
|
|
|
+ //默认固定值(暂时)
|
|
|
|
+ dto.asrModelId = 'ASR_FunASR';
|
|
|
|
+ dto.vadModelId = 'VAD_SileroVAD';
|
|
|
|
+ dto.llmModelId = 'LLM_ChatGLMLLM';
|
|
|
|
+ dto.ttsModelId = 'TTS_EdgeTTS';
|
|
|
|
+ dto.memModelId = 'Memory_mem_local_short';
|
|
|
|
+ dto.intentModelId = 'Intent_function_call';
|
|
|
|
+ dto.chatHistoryConf = 1;
|
|
|
|
+ dto.langCode = 'zh';
|
|
|
|
+ dto.language = '中文';
|
|
this.$api.post(this.agentId?`/agent/update/${this.agentId}`:'/agent',dto).then(res=>{
|
|
this.$api.post(this.agentId?`/agent/update/${this.agentId}`:'/agent',dto).then(res=>{
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
this.$showToast(this.agentId?'编辑成功':'创建成功');
|
|
this.$showToast(this.agentId?'编辑成功':'创建成功');
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
- let url = this.agentId?'/pages/home':'/pages/role'
|
|
|
|
- uni.reLaunch({ url })
|
|
|
|
|
|
+ uni.reLaunch({ url:'/pages/role' })
|
|
},1500)
|
|
},1500)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -189,24 +206,19 @@
|
|
this.$api.get(`/agent/${this.agentId}`).then(res=>{
|
|
this.$api.get(`/agent/${this.agentId}`).then(res=>{
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
this.agentDto = {...this.agentDto,...res.data.data};
|
|
this.agentDto = {...this.agentDto,...res.data.data};
|
|
- this.deviceMemo = this.agentDto.systemPrompt;
|
|
|
|
|
|
+ if(this.agentDto.systemPrompt) this.showta = true;
|
|
this.getModelVoiceList();
|
|
this.getModelVoiceList();
|
|
- this.getAgentModelList();
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- getAgentModelList(){
|
|
|
|
- this.$api.get('/agent/template').then(res=>{
|
|
|
|
- if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
|
|
- if(res.data.data.length){
|
|
|
|
- this.modelText = res.data.data.find(d=>d.systemPrompt===this.agentDto.systemPrompt)?.agentName;
|
|
|
|
- }
|
|
|
|
})
|
|
})
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
-<style scoped lang="less">
|
|
|
|
|
|
+<style scoped lang="scss">
|
|
|
|
+ ::v-deep .desc .u-textarea{
|
|
|
|
+ padding: 0 !important;
|
|
|
|
+ }
|
|
|
|
+
|
|
.ph{
|
|
.ph{
|
|
font-family: PingFangSC, PingFang SC;
|
|
font-family: PingFangSC, PingFang SC;
|
|
font-weight: 400;
|
|
font-weight: 400;
|
|
@@ -278,12 +290,13 @@
|
|
.desc{
|
|
.desc{
|
|
margin-top: 20rpx;
|
|
margin-top: 20rpx;
|
|
min-height: 200rpx;
|
|
min-height: 200rpx;
|
|
|
|
+ overflow-y: auto;
|
|
}
|
|
}
|
|
.tip{
|
|
.tip{
|
|
font-family: PingFangSC, PingFang SC;
|
|
font-family: PingFangSC, PingFang SC;
|
|
font-weight: 400;
|
|
font-weight: 400;
|
|
font-size: 28rpx;
|
|
font-size: 28rpx;
|
|
- color: #A6A6A6;
|
|
|
|
|
|
+ color: #1B50FF;
|
|
line-height: 40rpx;
|
|
line-height: 40rpx;
|
|
text-align: right;
|
|
text-align: right;
|
|
}
|
|
}
|