feat: 添加夸一下的内容

This commit is contained in:
2025-06-25 11:35:16 +08:00
parent b807cc9f38
commit bce94f52a0
8 changed files with 124 additions and 53 deletions

View File

@@ -71,6 +71,58 @@ const kuarenPrompt = `### 浮夸夸人
#### 当前的场景是
`;
const pickGoodJobPrompt = `对提供的文字,提取单个的夸奖内容,并丰富为纯口语化模式,同时在括号中添加对应的姿态语言描述,同时添加了括号中的姿态语言描述,使其更具临场感和情感色彩。
要求:
1. 只返回单个的一条夸奖内容,不能有其他内容。
2. 夸奖内容要口语化,富有情感色彩。
3. 姿态语言描述要符合夸奖内容,且要在括号中描述。
4. 夸奖内容要有夸张的比喻和形容词,突出对方的优点和成就。
5. 夸奖内容要让人感到被认可和赞赏,能够激励对方。
6. 不要返回任何其他内容或解释,只返回夸奖内容。
7. 夸奖内容要简洁明了,易于理解,篇幅不易过长。
当前文字是:
`;
agent
.route({
path: 'tools',
key: 'pick-good-job',
description: '对用户的内容进行夸奖后,提取出夸奖的内容',
})
.define(async (ctx) => {
let { text } = ctx.query;
if (!text) {
text = '真厉害啊';
}
const prompt = `${pickGoodJobPrompt} ${text}`;
const res = await ai
.chat(
[
{
role: 'user',
content: prompt,
},
],
{
enable_thinking: false,
},
)
.catch((err) => {
console.error('AI service error:', err.status);
ctx.throw(500, 'AI service error: ' + err.status);
return err;
});
const ans = res.choices[0]?.message?.content || '';
if (!ans) {
ctx.throw(500, 'AI response is empty');
}
ctx.body = ans;
})
.addTo(agent);
agent
.route({
path: 'tools',
@@ -103,7 +155,23 @@ agent
if (!ans) {
ctx.throw(500, 'AI response is empty');
}
ctx.body = ans;
console.log('AI response:', ans);
// ctx.body = ans;
// console.log('AI response:', ans);
const resPick = await agent.call({
path: 'tools',
key: 'pick-good-job',
payload: {
text: ans,
},
});
if (resPick.code !== 200) {
ctx.throw(500, 'AI pick good job error: ' + resPick.message);
return;
}
const pickAns = resPick.body || '';
if (!pickAns) {
ctx.throw(500, 'AI pick good job response is empty');
}
ctx.body = pickAns;
})
.addTo(agent);