|
@@ -1,14 +1,62 @@
|
|
|
import { Component } from '@angular/core';
|
|
|
-import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
|
|
|
+import { IonicModule } from '@ionic/angular'; // 引入 IonicModule
|
|
|
+import { IonTextarea } from '@ionic/angular/standalone'; // 引入 IonicModule
|
|
|
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
|
+import { FmodeChatCompletion, MarkdownPreviewModule } from 'fmode-ng';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-tab3',
|
|
|
templateUrl: 'tab3.page.html',
|
|
|
styleUrls: ['tab3.page.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent],
|
|
|
+ imports: [
|
|
|
+ ExploreContainerComponent,
|
|
|
+ IonicModule, // 引入 IonicModule
|
|
|
+ MarkdownPreviewModule,
|
|
|
+ ],
|
|
|
})
|
|
|
export class Tab3Page {
|
|
|
+ qunti: string = "";
|
|
|
+ jikou: string = "";
|
|
|
+ userPrompt: string = "";
|
|
|
+ responseMsg: any = "";
|
|
|
+ isComplete: boolean = false;
|
|
|
+
|
|
|
constructor() {}
|
|
|
-}
|
|
|
+
|
|
|
+ ngOnInit() {}
|
|
|
+
|
|
|
+ quntiInput(ev: any) {
|
|
|
+ this.qunti = ev.detail.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ jikouInput(ev: any) {
|
|
|
+ this.jikou = ev.detail.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ promptInput(ev: any) {
|
|
|
+ this.userPrompt = ev.detail.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ sendMessage() {
|
|
|
+ console.log("create");
|
|
|
+
|
|
|
+ let PromptTemplate = `
|
|
|
+ 你是一名专业的饮食营养规划师,拥有丰富的营养学背景和实践经验。你的工作是为不同需求的人群提供个性化的饮食规划,帮助他们实现健康目标,如减肥、增肌、健康维护或疾病管理。
|
|
|
+ 你可以根据用户的需求为客户设计量身定制具体的饮食方案。
|
|
|
+ 当前来咨询用户的饮食习惯是${this.qunti},用户的饮食偏好是${this.jikou}需求描述是${this.userPrompt}`;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ if (message?.complete) {
|
|
|
+ this.isComplete = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|