| 
					
				 | 
			
			
				@@ -1,9 +1,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { Component, OnInit } from '@angular/core'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { Router } from '@angular/router'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonIcon, ModalController, IonTextarea, IonInput, IonCard, IonCardHeader, IonCardTitle, IonThumbnail, IonCardContent, IonCardSubtitle, IonItem, IonList, IonLabel, IonAvatar, IonSelect, IonSelectOption } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonIcon, ModalController, IonTextarea, IonInput, IonCard, IonCardHeader, IonCardTitle, IonThumbnail, IonCardContent, IonCardSubtitle, IonItem, IonList, IonLabel, IonAvatar, IonSelect, IonSelectOption, AlertController, IonButtons, IonProgressBar, IonText } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { CommonModule } from '@angular/common'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { AvatarModule, ChatPanelOptions, FmodeChat, FmodeChatMessage, openChatPanelModal } from 'fmode-ng'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { AvatarModule, ChatPanelOptions, DalleOptions, FmodeChat, FmodeChatCompletion, FmodeChatMessage, ImagineWork, openChatPanelModal } from 'fmode-ng'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Component({ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -15,7 +15,8 @@ import { AvatarModule, ChatPanelOptions, FmodeChat, FmodeChatMessage, openChatPa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonTextarea,IonInput, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonIcon,IonCard,IonCardHeader,IonCardTitle, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonCardSubtitle,IonCardContent, IonThumbnail, IonItem,IonList,CommonModule,IonLabel, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    IonAvatar, IonSelect, IonSelectOption 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    IonAvatar, IonSelect, IonSelectOption,IonButtons,IonProgressBar, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    IonText, IonCardHeader, IonCardSubtitle, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -23,11 +24,21 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   currentUser: CloudUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   constructor( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private modalCtrl:ModalController, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private router:Router 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private router:Router, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private alertController: AlertController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   this.currentUser = new  CloudUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   this.currentUser = new CloudUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // 示例任务,自己生成图片后请存储新的ID  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  this.imagineWork = new ImagineWork(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  this.imagineWork.fetchTask().then(work=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(work){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.imagineWork.id = work.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.images = this.imagineWork?.images || '../../assets/image/头像示例.png'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  this.loadAgentData() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ images:Array<string> = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   back:string = "<"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   backhome() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -63,19 +74,21 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     this.desc = e.detail.value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     console.log(this.desc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // 头像 大模型生成图片 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  avatar: string = '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  getAvatar() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 通过大模型生成图片 根据用户的描述年龄性别名字 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    this.avatar = '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  changeDesc(e:any): any{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 通过大模型,根据用户的描述将desc更标准 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return "标准描述" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  imagineWork:ImagineWork 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  PictureDescResult:string = `` // 画面描述结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // 创建医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  createAgent() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  async createAgent() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const alert = await this.alertController.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      header: '温馨提示', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      subHeader: 'Tips', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      message: '把信息填写完整哦~', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      buttons: ['好的'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (this.name == '' || this.age == 0 || this.gender == '' || this.desc == '') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      await alert.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     localStorage.setItem("company","E4KpGvTEto") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let consult = new CloudObject("DoctorAgent") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -88,19 +101,67 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(this.currentUser?.id){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       ACL[this.currentUser?.id] = {read:true,write:true} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    let description = this.desc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    description = this.changeDesc(description) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      avatar:`${this.avatar}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      name:`${this.name}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      age:`${this.age}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      gender:`${this.gender}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      desc:`${description}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      user:this.currentUser.toPointer(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ACL:ACL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    consult.save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    console.log(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.imagineWork = new ImagineWork(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // 文本生成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let PromptTemplate = `您是一名专业的美术画家,擅长画各类型头像图,请您根据下面提供的需求内容,将其描述的画面、场景、人物、物品等用最简短的语言表达,直接写出画面, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      需求如下: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ${this.name},${this.age}岁,${this.gender},描述:${this.desc} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let completion = new FmodeChatCompletion([ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {role:"system",content:""}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {role:"user",content:PromptTemplate} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let avatar = "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      completion.sendCompletion().subscribe((message:any)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 打印消息体 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(message.content) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 赋值消息内容给组件内属性 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.PictureDescResult = message.content 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(message?.complete){ // 判断message为完成状态,则设置isComplete为完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              // 图片生成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let PicturePrompt = `${this.PictureDescResult}\n风格:画面不带任何文字。人物为主体,人物要在图片的正中央。其中人物必须帅气,符合现代中国人审美。` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let options:DalleOptions = {prompt:PicturePrompt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.imagineWork?.draw(options).subscribe(work=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // console.log("imagineWork",work?.toJSON()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // console.log("images",work?.get("images")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(work?.get("images")?.length){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  avatar =  work?.get("images")[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  console.log(work?.get("images")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  console.log("work",work); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  console.log("里面的avatar",avatar); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    avatar:`${avatar}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    name:`${this.name}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    age:`${this.age}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    gender:`${this.gender}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    desc:`${this.desc}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    user:this.currentUser.toPointer(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ACL:ACL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  consult.save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  console.log(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      console.log("外面的avatar",avatar); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (avatar.length){   // 暂时不能创建头像 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // 保存医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          avatar:`${avatar}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          name:`${this.name}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          age:`${this.age}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          gender:`${this.gender}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          desc:`${this.desc}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          user:this.currentUser.toPointer(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          ACL:ACL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        consult.save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   agentList: Array<CloudObject> = []; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -137,13 +198,8 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       ACL[currentUser?.id] = {read:true,write:true} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      title:`${doctor.get('depart')?.name || ""}门诊记录${dateStr}-${doctor?.get("name")}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      title:`门诊记录${dateStr}-${doctor?.get("name")}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       doctor:doctor.toPointer(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      depart:{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        __type:"Pointer", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        className:"Department", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        objectId:doctor.get("depart")?.objectId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       user:currentUser.toPointer(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       ACL:ACL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -154,9 +210,7 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         console.log("onChatInit"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               console.log("预设角色",chat.role); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               chat.role.set("name",doctor?.get("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              chat.role.set("title",doctor?.get("title")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               chat.role.set("desc",doctor?.get("desc")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              chat.role.set("tags",doctor?.get("qualifications")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               chat.role.set("avatar",doctor?.get("avatar") || "../../assets/image/doctor7.png") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               chat.role.set("prompt",` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 角色设定 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -202,4 +256,7 @@ ${userPrompt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       openChatPanelModal(this.modalCtrl,options) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  deleteAgent(agent:CloudObject){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    console.log("删除了",agent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |