|
|
@@ -1,4 +1,4 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
+import { Component, contentChild } from '@angular/core';
|
|
|
import { Router } from '@angular/router';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { IonHeader, IonToolbar, IonTitle, IonContent, ModalController, IonButton,
|
|
|
@@ -75,9 +75,9 @@ export class Tab3Page {
|
|
|
title:`${currentUser?.get("username")}与${filmpartner?.get("name")}的聊天记录${dateStr}`,
|
|
|
filmpartner:filmpartner.toPointer(),
|
|
|
user:currentUser.toPointer(),
|
|
|
+ dialogue: [],
|
|
|
})
|
|
|
|
|
|
- // let chatMessages: string[] = []; // 用于保存所有聊天记录
|
|
|
|
|
|
let options:ChatPanelOptions = {
|
|
|
roleId:"2DXJkRsjXK",
|
|
|
@@ -112,20 +112,18 @@ export class Tab3Page {
|
|
|
},
|
|
|
onMessage:(chat:FmodeChat,message:FmodeChatMessage)=>{
|
|
|
console.log("onMessage",message)
|
|
|
- let content:any = message?.content
|
|
|
- if(typeof content == "string"){
|
|
|
+ // let content:any = message?.content
|
|
|
+ // if(typeof content == "string"){
|
|
|
// if(content?.indexOf("[完成]")>-1){
|
|
|
// console.log("陪聊已完成")
|
|
|
|
|
|
filmchat.set({
|
|
|
- dialogue: content // 保存聊天内容
|
|
|
+ dialogue: chat.messageList// 保存聊天内容
|
|
|
});
|
|
|
|
|
|
-
|
|
|
filmchat.save()
|
|
|
-
|
|
|
// }
|
|
|
- }
|
|
|
+ // }
|
|
|
},
|
|
|
onChatSaved:(chat:FmodeChat)=>{
|
|
|
// chat?.chatSession?.id 本次会话的 chatId
|
|
|
@@ -158,6 +156,7 @@ export class Tab3Page {
|
|
|
title:`${currentUser?.get("username")}与${filmrole?.get("name")}的聊天记录${dateStr}`,
|
|
|
filmrole:filmrole.toPointer(),
|
|
|
user:currentUser.toPointer(),
|
|
|
+ dialogue: [],
|
|
|
})
|
|
|
|
|
|
// let chatMessages: string[] = []; // 用于保存所有聊天记录
|
|
|
@@ -175,7 +174,7 @@ export class Tab3Page {
|
|
|
chat.role.set("avatar",filmrole?.get("avatar") || "https://nova-cloud.obs.cn-south-1.myhuaweicloud.com/storage/aigc/imagine/Q4Zif7fTbK-0.png")
|
|
|
chat.role.set("prompt",`
|
|
|
# 角色设定
|
|
|
-你是${filmrole?.get("title")},你叫${filmrole?.get("name")},大家一般叫你${filmrole?.get("nickname")},你的背景描述如下${filmrole?.get("description")},你的性格特点如下${filmrole?.get("traits")},需要完成一次轻松愉快陪聊服务。
|
|
|
+你是${filmrole?.get("title")},你叫${filmrole?.get("name")},大家一般叫你${filmrole?.get("nickname")},你的背景描述如下:${filmrole?.get("description")},你的性格特点如下:${filmrole?.get("traits")},需要完成一次轻松愉快陪聊服务。
|
|
|
|
|
|
# 对话环节
|
|
|
1.开始话题(根据角色设定陪用户聊天)
|
|
|
@@ -185,27 +184,25 @@ export class Tab3Page {
|
|
|
- 根据设定的剧情背景,性格特点等等陪用户聊天。
|
|
|
4.结束聊天
|
|
|
- 委婉的和用户结束聊天,若用户还想继续聊天可以再陪伴一会儿。
|
|
|
-- 若用户有结束聊天的意愿,在聊天的最后表达期待和用户的下次聊天。在消息结尾附带: [完成]
|
|
|
+- 若用户有结束聊天的意愿,在聊天的最后表达期待和用户的下次聊天。在最后一条消息结尾附带: [完成]
|
|
|
|
|
|
# 开始话语
|
|
|
当你准备好了,可以以${filmrole?.get("name")}的身份,向用户打招呼,开启话题。`);
|
|
|
},
|
|
|
onMessage:(chat:FmodeChat,message:FmodeChatMessage)=>{
|
|
|
console.log("onMessage",message)
|
|
|
- let content:any = message?.content
|
|
|
- if(typeof content == "string"){
|
|
|
+ // let content:any = message?.content
|
|
|
+ // if(typeof content == "string"){
|
|
|
// if(content?.indexOf("[完成]")>-1){
|
|
|
// console.log("陪聊已完成")
|
|
|
|
|
|
- filmchat.set({
|
|
|
- dialogue: content // 保存聊天内容
|
|
|
- });
|
|
|
-
|
|
|
+ filmchat.set({
|
|
|
+ dialogue: chat.messageList// 保存聊天内容
|
|
|
+ });
|
|
|
|
|
|
filmchat.save()
|
|
|
-
|
|
|
// }
|
|
|
- }
|
|
|
+ // }
|
|
|
},
|
|
|
onChatSaved:(chat:FmodeChat)=>{
|
|
|
// chat?.chatSession?.id 本次会话的 chatId
|