|
@@ -4,16 +4,23 @@ import { ExploreContainerComponent } from '../explore-container/explore-containe
|
|
|
import { AgentTaskStep } from 'src/agent/agent.task';
|
|
|
import { closeCircleOutline,radioButtonOffOutline,reloadOutline,checkmarkCircleOutline} from 'ionicons/icons';
|
|
|
import { addIcons } from 'ionicons';
|
|
|
+import { startTask } from 'src/agent/agent.start';
|
|
|
+import { TaskPoemPictureDesc } from 'src/agent/tasks/poem/poem-desc';
|
|
|
+import { TaskPoemPictureCreate } from 'src/agent/tasks/poem/poem-picture';
|
|
|
+import { share } from 'rxjs';
|
|
|
import { DalleOptions, FmodeChatCompletion, ImagineWork } from 'fmode-ng';
|
|
|
import { getUserInput } from 'src/agent/agent.input';
|
|
|
-import { startTask } from 'src/agent/agent.start';
|
|
|
+import { DecimalPipe } from '@angular/common';
|
|
|
+
|
|
|
addIcons({radioButtonOffOutline,reloadOutline,checkmarkCircleOutline,closeCircleOutline})
|
|
|
@Component({
|
|
|
selector: 'app-tab3',
|
|
|
templateUrl: 'tab3.page.html',
|
|
|
styleUrls: ['tab3.page.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonButton,IonIcon],
|
|
|
+ imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonButton,IonIcon,
|
|
|
+ DecimalPipe
|
|
|
+ ],
|
|
|
})
|
|
|
export class Tab3Page {
|
|
|
constructor(private modalCtrl:ModalController) {
|
|
@@ -35,54 +42,57 @@ export class Tab3Page {
|
|
|
|
|
|
// 任务:完成故事意境描述及图像绘制
|
|
|
doPoemTask(){
|
|
|
- let task1 = new AgentTaskStep({title:"意境分析",shareData:this.shareData});
|
|
|
- task1.handle=async()=>{
|
|
|
- //获取用户输入的诗词
|
|
|
- let userInput=await getUserInput(this.modalCtrl,{filedsArray:[{name:"诗文内容",type:"text",desc:"诗文内容"}]});
|
|
|
- console.log("已获取用户输入:",userInput)
|
|
|
- console.log("已获取诗文内容:",userInput.poem)
|
|
|
-
|
|
|
- // 文本生成
|
|
|
- let PromptTemplate = `您是一名专业的美术画家,请您根据古诗文的内容,将其描述的画面、场景、人物、物品等用最简短的语言表达,直接写出画面,并且以中国的古风意境为主
|
|
|
- 诗文如下:${userInput.poem}`
|
|
|
- let completion = new FmodeChatCompletion([
|
|
|
- {role:"system",content:""},
|
|
|
- {role:"user",content:PromptTemplate}
|
|
|
- ])
|
|
|
- completion.sendCompletion().subscribe((message:any)=>{
|
|
|
- // 打印消息体
|
|
|
- console.log(message.content)
|
|
|
- // 赋值消息内容给组件内属性
|
|
|
- this.shareData.PictureDescResult = message.content
|
|
|
- if(message?.complete){ // 判断message为完成状态,则设置isComplete为完成
|
|
|
- task1.progress=1
|
|
|
- }
|
|
|
- })
|
|
|
- // await this.wait(1000);
|
|
|
- // console.log("意境分析")
|
|
|
- }
|
|
|
+ // 产生: shareData.PictureDescResult 生成后描述
|
|
|
+ let task1=TaskPoemPictureDesc({shareData:this.shareData,modalCtrl:this.modalCtrl});
|
|
|
+ // let task1 = new AgentTaskStep({title:"意境分析",shareData:this.shareData});
|
|
|
+ // task1.handle=async()=>{
|
|
|
+ // //获取用户输入的诗词
|
|
|
+ // let userInput=await getUserInput(this.modalCtrl,{filedsArray:[{name:"诗文内容",type:"text",desc:"诗文内容"}]});
|
|
|
+ // console.log("已获取用户输入:",userInput)
|
|
|
+ // console.log("已获取诗文内容:",userInput.poem)
|
|
|
|
|
|
- let task2=new AgentTaskStep({title:"意境绘制",shareData:this.shareData});
|
|
|
- task2.handle=async()=>{
|
|
|
- await this.wait(10000);
|
|
|
- //let userInput=await getUserInput(this.modalCtrl,{filedsArray:[{name:"绘图要求",type:"text",desc:"画风、构图等"}]});
|
|
|
- // console.log("已获取用户输入:",userInput)
|
|
|
- // console.log("已获取诗文内容:",userInput.poem)
|
|
|
- console.log("意境绘制:执行过程");
|
|
|
- let imagineWork = new ImagineWork();
|
|
|
+ // // 文本生成
|
|
|
+ // let PromptTemplate = `您是一名专业的美术画家,请您根据古诗文的内容,将其描述的画面、场景、人物、物品等用最简短的语言表达,直接写出画面,并且以中国的古风意境为主
|
|
|
+ // 诗文如下:${userInput.poem}`
|
|
|
+ // let completion = new FmodeChatCompletion([
|
|
|
+ // {role:"system",content:""},
|
|
|
+ // {role:"user",content:PromptTemplate}
|
|
|
+ // ])
|
|
|
+ // completion.sendCompletion().subscribe((message:any)=>{
|
|
|
+ // // 打印消息体
|
|
|
+ // console.log(message.content)
|
|
|
+ // // 赋值消息内容给组件内属性
|
|
|
+ // this.shareData.PictureDescResult = message.content
|
|
|
+ // if(message?.complete){ // 判断message为完成状态,则设置isComplete为完成
|
|
|
+ // task1.progress=1
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // // await this.wait(1000);
|
|
|
+ // // console.log("意境分析")
|
|
|
+ // }
|
|
|
+ // 产生: shareData.images 渲染后图片
|
|
|
+ let task2 = TaskPoemPictureCreate({shareData:this.shareData,modalCtrl:this.modalCtrl});
|
|
|
+ // let task2=new AgentTaskStep({title:"意境绘制",shareData:this.shareData});
|
|
|
+ // task2.handle=async()=>{
|
|
|
+ // await this.wait(10000);
|
|
|
+ // //let userInput=await getUserInput(this.modalCtrl,{filedsArray:[{name:"绘图要求",type:"text",desc:"画风、构图等"}]});
|
|
|
+ // // console.log("已获取用户输入:",userInput)
|
|
|
+ // // console.log("已获取诗文内容:",userInput.poem)
|
|
|
+ // console.log("意境绘制:执行过程");
|
|
|
+ // let imagineWork = new ImagineWork();
|
|
|
|
|
|
- // 图片生成
|
|
|
- let PicturePrompt = `${this.shareData.PictureDescResult}\n风格:中国古风。画面不带任何文字。`
|
|
|
- let options:DalleOptions = {prompt:PicturePrompt}
|
|
|
- imagineWork?.draw(options).subscribe((work:any)=>{
|
|
|
- console.log("imagineWork",work?.toJSON())
|
|
|
- console.log("images",work?.get("images"))
|
|
|
- if(work?.get("images")?.length){
|
|
|
- this.shareData.images = work?.get("images");
|
|
|
- task2.progress=1
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ // // 图片生成
|
|
|
+ // let PicturePrompt = `${this.shareData.PictureDescResult}\n风格:中国古风。画面不带任何文字。`
|
|
|
+ // let options:DalleOptions = {prompt:PicturePrompt}
|
|
|
+ // imagineWork?.draw(options).subscribe((work:any)=>{
|
|
|
+ // console.log("imagineWork",work?.toJSON())
|
|
|
+ // console.log("images",work?.get("images"))
|
|
|
+ // if(work?.get("images")?.length){
|
|
|
+ // this.shareData.images = work?.get("images");
|
|
|
+ // task2.progress=1
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
|
|
|
// 定义任务集
|
|
|
let PoemTaskList = [task1,task2]
|
|
@@ -133,5 +143,5 @@ export class Tab3Page {
|
|
|
// 开始执行任务
|
|
|
startTask(InquireServiceTaskList)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|