فهرست منبع

最新需求调整优化等

htc 1 هفته پیش
والد
کامیت
d980d99c35
5فایلهای تغییر یافته به همراه132 افزوده شده و 70 حذف شده
  1. 11 1
      components/deviceBox/index.vue
  2. 52 30
      pages/role.vue
  3. 1 1
      pagesMy/scanResult.vue
  4. 46 33
      pagesRole/addRole.vue
  5. 22 5
      pagesRole/roleModel.vue

+ 11 - 1
components/deviceBox/index.vue

@@ -23,7 +23,8 @@
 				<u--text :lines="3" :text="item.agent.systemPrompt||''" size="24rpx" color="#7C8592" lineHeight="40rpx"></u--text>
 				<u--text :lines="3" :text="item.agent.systemPrompt||''" size="24rpx" color="#7C8592" lineHeight="40rpx"></u--text>
 			</div>
 			</div>
 			<div class="lc_btns adfac">
 			<div class="lc_btns adfac">
-				<div class="lcb_pre" @tap="editRole(item)">角色编辑</div>
+				<!-- <div class="lcb_pre" @tap="editRole(item)">角色编辑</div> -->
+				<div class="lcb_pre" @tap="dislogRecord(item)">对话记录</div>
 				<div class="lcb_pre" @tap="changeWifi(item)">配置网络</div>
 				<div class="lcb_pre" @tap="changeWifi(item)">配置网络</div>
 				<div class="lcb_pre" @tap="unbindDevice(item)">解绑设备</div>
 				<div class="lcb_pre" @tap="unbindDevice(item)">解绑设备</div>
 			</div>
 			</div>
@@ -48,6 +49,15 @@
 			}
 			}
 		},
 		},
 		methods:{
 		methods:{
+			dislogRecord(item){
+				this.$api.get(`/agent/${item.agentId}/${item.id}/sessions`,{page:1,limit:-1}).then(res=>{
+					if(res.data.code!==0) return this.$showToast(res.data.msg)
+					this.$api.get(`/agent/${item.agentId}/${item.id}/chat-history/${'17a9ae7e-601b-4566-96fc-7728e8342072'}`).then(res2=>{
+						if(res2.data.code!==0) return this.$showToast(res2.data.msg)
+						
+					})
+				})
+			},
 			editRole(item){
 			editRole(item){
 				this.$emit('editRole');
 				this.$emit('editRole');
 				uni.navigateTo({
 				uni.navigateTo({

+ 52 - 30
pages/role.vue

@@ -62,12 +62,24 @@
 				originList:[],
 				originList:[],
 				deviceList:[],
 				deviceList:[],
 				show:false,
 				show:false,
-				options: [{
-					text: '删除',
-					style: {
-						backgroundColor: '#f56c6c'
-					}
-				}],
+				options: [
+					{
+						text: '编辑',
+						icon: 'edit-pen',
+						iconSize:'32rpx',
+						style: {
+							backgroundColor: '#252525'
+						}
+					},
+					{
+						text: '删除',
+						icon: 'trash',
+						iconSize:'32rpx',
+						style: {
+							backgroundColor: '#f56c6c'
+						}
+					},
+				],
 				keyword:'',
 				keyword:'',
 				agentId: '',
 				agentId: '',
 				deviceId: ''
 				deviceId: ''
@@ -106,35 +118,45 @@
 				})
 				})
 			},
 			},
 			deleteRole(item,e){
 			deleteRole(item,e){
-				let that = this;
-				uni.showModal({
-					content:'删除角色设备将自动解绑需重新添加,您确定删除吗?',
-					success: (res) => {
-						if(res.confirm){
-							that.$api.del('/agent/'+item.id).then(res=>{
-								if(res.data.code!==0) return that.$showToast(res.data.msg)
-								that.list.forEach((d, i) => {
-									that.$refs['swipeAction' + i][0].closeHandler();
-								})
-								that.getAgentList();
-							})
-						}
-					}
-				})
-			},
-			toBindDevice(item){
-				this.agentId = item.id;
-				if(item.deviceCount>0){
+				if(e.index===0){
+					this.list.forEach((d, i) => {
+						this.$refs['swipeAction' + i][0].closeHandler();
+					})
+					uni.navigateTo({
+						url:`/pagesRole/addRole?agentId=${item.id}`
+					})
+				}else if(e.index===1){
+					let that = this;
 					uni.showModal({
 					uni.showModal({
-						title:'温馨提示',
-						content:'当前角色已绑定设备,是否继续配置设备?',
+						content:'删除角色设备将自动解绑需重新添加,您确定删除吗?',
 						success: (res) => {
 						success: (res) => {
 							if(res.confirm){
 							if(res.confirm){
-								this.show = true;
+								that.$api.del('/agent/'+item.id).then(res=>{
+									if(res.data.code!==0) return that.$showToast(res.data.msg)
+									that.list.forEach((d, i) => {
+										that.$refs['swipeAction' + i][0].closeHandler();
+									})
+									that.getAgentList();
+								})
 							}
 							}
 						}
 						}
 					})
 					})
-				}else this.show = true
+				}
+			},
+			toBindDevice(item){
+				this.agentId = item.id;
+				this.show = true;
+				// if(item.deviceCount>0){
+				// 	uni.showModal({
+				// 		title:'温馨提示',
+				// 		content:'当前角色已绑定设备,是否继续配置设备?',
+				// 		success: (res) => {
+				// 			if(res.confirm){
+				// 				this.show = true;
+				// 			}
+				// 		}
+				// 	})
+				// }else this.show = true
 			},
 			},
 			confirm(e){
 			confirm(e){
 				this.show = false;
 				this.show = false;
@@ -153,11 +175,11 @@
 
 
 <style>
 <style>
 	.u-swipe-action-item__right__button__wrapper {
 	.u-swipe-action-item__right__button__wrapper {
-		background: #F55454 !important;
 		font-size: 28rpx;
 		font-size: 28rpx;
 		font-weight: 400;
 		font-weight: 400;
 		color: #FFFFFF;
 		color: #FFFFFF;
 		letter-spacing: 2rpx;
 		letter-spacing: 2rpx;
+		padding: 0 26rpx;
 	}
 	}
 	.swipe-action {
 	.swipe-action {
 	  width: 100%;
 	  width: 100%;

+ 1 - 1
pagesMy/scanResult.vue

@@ -19,7 +19,7 @@
 		methods:{
 		methods:{
 			addRole(){
 			addRole(){
 				uni.navigateTo({
 				uni.navigateTo({
-					url:'/pagesRole/addRole'
+					url:'/pages/role'
 				})
 				})
 			},
 			},
 			goBack(){
 			goBack(){

+ 46 - 33
pagesRole/addRole.vue

@@ -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;
 			}
 			}

+ 22 - 5
pagesRole/roleModel.vue

@@ -12,7 +12,13 @@
 			<image src="http://106.54.209.120:8188/static/avatar_default.png"></image>
 			<image src="http://106.54.209.120:8188/static/avatar_default.png"></image>
 			<p>{{agentDto.agentName||''}}</p>
 			<p>{{agentDto.agentName||''}}</p>
 		</div>
 		</div>
-		<div class="desc">{{agentDto.systemPrompt||''}}</div>
+		<div class="desc">
+			<!-- <u-read-more :toggle="true" showHeight="300rpx">
+				<rich-text :nodes="agentDto.systemPrompt||''"></rich-text>
+			</u-read-more> -->
+			<!-- {{agentDto.systemPrompt||''}} -->
+			<u-textarea v-model="agentDto.systemPrompt" autoHeight :maxlength="-1" border="none" disabled="disabled"></u-textarea>
+		</div>
 		<div class="zt_btn" @tap="confirm">确认选择</div>
 		<div class="zt_btn" @tap="confirm">确认选择</div>
 	</view>
 	</view>
 </template>
 </template>
@@ -57,13 +63,20 @@
 	}
 	}
 </script>
 </script>
 
 
-<style scoped lang="less">
+<style scoped lang="scss">
+	::v-deep .desc .u-textarea{
+		padding: 0 20rpx !important;
+		font-size: 26rpx !important;
+		color: #7C8592 !important;
+		line-height: 37rpx !important;
+		background: transparent !important;
+	}
+	
 	.page{
 	.page{
 		width: 100%;
 		width: 100%;
 		background: #FFFFFF;
 		background: #FFFFFF;
-		padding: 0 30rpx 30rpx;
+		padding: 0 30rpx 150rpx;
 		box-sizing: border-box;
 		box-sizing: border-box;
-		overflow: hidden;
 		.title{
 		.title{
 			font-family: PingFang-SC, PingFang-SC;
 			font-family: PingFang-SC, PingFang-SC;
 			font-weight: bold;
 			font-weight: bold;
@@ -137,7 +150,11 @@
 			margin-top: 36rpx;
 			margin-top: 36rpx;
 		}
 		}
 		.zt_btn{
 		.zt_btn{
-			margin-top: 285rpx;
+			width: calc(100% - 60rpx);
+			position: fixed;
+			left: 30rpx;
+			bottom: 30rpx;
+			z-index: 999;
 		}
 		}
 	}
 	}
 </style>
 </style>