import { Component,OnInit } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonIcon, ModalController, IonTextarea, IonInput } from '@ionic/angular/standalone';
import { AgentTaskStep } from 'src/agent/agent.task';
import { addIcons } from 'ionicons';
import { radioButtonOffOutline, reloadOutline, checkmarkCircleOutline, closeCircleOutline } from 'ionicons/icons';
import { TaskExecutor } from 'src/agent/agent.start';
import { AgentUserInputComponent } from 'src/agent/agent-user-input/agent-user-input.component';
import { FmodeChatCompletion, ImagineWork, DalleOptions } from "fmode-ng";
import { TaskPoemPictureDesc } from 'src/agent/tasks/poem/poem-desc';
import { TaskPoemPictureCreate } from 'src/agent/tasks/poem/poem-picture';
import { DecimalPipe } from '@angular/common';
import { TaskInqueryUserStory } from 'src/agent/tasks/inquiry/1.inquiry-user-story';
import { extactAndParseJsonFromString } from 'src/agent/agent.json';
import { TaskInqueryDoctorQuestion } from 'src/agent/tasks/inquiry/2.inquiry-doctor-question';
import { TaskInqueryUserAnswer } from 'src/agent/tasks/inquiry/3.inquiry-user-answer';
addIcons({radioButtonOffOutline,reloadOutline,checkmarkCircleOutline,closeCircleOutline})

@Component({
  selector: 'app-page-inquiry',
  templateUrl: './page-inquiry.component.html',
  styleUrls: ['./page-inquiry.component.scss'],
  standalone: true,
  imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonTextarea,IonInput,
    IonIcon,AgentUserInputComponent,DecimalPipe
  ],
})
export class PageInquiryComponent  implements OnInit {
  constructor(private modalCtrl:ModalController) {


  }

  taskList:AgentTaskStep[] = []

  wait(duration:number=1000){
    return new Promise(resolve=>{
      setTimeout(() => {
          resolve(true)
      }, duration);
    })
  }

  shareData:any = {}

  ngOnInit(){}
  doInqueryTask(){
    let task1 = TaskInqueryUserStory({shareData:this.shareData,modalCtrl:this.modalCtrl});
    let task2 = TaskInqueryDoctorQuestion({shareData:this.shareData,modalCtrl:this.modalCtrl});
    let task3 = TaskInqueryUserAnswer({shareData:this.shareData,modalCtrl:this.modalCtrl});

    // 定义任务集
    let InquireServiceTaskList = [
      task1,task2,task3
    ]
    // 传递给显示组件
    this.taskList = InquireServiceTaskList
    // 开始执行任务
    TaskExecutor(InquireServiceTaskList)
  }

  //  http://localhost:4200/
  // 用户输入提示词
  // keshi:string = ""
  // keshiInput(ev:any){
  //   this.keshi = ev.detail.value;
  // }
  // // 用户输入提示词
  // userPrompt:string = ""
  // promptInput(ev:any){
  //   this.userPrompt = ev.detail.value;
  // }

  // // 属性：组件内用于展示消息内容的变量
  // responseMsg:any = ""
  // // 方法：实例化completion对象，传入消息数组，并订阅生成的可观察对象。
  // isComplete:boolean = false; // 定义完成状态属性，用来标记是否补全完成
  // sendMessage(){
  //   console.log("create")

  //   let PromptTemplate = `
  //   您作为一名专业的${this.keshi}医生，请您根据用户描述的症状，给出初步的诊断，并给出一些建议。
  //   以下是用户的口述：${this.userPrompt}
  //   `

  //   let completion = new FmodeChatCompletion([
  //     {role:"system",content:""},
  //     {role:"user",content:PromptTemplate}
  //   ])

  //   completion.sendCompletion().subscribe((message:any)=>{
  //     // 打印消息体
  //     console.log(message.content)
      
  //     // 赋值消息内容给组件内属性
  //     this.responseMsg = message.content
  //     if(message.complete){ // 判断message为完成状态，则设置isComplete为完成
  //       this.isComplete = true
  //     }
  //   })
  // }
}
