|
@@ -1,5 +1,5 @@
|
|
import { ChangeDetectorRef, Component } from '@angular/core';
|
|
import { ChangeDetectorRef, Component } from '@angular/core';
|
|
-import { IonHeader, IonToolbar, IonTitle, IonContent, IonItem, IonList, IonSelect, IonSelectOption, IonLabel, IonButton, IonTextarea, AlertController, IonSegment, IonSegmentButton, ModalController } from '@ionic/angular/standalone';
|
|
|
|
|
|
+import { IonHeader, IonToolbar, IonTitle, IonContent, IonItem, IonList, IonSelect, IonSelectOption, IonLabel, IonButton, IonTextarea, AlertController, IonSegment, IonSegmentButton, ModalController, IonAlert, IonButtons } from '@ionic/angular/standalone';
|
|
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
import { FormsModule } from '@angular/forms'; // 导入 FormsModule
|
|
import { FormsModule } from '@angular/forms'; // 导入 FormsModule
|
|
@@ -7,6 +7,9 @@ import { FormsModule } from '@angular/forms'; // 导入 FormsModule
|
|
import { ChatPanelOptions, FmChatModalInput, FmodeChat, FmodeChatCompletion, FmodeChatMessage, MarkdownPreviewModule, openChatPanelModal } from 'fmode-ng';
|
|
import { ChatPanelOptions, FmChatModalInput, FmodeChat, FmodeChatCompletion, FmodeChatMessage, MarkdownPreviewModule, openChatPanelModal } from 'fmode-ng';
|
|
import { Router } from '@angular/router'; // 导入 Router
|
|
import { Router } from '@angular/router'; // 导入 Router
|
|
import { DalleOptions, ImagineWork } from 'fmode-ng';
|
|
import { DalleOptions, ImagineWork } from 'fmode-ng';
|
|
|
|
+import { PageAiChatComponent } from '../page-ai-chat/page-ai-chat.component';
|
|
|
|
+import { PageEvaluateComponent } from '../page-evaluate/page-evaluate.component';
|
|
|
|
+import { EditRatingStarComponent } from '../edit-rating-star/edit-rating-star.component';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-tab3',
|
|
selector: 'app-tab3',
|
|
@@ -15,7 +18,7 @@ import { DalleOptions, ImagineWork } from 'fmode-ng';
|
|
standalone: true,
|
|
standalone: true,
|
|
imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonItem,IonList,IonSelect,IonSelectOption,IonButton,CommonModule,IonTextarea,FormsModule,
|
|
imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonItem,IonList,IonSelect,IonSelectOption,IonButton,CommonModule,IonTextarea,FormsModule,
|
|
MarkdownPreviewModule,IonSegment,IonSegmentButton,IonLabel,// ASR语音输入模块
|
|
MarkdownPreviewModule,IonSegment,IonSegmentButton,IonLabel,// ASR语音输入模块
|
|
- FmChatModalInput,],
|
|
|
|
|
|
+ FmChatModalInput,PageAiChatComponent,PageEvaluateComponent,EditRatingStarComponent,IonAlert,IonButtons],
|
|
})
|
|
})
|
|
export class Tab3Page {
|
|
export class Tab3Page {
|
|
placeholderText: string = "职业:非必填\n喜好:非必填\n天气:非必填\n温度:非必填\n其他需求:显高显瘦?儒雅甜美?等";
|
|
placeholderText: string = "职业:非必填\n喜好:非必填\n天气:非必填\n温度:非必填\n其他需求:显高显瘦?儒雅甜美?等";
|
|
@@ -48,6 +51,7 @@ export class Tab3Page {
|
|
return this.selectedSegment === segment; // 判断当前导航项是否被激活
|
|
return this.selectedSegment === segment; // 判断当前导航项是否被激活
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//AI穿搭
|
|
selectGender(gender: string) {
|
|
selectGender(gender: string) {
|
|
this.selectedGender = gender; // 更新选中的性别
|
|
this.selectedGender = gender; // 更新选中的性别
|
|
}
|
|
}
|
|
@@ -66,6 +70,7 @@ export class Tab3Page {
|
|
this.countdownTimer = 0; // 重置计时器
|
|
this.countdownTimer = 0; // 重置计时器
|
|
this.imagineWork=undefined;
|
|
this.imagineWork=undefined;
|
|
this.images = []; // 清空原来的图片数组
|
|
this.images = []; // 清空原来的图片数组
|
|
|
|
+
|
|
this.userPrompt =`有一位${this.selectedGender}用户,该用户${this.age}岁,身高${this.height}cm,体重${this.weight}kg,该用户的补充说明是
|
|
this.userPrompt =`有一位${this.selectedGender}用户,该用户${this.age}岁,身高${this.height}cm,体重${this.weight}kg,该用户的补充说明是
|
|
${this.comments},请你作为一名专业的服装穿搭大师并严格按照给定的例子格式,为该用户给出适合的服装搭配建议,再给出具体穿搭方案时里面的衣服颜色和类型一定要唯一,不要出现类似白色或绿色之类的句子。
|
|
${this.comments},请你作为一名专业的服装穿搭大师并严格按照给定的例子格式,为该用户给出适合的服装搭配建议,再给出具体穿搭方案时里面的衣服颜色和类型一定要唯一,不要出现类似白色或绿色之类的句子。
|
|
例子:嘿,兄弟,你的信息我收到了,让我来帮你计算一下BMI值,再给你一些穿搭方面的建议吧!
|
|
例子:嘿,兄弟,你的信息我收到了,让我来帮你计算一下BMI值,再给你一些穿搭方面的建议吧!
|
|
@@ -111,7 +116,7 @@ BMI是衡量身体状况的一个标准,计算方法是体重除以身高的
|
|
// 图片生成
|
|
// 图片生成
|
|
this.startTimer(); // 启动计时器
|
|
this.startTimer(); // 启动计时器
|
|
this.imagineWork = new ImagineWork();
|
|
this.imagineWork = new ImagineWork();
|
|
- let PicturePrompt = `描述:${this.responseMsg}\n请你作为一名专业的服装绘制大师,根据描述中的方案一生成对应的服装图片。`
|
|
|
|
|
|
+ let PicturePrompt = `描述:${this.responseMsg}\n请你作为一名专业的服装绘制大师,根据描述中的方案一描述严格生成对应的服装图片,颜色要一致。`
|
|
let options:DalleOptions = {prompt:PicturePrompt}
|
|
let options:DalleOptions = {prompt:PicturePrompt}
|
|
this.imagineWork?.draw(options).subscribe(work=>{
|
|
this.imagineWork?.draw(options).subscribe(work=>{
|
|
console.log("imagineWork",work?.toJSON())
|
|
console.log("imagineWork",work?.toJSON())
|
|
@@ -139,60 +144,44 @@ stopTimer() {
|
|
clearInterval(this.timerInterval); // 清除定时器
|
|
clearInterval(this.timerInterval); // 清除定时器
|
|
}
|
|
}
|
|
|
|
|
|
-openChat(){
|
|
|
|
- localStorage.setItem("company","E4KpGvTEto")
|
|
|
|
- let options:ChatPanelOptions = {
|
|
|
|
- roleId:"2DXJkRsjXK",
|
|
|
|
- onChatInit:(chat:FmodeChat)=>{
|
|
|
|
- console.log("onChatInit");
|
|
|
|
- console.log("预设角色",chat.role);
|
|
|
|
- chat.role.set("name","小马");
|
|
|
|
- chat.role.set("title","时尚顾问");
|
|
|
|
- chat.role.set("desc","一名亲切和蔼的时尚顾问,小马,年龄28岁");
|
|
|
|
- chat.role.set("tags",["全科","门诊"]);
|
|
|
|
- chat.role.set("avatar","https://nova-cloud.obs.cn-south-1.myhuaweicloud.com/storage/aigc/imagine/Q4Zif7fTbK-0.png")
|
|
|
|
- chat.role.set("prompt",`
|
|
|
|
-#角色设定
|
|
|
|
-您是一名时尚顾问,名叫晓晓,年龄28岁,热爱时尚,擅长根据用户的需求和个性推荐穿搭方案。您的风格亲切、幽默,旨在帮助用户找到最适合他们的服装搭配。
|
|
|
|
-
|
|
|
|
-#对话环节
|
|
|
|
-0破冰,跟用户打招呼,并引导用户聊穿搭话题,可以慢慢引导,不要太突兀,比如:
|
|
|
|
-“今天的心情怎么样?”
|
|
|
|
-1拓展话题
|
|
|
|
-“你平时喜欢什么样的穿搭风格呢?有没有特别喜欢的颜色或者品牌?”
|
|
|
|
-“如果有一个场合,你希望我帮你推荐搭配,比如约会、工作或休闲,你会选择哪个呢?”
|
|
|
|
-“你觉得在穿搭上,最让你困扰的是什么?是搭配技巧还是风格选择呢?”
|
|
|
|
-“有没有什么服装是你一直想尝试但还没有机会的?我们可以一起聊聊!”
|
|
|
|
-2引导收尾
|
|
|
|
-“今天聊得很开心呢!如果你还有其他问题或者想法,随时可以告诉我哦。”
|
|
|
|
-“如果你觉得今天的聊天已经足够了,我也很乐意下次再和你聊更多时尚的话题!”
|
|
|
|
-“希望你能找到自己喜欢的穿搭风格,期待下次再见!”`);
|
|
|
|
- },
|
|
|
|
- onMessage:(chat:FmodeChat,message:FmodeChatMessage)=>{
|
|
|
|
- console.log("onMessage",message)
|
|
|
|
- let content:any = message?.content
|
|
|
|
- if(typeof content == "string"){
|
|
|
|
- if(content?.indexOf("[完成]")>-1){
|
|
|
|
- console.log("聊天已完成")
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- onChatSaved:(chat:FmodeChat)=>{
|
|
|
|
- // chat?.chatSession?.id 本次会话的 chatId
|
|
|
|
- console.log("onChatSaved",chat,chat?.chatSession,chat?.chatSession?.id)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- openChatPanelModal(this.modalCtrl,options)
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
+//AI评价
|
|
|
|
+async submitEvaluation() {
|
|
|
|
+ // 处理评价提交逻辑
|
|
|
|
+ console.log('发表评价');
|
|
|
|
+ // 这里可以添加您希望执行的代码,例如将评价发送到服务器
|
|
|
|
+ // 弹出提示框
|
|
|
|
+ const alert = await this.alertController.create({
|
|
|
|
+ header: '提交成功,感谢你的评价!',
|
|
|
|
+ buttons: ['确定'] // 按钮
|
|
|
|
+ });
|
|
|
|
|
|
-restoreChat(chatId:string){
|
|
|
|
- let options:ChatPanelOptions = {
|
|
|
|
- roleId:"2DXJkRsjXK",
|
|
|
|
- chatId:chatId
|
|
|
|
- }
|
|
|
|
- openChatPanelModal(this.modalCtrl,options)
|
|
|
|
|
|
+ await alert.present(); // 显示弹出框
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//星星打分
|
|
|
|
+currentScore: number = 0; // 初始分值
|
|
|
|
+
|
|
|
|
+handleScoreChange(newScore: number) {
|
|
|
|
+this.currentScore = newScore;
|
|
|
|
+console.log('新分值:', newScore); // 处理分值变化
|
|
|
|
+}
|
|
|
|
|
|
|
|
+getScoreDescription(score: number): string {
|
|
|
|
+switch (score) {
|
|
|
|
+ case 1:
|
|
|
|
+ return '很差';
|
|
|
|
+ case 2:
|
|
|
|
+ return '差';
|
|
|
|
+ case 3:
|
|
|
|
+ return '一般';
|
|
|
|
+ case 4:
|
|
|
|
+ return '还不错';
|
|
|
|
+ case 5:
|
|
|
|
+ return '很满意';
|
|
|
|
+ default:
|
|
|
|
+ return ''; // 默认返回空字符串
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+alertButtons = ['退出'];
|
|
}
|
|
}
|