feat: complete huihui square avatar workflows

This commit is contained in:
stefanfeng
2026-07-24 14:04:21 +08:00
parent 2ef58a44b8
commit e3bda469bb
68 changed files with 8062 additions and 132 deletions

View File

@@ -190,6 +190,32 @@ class AIService:
请对上面的评论写一条友善自然的回复,{word_min}~{word_max}字,直接输出回复内容。"""
return await self._call_api(db, prompt, system_prompt, max_tokens=150)
async def generate_thread_reply(
self, db: AsyncSession, article_title: str, root_comment: str,
reply_context: str, personality_prompt: str,
word_min: int = 15, word_max: int = 60
) -> tuple[str, int]:
"""结合文章、原评论和上下文生成评论回复链中的下一句。"""
system_prompt = f"""你是一名真实的社区用户。{personality_prompt}
重要规则:
- 回复必须积极正面、文明友善,不含任何敏感违规内容
- 要自然接住对方的话,不要机械复述
- 不要透露自己是AI或虚拟用户"""
prompt = f"""文章标题:{article_title}
原评论:{root_comment}
当前对话上下文:{reply_context}
请结合文章、原评论和当前对话,写一条自然的后续回复。
要求:
1. 字数 {word_min}~{word_max}
2. 语气像真实用户交流,可以认同、补充或追问
3. 必须围绕文章和评论内容,不要跑题
4. 只输出回复正文,不要加任何前缀或解释
回复:"""
return await self._call_api(db, prompt, system_prompt, max_tokens=180)
async def test_model(self, db: AsyncSession, model_id: int, test_prompt: str) -> dict:
"""测试模型可用性"""
result = await db.execute(select(AIModelConfig).where(AIModelConfig.id == model_id))