atest.page.ts 3.0 KB

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