|
@@ -7,26 +7,37 @@ export function TaskPoemPictureCreate(options:{
|
|
modalCtrl:ModalController
|
|
modalCtrl:ModalController
|
|
shareData:any}):AgentTaskStep{
|
|
shareData:any}):AgentTaskStep{
|
|
let task2 = new AgentTaskStep({title:"意境绘制",shareData:options.shareData})
|
|
let task2 = new AgentTaskStep({title:"意境绘制",shareData:options.shareData})
|
|
- task2.handle = async ()=>{
|
|
|
|
- // let userInput = await getUserInput(options.modalCtrl,{fieldsArray:[
|
|
|
|
- // {name:"绘图要求",type:"text",desc:"画风、构图等等"}
|
|
|
|
- // ]});
|
|
|
|
- // console.log(userInput)
|
|
|
|
- console.log("意境绘制:执行过程")
|
|
|
|
|
|
+ task2.handle = ()=>{
|
|
|
|
+ return new Promise(resolve=>{
|
|
|
|
+ // let userInput = await getUserInput(options.modalCtrl,{fieldsArray:[
|
|
|
|
+ // {name:"绘图要求",type:"text",desc:"画风、构图等等"}
|
|
|
|
+ // ]});
|
|
|
|
+ // console.log(userInput)
|
|
|
|
+ console.log("意境绘制:执行过程")
|
|
|
|
|
|
- options.shareData.PictureDescResult
|
|
|
|
- let imagineWork = new ImagineWork();
|
|
|
|
- // 图片生成
|
|
|
|
- let PicturePrompt = `${options.shareData.PictureDescResult}\n风格:中国古风。画面不带任何文字。`
|
|
|
|
- let imgOptions:DalleOptions = {prompt:PicturePrompt}
|
|
|
|
- imagineWork?.draw(imgOptions).subscribe((work:any)=>{
|
|
|
|
- console.log("imagineWork",work?.toJSON())
|
|
|
|
- console.log("images",work?.get("images"))
|
|
|
|
- if(work?.get("images")?.length){
|
|
|
|
- options.shareData.images = work?.get("images");
|
|
|
|
- task2.progress = 1
|
|
|
|
- }
|
|
|
|
|
|
+ if(!options.shareData.PictureDescResult){
|
|
|
|
+ task2.error = "缺少古风描述结果,请重新执行。"
|
|
|
|
+ resolve(false)
|
|
|
|
+ }
|
|
|
|
+ let imagineWork = new ImagineWork();
|
|
|
|
+ // 图片生成
|
|
|
|
+ let PicturePrompt = `${options.shareData.PictureDescResult}\n风格:中国古风。画面不带任何文字。`
|
|
|
|
+ let imgOptions:DalleOptions = {prompt:PicturePrompt}
|
|
|
|
+ let countDownInt = setInterval(()=>{
|
|
|
|
+ task2.progress += 0.01
|
|
|
|
+ },1000)
|
|
|
|
+ imagineWork?.draw(imgOptions).subscribe((work:any)=>{
|
|
|
|
+ console.log("imagineWork",work?.toJSON())
|
|
|
|
+ console.log("images",work?.get("images"))
|
|
|
|
+ if(work?.get("images")?.length){
|
|
|
|
+ options.shareData.images = work?.get("images");
|
|
|
|
+ clearInterval(countDownInt);
|
|
|
|
+ task2.progress = 1
|
|
|
|
+ resolve(true)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
})
|
|
})
|
|
|
|
+
|
|
}
|
|
}
|
|
return task2
|
|
return task2
|
|
}
|
|
}
|