|
@@ -0,0 +1,48 @@
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton, IonTextarea, IonInput } from '@ionic/angular/standalone';
|
|
|
+/** 引用:从fmode-ng库引用FmodeChatCompletion类 */
|
|
|
+import { FmodeChatCompletion } from 'fmode-ng';
|
|
|
+
|
|
|
+@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],
|
|
|
+})
|
|
|
+export class PageInquiryComponent implements OnInit {
|
|
|
+ constructor() {}
|
|
|
+ ngOnInit(){}
|
|
|
+ // 用户输入提示词
|
|
|
+ keshi:string = "门诊"
|
|
|
+ keshiInput(ev:any){
|
|
|
+ this.keshi = ev.detail.value;
|
|
|
+ }
|
|
|
+ // 用户输入提示词
|
|
|
+ userPrompt:string = "请描述您的症状"
|
|
|
+ promptInput(ev:any){
|
|
|
+ this.userPrompt = ev.detail.value;
|
|
|
+ }
|
|
|
+ // 属性:组件内用于展示消息内容的变量
|
|
|
+ responseMsg:any = ""
|
|
|
+ // 方法:实例化completion对象,传入消息数组,并订阅生成的可观察对象。
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|