import { Component, OnInit } from '@angular/core';
import { IonButton, IonContent, IonHeader, IonInput, IonTextarea, IonTitle, IonToolbar } from '@ionic/angular/standalone';
/** 引用：从fmode-ng库引用FmodeChatCompletion类 */
import { FmodeChatCompletion } from 'fmode-ng';

@Component({
  selector: 'app-tengwang-pavilion',
  templateUrl: './tengwang-pavilion.component.html',
  styleUrls: ['./tengwang-pavilion.component.scss'],
  standalone: true,

  imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonTextarea,IonInput],
})

export class TengwangPavilionComponent  implements OnInit {
  constructor() {}
  ngOnInit(){}
  // 用户输入提示词
  tengwangge:string = "时间"
  tengwanggeInput(ev:any){
    this.tengwangge = ev.detail.value;
  }
  userPrompt:string = "请描述您的需求"
  promptInput(ev:any){
    this.userPrompt = ev.detail.value;
  }
  // 属性：组件内用于展示消息内容的变量
  responseMsg:any = ""
  // 方法：实例化completion对象，传入消息数组，并订阅生成的可观察对象。
  sendMessage(){
    console.log("create")

    let PromptTemplate = `您作为一名专业的滕王阁导游，请您根据用户描述的需求，给出旅游路线，用户游玩的时间是${this.tengwangge}
    以下是用户的口述：${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
    })
  }
}
