|
@@ -1,68 +0,0 @@
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
|
-import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
|
|
|
|
-import { IonTextarea, IonButton,IonInput } from "@ionic/angular/standalone";
|
|
|
|
-import { DalleOptions, ImagineWork } from 'fmode-ng';
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-@Component({
|
|
|
|
- selector: 'app-travel1',
|
|
|
|
- templateUrl: './travel1.component.html',
|
|
|
|
- styleUrls: ['./travel1.component.scss'],
|
|
|
|
- standalone: true,
|
|
|
|
- imports: [
|
|
|
|
- IonHeader, IonToolbar, IonTitle, IonContent,
|
|
|
|
- IonButton,
|
|
|
|
- IonInput,
|
|
|
|
- IonTextarea
|
|
|
|
- ],
|
|
|
|
-})
|
|
|
|
-export class Travel1Component implements OnInit {
|
|
|
|
-
|
|
|
|
- userPrompt:string = "南昌特色,天下英雄城"
|
|
|
|
- promptInput(ev:any){
|
|
|
|
- this.userPrompt = ev.detail.value;
|
|
|
|
- }
|
|
|
|
- imagineWork:ImagineWork|undefined
|
|
|
|
- images:Array<string> = []
|
|
|
|
- constructor(
|
|
|
|
- private cdRef:ChangeDetectorRef
|
|
|
|
- ){
|
|
|
|
- // 示例任务,自己生成图片后请存储新的ID
|
|
|
|
- this.imagineWork = new ImagineWork("lpJGiFwWeA");
|
|
|
|
- this.imagineWork.fetchTask().then(work=>{
|
|
|
|
- this.images = this.imagineWork?.images || [];
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- async createImage(){
|
|
|
|
- this.imagineWork = new ImagineWork();
|
|
|
|
- let PromptTemplate = `您是一名专业的美术画家,请您根据上面的语句,将其描述的南昌画面、场景等细节描述出来
|
|
|
|
- 南昌特色:
|
|
|
|
- ${this.userPrompt}
|
|
|
|
- `
|
|
|
|
- let PictureDescResult = `` //画面描述结果
|
|
|
|
- let completion = new FmodeChatCompletion([
|
|
|
|
- {role:"system",content:""},
|
|
|
|
- {role:"user",content:PromptTemplate}
|
|
|
|
- ])
|
|
|
|
- completion.sendCompletion().subscribe((message:any)=>{
|
|
|
|
- // 打印消息体
|
|
|
|
- console.log(message.content)
|
|
|
|
- // 赋值消息内容给组件内属性
|
|
|
|
- this.PictureDescResult = message.content
|
|
|
|
- if(message?.complete){ // 判断message为完成状态,则设置isComplete为完成
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- let options:DalleOptions = {prompt:this.userPrompt}
|
|
|
|
- this.imagineWork.draw(options).subscribe(work=>{
|
|
|
|
- console.log("imagineWork",work?.toJSON())
|
|
|
|
- console.log("images",work?.get("images"))
|
|
|
|
- if(work?.get("images")?.length){
|
|
|
|
- this.images = work?.get("images");
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ngOnInit() {}
|
|
|
|
-
|
|
|
|
-}
|
|
|