|
@@ -48,13 +48,12 @@ import { AvatarModule, ChatPanelOptions, DalleOptions, FmodeChat, FmodeChatMessa
|
|
|
],
|
|
|
})
|
|
|
export class Tab7Page implements OnInit {
|
|
|
- constructor(private router: Router) { }
|
|
|
+ constructor(private router: Router) {
|
|
|
+ this.currentUser = new CloudUser();
|
|
|
+ }
|
|
|
|
|
|
ngOnInit() { }
|
|
|
-
|
|
|
- navigateToContentGenerator() {
|
|
|
- this.router.navigate(['/content-generator'], { queryParams: { outline: this.generatedOutline } });
|
|
|
- }
|
|
|
+ currentUser: CloudUser;
|
|
|
|
|
|
// 用户输入提示词
|
|
|
titlel: string = "";
|
|
@@ -67,29 +66,10 @@ export class Tab7Page implements OnInit {
|
|
|
styleInput(ev: any) {
|
|
|
this.style = ev.detail.value;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- // 人物词条
|
|
|
- entryList: Array<any> = []
|
|
|
- list: any = [];
|
|
|
- entry: string = '';
|
|
|
- onEntryListChange(ev: any) {
|
|
|
- this.entryList = ev;
|
|
|
- let list =JSON.stringify(this.entryList) ;
|
|
|
- console.log(list);
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- showEntryList() {
|
|
|
- console.log(JSON.stringify(this.entryList))
|
|
|
-
|
|
|
- }
|
|
|
// 生成的小说大纲
|
|
|
generatedOutline: string = "";
|
|
|
|
|
|
- // 生成的小说内容
|
|
|
- generatedContent: string = "";
|
|
|
-
|
|
|
// 属性:组件内用于展示消息内容的变量
|
|
|
responseMsg: any = "";
|
|
|
|
|
@@ -98,13 +78,8 @@ export class Tab7Page implements OnInit {
|
|
|
|
|
|
sendMessage() {
|
|
|
console.log("create");
|
|
|
- console.log(JSON.stringify(this.entryList));
|
|
|
- console.log(this.titlel);
|
|
|
- this.entry = JSON.stringify(this.entryList); // 将 entryList 转换为字符串并存储在 entry 中
|
|
|
- console.log(this.entry); // 输出 entry 的值
|
|
|
let PromptTemplate = `
|
|
|
- 您作为一名专业的${this.style}作者,请您根据用户提供的标题${this.titlel},根据这个词条${this.entry}的内容,添加文章信息,并给出短篇小说大纲。
|
|
|
-
|
|
|
+ 您作为一名专业的${this.style}作者,请您根据用户提供的标题${this.titlel},添加文章信息,并给出短篇小说大纲。
|
|
|
`;
|
|
|
console.log(PromptTemplate);
|
|
|
let completion = new FmodeChatCompletion([
|
|
@@ -124,32 +99,6 @@ export class Tab7Page implements OnInit {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- sendOutline() {
|
|
|
- console.log("create");
|
|
|
-
|
|
|
- let PromptTemplate = `
|
|
|
- 根据短篇小说大纲${this.generatedOutline},生成一个短篇小说。
|
|
|
- `;
|
|
|
-
|
|
|
- let completion = new FmodeChatCompletion([
|
|
|
- { role: "system", content: "" },
|
|
|
- { role: "user", content: PromptTemplate }
|
|
|
- ]);
|
|
|
-
|
|
|
- completion.sendCompletion().subscribe((message: any) => {
|
|
|
- // 打印消息体
|
|
|
- console.log(message.content);
|
|
|
- // 赋值消息内容给组件内属性
|
|
|
- this.responseMsg = message.content;
|
|
|
- if (message?.complete) { // 判断message为完成状态,则设置isComplete为完成
|
|
|
- this.isComplete = true;
|
|
|
- // 将生成的小说内容放入文本框中
|
|
|
- this.generatedContent = this.responseMsg;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
saveNovel() {
|
|
|
let consult = new CloudObject("NovelAriticle")
|
|
|
let now = new Date();
|
|
@@ -157,8 +106,7 @@ export class Tab7Page implements OnInit {
|
|
|
// 对象权限的精确指定
|
|
|
let completion = new FmodeChatCompletion([
|
|
|
{role:"system",content:""},
|
|
|
- ])
|
|
|
-
|
|
|
+ ])
|
|
|
completion.sendCompletion().subscribe((message:any)=>{
|
|
|
// 打印消息体
|
|
|
console.log(message.content)
|
|
@@ -167,15 +115,15 @@ export class Tab7Page implements OnInit {
|
|
|
|
|
|
|
|
|
consult.set({
|
|
|
- // name: `${this.name}`,
|
|
|
- // age: `${this.age}`,
|
|
|
- // gender: `${this.gender}`,
|
|
|
- // desc: `${this.desc}`,
|
|
|
- // user: this.currentUser.toPointer(),
|
|
|
+ user: this.currentUser.toPointer(),
|
|
|
+ username: this.currentUser.data["username"],
|
|
|
title: `${this.titlel}`,
|
|
|
topic: `${this.style}`,
|
|
|
- content2: `${this.generatedContent}`,
|
|
|
+
|
|
|
+
|
|
|
+ outline: `${this.generatedOutline}`,
|
|
|
date: dateStr,
|
|
|
+
|
|
|
category: `工具箱内容`
|
|
|
});
|
|
|
consult.save();
|