import { Component, OnInit } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { FmodeChatCompletion } from 'fmode-ng';

@Component({
  selector: 'app-health-tips',
  templateUrl: './health-tips.component.html',
  styleUrls: ['./health-tips.component.scss'],
  standalone: true,
  imports: [IonicModule
    ],
})
export class HealthTipsComponent  implements OnInit {

  constructor() {}
  ngOnInit() {}
  // 用户输入提示词
   userPrompt:string = "飞码产品LOGO，独角兽头部形象，极简风格，棱角分明，线条勾勒，蓝色紫色搭配。"
  promptInput(ev:any){
    this.userPrompt = ev.detail.value;
  }
  // 属性：组件内用于展示消息内容的变量
  responseMsg:any = ""
  // 方法：实例化completion对象，传入消息数组，并订阅生成的可观察对象。
  sendMessage(){
    console.log("create")
    let completion = new FmodeChatCompletion([
      {role:"system",content:""},
      {role:"user",content:this.userPrompt}
    ])
    completion.sendCompletion().subscribe((message:any)=>{
      // 打印消息体
      console.log(message.content)
      // 赋值消息内容给组件内属性
      this.responseMsg = message.content
    })
  }
}
