feat: 调整提示词
This commit is contained in:
@@ -1,64 +1,36 @@
|
|||||||
tip_prompt = """
|
tip_prompt = """
|
||||||
你是一个专业的健康科普作者。请一次性生成5篇健康科普文章,分别对应以下5个分类,每个分类各1篇。
|
你是一个专业的健康科普作者。请生成3篇健康科普文章。
|
||||||
|
|
||||||
【分类】
|
|
||||||
1. 饮食营养
|
|
||||||
2. 运动健身
|
|
||||||
3. 睡眠作息
|
|
||||||
4. 心理健康
|
|
||||||
5. 常见病预防
|
|
||||||
|
|
||||||
【选题要求】
|
【选题要求】
|
||||||
请你从每个分类中自行选择一个具体、实用的细分主题,5篇文章的主题互不重复。选题应贴近日常生活,适合普通大众阅读。
|
从以下10个分类中选择3个不重复的分类:
|
||||||
|
饮食营养、运动健身、睡眠作息、心理健康、养生保健、疾病预防、职场健康、皮肤美容、家庭医疗、生活习惯
|
||||||
|
每个分类下自行选择一个具体、实用的细分主题,要求:
|
||||||
|
贴近日常生活,适合普通大众阅读
|
||||||
|
选题要具体、有新意,避免"多喝水""早睡早起""多运动"等过于宽泛的老话题
|
||||||
|
结合当前月份和季节特点来选题
|
||||||
|
如果涉及饮食建议,优先选择当季食材
|
||||||
|
|
||||||
【每篇文章要求】
|
【每篇文章要求】
|
||||||
1. 标题简洁有力,吸引普通读者点击,控制在10字以内
|
标题简洁有力,吸引普通读者点击,控制在10字以内
|
||||||
2. 概要控制在50字以内,概括文章核心观点
|
概要控制在50字以内,概括文章核心观点
|
||||||
3. 正文500字左右,语言通俗易懂,适合大众阅读,避免过多专业术语
|
正文300字左右,语言通俗易懂,适合大众阅读,避免过多专业术语
|
||||||
4. 内容需有科学依据,给出3-5条可操作的实用建议
|
内容需有科学依据,给出3-5条可操作的实用建议
|
||||||
5. 正文结尾附一句总结金句
|
正文结尾附一句总结金句
|
||||||
6. 文末附免责声明:"本文仅供科普参考,不构成医疗建议。"
|
文末附免责声明:"本文仅供科普参考,不构成医疗建议。"
|
||||||
7. 不要使用Markdown格式,正文中的换行用\n表示
|
正文中的换行用\n表示
|
||||||
8. 5篇文章的主题和内容互不重复
|
|
||||||
|
|
||||||
请严格按以下JSON数组格式输出,不要输出任何其他内容:
|
请严格按以下JSON数组格式输出,不要输出任何其他内容:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"title": "文章标题",
|
"title": "文章标题",
|
||||||
"summary": "50字以内的概要",
|
"summary": "50字以内的概要",
|
||||||
"category": "分类名称",
|
"category": "分类名称",
|
||||||
"content": "正文内容,500字左右"
|
"content": "正文内容,300字左右"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "文章标题",
|
|
||||||
"summary": "50字以内的概要",
|
|
||||||
"category": "分类名称",
|
|
||||||
"content": "正文内容,500字左右"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "文章标题",
|
|
||||||
"summary": "50字以内的概要",
|
|
||||||
"category": "分类名称",
|
|
||||||
"content": "正文内容,500字左右"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "文章标题",
|
|
||||||
"summary": "50字以内的概要",
|
|
||||||
"category": "分类名称",
|
|
||||||
"content": "正文内容,500字左右"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "文章标题",
|
|
||||||
"summary": "50字以内的概要",
|
|
||||||
"category": "分类名称",
|
|
||||||
"content": "正文内容,500字左右"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
recipe_prompt = """
|
recipe_prompt = """
|
||||||
你是一位注册营养师和资深美食顾问。请为我生成2份健康菜谱,要求包含一份主菜和一份汤品。
|
你是一位注册营养师和资深美食顾问。请为我生成2份健康菜谱,要求包含一份主菜和一份汤品,结合当前月份和季节特点来生成。
|
||||||
|
|
||||||
请按以下JSON数组格式输出,每条菜谱为一个对象,包含三个字段:name、tags、content。
|
请按以下JSON数组格式输出,每条菜谱为一个对象,包含三个字段:name、tags、content。
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
|
from datetime import datetime
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
|
|
||||||
from langchain_core.messages import HumanMessage
|
from langchain_core.messages import HumanMessage, SystemMessage
|
||||||
|
|
||||||
from agent.health import tip_agent, recipe_agent
|
from agent.health import tip_agent, recipe_agent
|
||||||
|
|
||||||
@@ -10,11 +11,15 @@ memory_store: Dict[str, Any] = {
|
|||||||
"recipe": []
|
"recipe": []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def query_tip_agent():
|
def query_tip_agent():
|
||||||
try:
|
try:
|
||||||
print("开始生成今日5篇健康科普文章")
|
print("开始生成今日健康资讯")
|
||||||
|
today = datetime.today().strftime("%Y-%m-%d")
|
||||||
|
|
||||||
resp = tip_agent.invoke({
|
resp = tip_agent.invoke({
|
||||||
"messages": [HumanMessage(content="请生成今日5篇健康科普文章")]
|
"messages": [SystemMessage(content=f"当前系统日期:{today} \n\n"),
|
||||||
|
HumanMessage(content="请生成今日健康资讯")]
|
||||||
})
|
})
|
||||||
last_msg = resp["messages"][-1]
|
last_msg = resp["messages"][-1]
|
||||||
raw_text = last_msg.content.strip()
|
raw_text = last_msg.content.strip()
|
||||||
@@ -23,7 +28,7 @@ def query_tip_agent():
|
|||||||
articles = json.loads(raw_text)
|
articles = json.loads(raw_text)
|
||||||
# 写入内存缓存
|
# 写入内存缓存
|
||||||
memory_store["articles"] = articles
|
memory_store["articles"] = articles
|
||||||
print("结束生成今日5篇健康科普文章")
|
print("结束生成今日健康资讯")
|
||||||
return True
|
return True
|
||||||
except json.JSONDecodeError as je:
|
except json.JSONDecodeError as je:
|
||||||
print(f"[JSON解析错误] {str(je)}")
|
print(f"[JSON解析错误] {str(je)}")
|
||||||
@@ -35,14 +40,19 @@ def query_tip_agent():
|
|||||||
memory_store["articles"] = []
|
memory_store["articles"] = []
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_latest_tip():
|
def get_latest_tip():
|
||||||
return memory_store["articles"]
|
return memory_store["articles"]
|
||||||
|
|
||||||
|
|
||||||
def query_recipe_agent():
|
def query_recipe_agent():
|
||||||
try:
|
try:
|
||||||
print("开始生成今日菜谱")
|
print("开始生成今日养生食谱")
|
||||||
|
today = datetime.today().strftime("%Y-%m-%d")
|
||||||
|
|
||||||
resp = recipe_agent.invoke({
|
resp = recipe_agent.invoke({
|
||||||
"messages": [HumanMessage(content="请生成今日菜谱")]
|
"messages": [SystemMessage(content=f"当前系统日期:{today} \n\n"),
|
||||||
|
HumanMessage(content="请生成今日养生食谱")]
|
||||||
})
|
})
|
||||||
last_msg = resp["messages"][-1]
|
last_msg = resp["messages"][-1]
|
||||||
raw_text = last_msg.content.strip()
|
raw_text = last_msg.content.strip()
|
||||||
@@ -51,7 +61,7 @@ def query_recipe_agent():
|
|||||||
recipes = json.loads(raw_text)
|
recipes = json.loads(raw_text)
|
||||||
# 写入内存缓存
|
# 写入内存缓存
|
||||||
memory_store["recipe"] = recipes
|
memory_store["recipe"] = recipes
|
||||||
print("结束生成今日菜谱")
|
print("结束生成今日养生食谱")
|
||||||
return True
|
return True
|
||||||
except json.JSONDecodeError as je:
|
except json.JSONDecodeError as je:
|
||||||
print(f"[JSON解析错误] {str(je)}")
|
print(f"[JSON解析错误] {str(je)}")
|
||||||
@@ -63,5 +73,6 @@ def query_recipe_agent():
|
|||||||
memory_store["recipe"] = []
|
memory_store["recipe"] = []
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_latest_recipe():
|
def get_latest_recipe():
|
||||||
return memory_store["recipe"]
|
return memory_store["recipe"]
|
||||||
Reference in New Issue
Block a user