diff --git a/llm/prompts/wei_toutiao_system_prompt.txt b/llm/prompts/wei_toutiao_system_prompt.txt new file mode 100644 index 0000000..c938cd7 --- /dev/null +++ b/llm/prompts/wei_toutiao_system_prompt.txt @@ -0,0 +1,30 @@ +你是一个楼市观察者,每天从全国各地收集真实的购房故事。请根据用户提供的素材,按照以下步骤生成一篇以第一人称视角叙述的微头条,并以JSON格式输出。 + +### 第一步:素材筛选 +分析素材是否符合发布标准: +- 是否有普遍共鸣? +- 是否有情绪张力? +- 是否有信息增量? +在输出JSON中,需包含“素材分析”字段,简要说明理由。 + +### 第二步:撰写标题 +从以下三个标题模板中选择最合适的一个(可微调),并说明选择理由: +1. **“[情绪词]![具体信息]”** + 示例:“崩溃!签完合同三天,同小区冒出套便宜30万的同户型。” +2. **“我好像被贝壳耍了”:一个深圳女孩的买房后悔日记。** +3. **“刚买房就亏30万,是什么体验?今天说说我的遭遇。”** + +### 第三步:构建正文(两段式) +按照以下两段式结构撰写正文,每段内容需贴合素材,语言生动真实,**全部使用第一人称**。 +- **第1段:开门见山,抛出情绪爆点** + (用“我”直接切入,制造悬念或情绪冲突,让读者想往下看) +- **第2段:讲故事,还原真实细节** + (保留原帖的语气和细节,让故事有画面感,适当加入心理活动) + +### 输出格式要求 +请将最终结果以JSON格式输出,包含以下字段: +- `material_analysis`(对象):包含`universal_resonance`(字符串)、`emotional_tension`(字符串)、`info_increment`(字符串)。 +- `title`(字符串):所选标题。 +- `body`(数组):正文的两个段落,每个段落为字符串。 + +确保JSON格式正确,无多余字符。 \ No newline at end of file diff --git a/task/hot_topic/real_estate_story.py b/task/hot_topic/real_estate_story.py index 6d5189a..1ad5551 100644 --- a/task/hot_topic/real_estate_story.py +++ b/task/hot_topic/real_estate_story.py @@ -113,43 +113,7 @@ def story_edit_task(): db.commit() # break # 目前先处理一条内容,后续再改成批量处理 - llm_engine = LLMThinkingEngine(system_prompt_file="real_estate_story_system_prompt.txt") - for content in to_processed_contents: - logger.info(f"story_edit_task content id: {content.id}, title: {content.link}, platform: {content.platform}") - story = llm_engine.think(f"故事素材:{content.content}") - logger.info(f"story_edit_task content id: {content.id} story: {story}") - # llm生成的结果有时不是json结构,会在前后增加一些文本,需要提取出json部分进行解析 - try: - json_start = story.find("{") - json_end = story.rfind("}") + 1 - if json_start != -1 and json_end != -1: - story = story[json_start:json_end] - else: - logger.warning(f"story_edit_task content id: {content.id} llm生成的结果不是有效的json格式,无法提取故事内容") - continue - except json.JSONDecodeError: - logger.warning(f"story_edit_task content id: {content.id} llm生成的结果不是有效的json格式,无法解析故事内容") - continue - # 将生成的故事写入Article表 - try: - json_story = json.loads(story) - except json.JSONDecodeError: - logger.warning(f"story_edit_task content id: {content.id} llm生成的故事内容不是有效的json格式,无法解析故事内容") - continue - title = json_story.get("title", "无标题") - paragraphs = json_story.get("body", ["无内容"]) - article_content = "\n".join(paragraphs) - article = Article( - title=title, - keywords=None, - content=article_content, - used=False - ) - db.add(article) - db.commit() - # break # 目前先处理一条内容,后续再改成批量处理 - - llm_engine = LLMThinkingEngine(system_prompt_file="real_estate_story_short_system_prompt.txt") + llm_engine = LLMThinkingEngine(system_prompt_file="wei_toutiao_system_prompt.txt") for content in to_processed_contents: logger.info(f"story_edit_task content id: {content.id}, title: {content.link}, platform: {content.platform}") story = llm_engine.think(f"故事素材:{content.content}") @@ -185,5 +149,6 @@ def story_edit_task(): db.commit() # break # 目前先处理一条内容,后续再改成批量处理 + if __name__ == "__main__": execute_task(story_edit_task) \ No newline at end of file