Files
batch-prompts/prompts/test/perfect-sentence-image.ts
2026-01-10 00:59:25 +08:00

48 lines
1.3 KiB
TypeScript

import { ai } from '../src/index.ts'
import { SentenceImage } from '../src/module/sentence-image.ts';
export async function generatePerfectImage() {
const sentenceImage = new SentenceImage();
// const content = JSON.stringify({
// "text": "选择像锁,终将奔跑。",
// "theme": "选择",
// "template": "{主}像{意象},终将{动}。",
// "templateType": "隐喻",
// "tags": [
// "选择",
// "隐喻",
// "后悔",
// "锁",
// "奔跑"
// ],
// "index": 7,
// "optimized": "选择如秤,终需掂量。"
// });
const content = JSON.stringify({
"text": "人生如逆旅,我亦是行人。",
"theme": "人生",
"template": "人生如{意象},我亦是{身份}。",
"templateType": "隐喻",
"tags": [
"人生",
"隐喻",
"旅途",
"行人"
],
"index": 1,
"optimized": "人生似长河,我自是过客。"
});
const prompt = sentenceImage.perfect(content);
const response = await ai.chat([], {
messages: [{ role: "user", content: prompt }],
// model: 'qwen-turbo',
// model: 'doubao-seed-1-6-251015',
model: 'qwen-plus',
enable_thinking: true
})
console.log('生成的海报设计方案:\n', response.choices[0].message.content);
return response.choices[0].message.content;
}
generatePerfectImage()