atest.page.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { Component, OnInit } from '@angular/core';
  2. import { Router } from '@angular/router';
  3. import { CloudObject, CloudQuery, CloudUser } from '../lib/ncloud';
  4. 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';
  5. import { CommonModule } from '@angular/common';
  6. import { AvatarModule, ChatPanelOptions, DalleOptions, FmodeChat, FmodeChatCompletion, FmodeChatMessage, ImagineWork, openChatPanelModal } from 'fmode-ng';
  7. import { CompUploaderHwobsComponent } from '../comp-uploader-hwobs/comp-uploader-hwobs.component';
  8. @Component({
  9. selector: 'app-atest',
  10. templateUrl: './atest.page.html',
  11. styleUrls: ['./atest.page.scss'],
  12. standalone: true,
  13. imports: [
  14. IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonTextarea,IonInput,
  15. IonIcon,IonCard,IonCardHeader,IonCardTitle,
  16. IonCardSubtitle,IonCardContent, IonThumbnail, IonItem,IonList,CommonModule,IonLabel,
  17. IonAvatar, IonSelect, IonSelectOption,IonButtons,IonProgressBar,
  18. IonText, IonCardHeader, IonCardSubtitle,CompUploaderHwobsComponent
  19. ]
  20. })
  21. export class AtestPage implements OnInit {
  22. currentUser: CloudUser;
  23. constructor(
  24. private modalCtrl:ModalController,
  25. private router:Router,
  26. private alertController: AlertController,
  27. ) {
  28. this.currentUser = new CloudUser();
  29. // 示例任务,自己生成图片后请存储新的ID
  30. }
  31. images:Array<string> = []
  32. back:string = "<";
  33. backhome() {
  34. this.router.navigate(['/tab1']);
  35. }
  36. ngOnInit() {
  37. }
  38. name: string = ''
  39. nameInput(e:any) {
  40. this.name = e.detail.value;
  41. }
  42. // 上传组件
  43. uploadUrl:string = ""
  44. onUrlChange(ev:any){
  45. console.log(ev);
  46. this.uploadUrl=ev;
  47. }
  48. age: number = 25
  49. ageInput(e:any) {
  50. this.age = e.detail.value;
  51. }
  52. gender: string = 'male'
  53. genderChange(e:any) {
  54. this.gender = e.detail.value;}
  55. genderCancel(){}
  56. genderDismiss(){}
  57. desc: string = ''
  58. descInput(e:any) {
  59. this.desc = e.detail.value;}
  60. PictureDescResult:string = `` // 画面描述结果
  61. isConsultSet: boolean = false;
  62. async createAgent() {
  63. // localStorage.setItem("company","E4KpGvTEto")
  64. let consult = new CloudObject("test")
  65. let now = new Date();
  66. let dateStr = `${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}`
  67. // 对象权限的精确指定
  68. let completion = new FmodeChatCompletion([
  69. {role:"system",content:""},
  70. ])
  71. completion.sendCompletion().subscribe((message:any)=>{
  72. // 打印消息体
  73. console.log(message.content)
  74. // 赋值消息内容给组件内属性
  75. if (message?.complete && !this.isConsultSet) {
  76. this.isConsultSet = true; // 标记为已设置
  77. consult.set({
  78. name: `${this.name}`,
  79. age: `${this.age}`,
  80. gender: `${this.gender}`,
  81. desc: `${this.desc}`,
  82. user: this.currentUser.toPointer(),
  83. avatar: this.uploadUrl
  84. });
  85. consult.save();
  86. console.log(consult);
  87. }
  88. })
  89. }
  90. }