|
@@ -30,23 +30,35 @@ export class PageCreateComponent implements OnInit {
|
|
|
// 属性:组件内用于展示消息内容的变量
|
|
|
responseMsg:any = ""
|
|
|
// 方法:实例化completion对象,传入消息数组,并订阅生成的可观察对象。
|
|
|
- sendMessage(){
|
|
|
- console.log("create")
|
|
|
+ sendMessage() {
|
|
|
+ console.log("create");
|
|
|
|
|
|
let PromptTemplate = `
|
|
|
- 您作为一位专业的$(this.style)诗歌创作者,请您根据用户提出的感官体验、情感表达和诗歌的结构,给出要求的诗歌格式的诗歌内容创作,
|
|
|
- 以下是用户的需求$(this.userPrompt)
|
|
|
- `
|
|
|
+ 您作为一位专业的${this.style}诗歌创作者,请您根据以下用户需求创作一首符合格式的诗歌:
|
|
|
+
|
|
|
+ 1. 主题:用户希望表达的主题(例如:爱情、自然、时间等)
|
|
|
+ 2. 感官体验:用户期望使用的视觉、听觉等感官细节描述
|
|
|
+ 3. 情感表达:用户想要传达的情感,例如:快乐、悲伤、怀念等
|
|
|
+ 4. 诗歌格式:请按照以下格式创作诗歌
|
|
|
+ - 诗歌的行数:要求的行数
|
|
|
+ - 每行字数:例如:五言、七言
|
|
|
+ - 韵律:是否需要押韵
|
|
|
+
|
|
|
+ 以下是用户的需求:
|
|
|
+ ${this.userPrompt}
|
|
|
+ `;
|
|
|
|
|
|
let completion = new FmodeChatCompletion([
|
|
|
- {role:"system",content:""},
|
|
|
- {role:"user",content:this.userPrompt}
|
|
|
- ])
|
|
|
- completion.sendCompletion().subscribe((message:any)=>{
|
|
|
+ { role: "system", content: "" },
|
|
|
+ { role: "user", content: PromptTemplate }
|
|
|
+ ]);
|
|
|
+
|
|
|
+ completion.sendCompletion().subscribe((message: any) => {
|
|
|
// 打印消息体
|
|
|
- console.log(message.content)
|
|
|
+ console.log(message.content);
|
|
|
// 赋值消息内容给组件内属性
|
|
|
- this.responseMsg = message.content
|
|
|
- })
|
|
|
+ this.responseMsg = message.content;
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
}
|