| 
					
				 | 
			
			
				@@ -1,7 +1,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 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, AlertController, IonButtons, IonProgressBar, IonText, IonRefresherContent, IonRefresher } 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, IonRefresherContent, IonRefresher, ToastController, IonToast } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { CommonModule } from '@angular/common'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { AvatarModule, ChatPanelOptions, DalleOptions, FmodeChat, FmodeChatCompletion, FmodeChatMessage, ImagineWork, openChatPanelModal } from 'fmode-ng'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -16,10 +16,24 @@ import { AvatarModule, ChatPanelOptions, DalleOptions, FmodeChat, FmodeChatCompl 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonIcon,IonCard,IonCardHeader,IonCardTitle, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonCardSubtitle,IonCardContent, IonThumbnail, IonItem,IonList,CommonModule,IonLabel, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonAvatar, IonSelect, IonSelectOption,IonButtons,IonProgressBar, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    IonText, IonCardHeader, IonCardSubtitle,IonRefresher,IonRefresherContent 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    IonText, IonCardHeader, IonCardSubtitle,IonRefresher,IonRefresherContent, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    IonToast 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public buffer = 0.05; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public progress = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  async presentToast(position: 'top' | 'middle' | 'bottom') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const toast = await this.toastController.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      message: '正在创建智能体,请耐心等待!', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      duration: 1500, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      position: position, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    await toast.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   handleRefresh(event:any) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     setTimeout(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // Any calls to load data go here 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -29,14 +43,16 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   currentUser: CloudUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   constructor( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private toastController: ToastController, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private modalCtrl:ModalController, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private router:Router, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private alertController: AlertController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    this.currentUser = new CloudUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // 示例任务,自己生成图片后请存储新的ID  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  this.imagineWork = new ImagineWork(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  this.imagineWork.fetchTask().then(work=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 示例任务,自己生成图片后请存储新的ID  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.imagineWork = new ImagineWork(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.imagineWork.fetchTask().then(work=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(work){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       this.imagineWork.id = work.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -58,12 +74,12 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     this.name = e.detail.value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     console.log(this.name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  age: number | undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  age: number = 18; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ageInput(e:any) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     this.age = e.detail.value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     console.log(this.age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  gender: string | undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  gender: string = "男"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   genderChange(e:any) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     console.log('ionChange fired with value: ' + e.detail.value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     this.gender = e.detail.value; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -85,16 +101,46 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // 创建医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   async createAgent() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const alert = await this.alertController.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let alert1 = await this.alertController.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       header: '温馨提示', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       subHeader: 'Tips', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       message: '把信息填写完整哦~', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       buttons: ['好的'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let alert2 = await this.alertController.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      header: '温馨提示', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      subHeader: 'Tips', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      message: '智能体已经创建成功!', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      buttons: ['好的'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let alert3 = await this.alertController.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      header: '温馨提示', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      subHeader: 'Tips', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      message: '智能体开始创建,请耐心等待!', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      buttons: ['好的'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let alert4 = await this.alertController.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      header: '温馨提示', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      subHeader: 'Tips', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      message: '智能体创建失败,请重新创建!', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      buttons: ['好的'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (this.name == '' || this.age == 0 || this.gender == '' || this.desc == '') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await alert.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      await alert1.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    await alert3.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let a = setInterval(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.buffer += 0.03; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.progress += 0.02; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (this.progress > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.buffer = 0.00; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.progress = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 删除定时器 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        clearInterval(a); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     localStorage.setItem("company","E4KpGvTEto") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let consult = new CloudObject("DoctorAgent") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -119,6 +165,11 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         {role:"user",content:PromptTemplate} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       ]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       let avatar = "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (!this.name || !this.desc){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.progress = 0; // 进度条重置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        await alert4.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       completion.sendCompletion().subscribe((message:any)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 打印消息体 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         console.log(message.content) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,8 +181,6 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             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")); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -147,30 +196,17 @@ export class PageCreateAgentComponent  implements OnInit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ACL:ACL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                   }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                   consult.save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                  console.log(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  this.progress = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  console.log("consult",consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  alert2.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  this.loadAgentData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  this.name = '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  this.desc = '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.name = '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.age = 18 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.gender = 'male' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.desc = '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   agentList: Array<CloudObject> = []; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -271,5 +307,6 @@ ${userPrompt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   deleteAgent(agent:CloudObject){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     console.log("删除了",agent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     agent.destroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.loadAgentData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |