feat: 增加食谱Agent

This commit is contained in:
2026-09-01 23:03:17 +08:00
parent 825e097989
commit e71a26e761
5 changed files with 95 additions and 12 deletions

20
main.py
View File

@@ -11,17 +11,25 @@ from service import agent_service
scheduler = BackgroundScheduler()
def job_task():
def tip_job_task():
"""定时执行的任务"""
try:
print(f"定时任务执行: {datetime.now()}")
agent_service.generate_tip_agent()
print(f"今日资讯定时任务执行: {datetime.now()}")
agent_service.query_tip_agent()
except Exception as e:
print(f"定时任务异常: {e}")
print(f"今日资讯定时任务异常: {e}")
def recipe_job_task():
"""定时执行的任务"""
try:
print(f"今日菜谱定时任务执行: {datetime.now()}")
agent_service.query_recipe_agent()
except Exception as e:
print(f"今日菜谱定时任务异常: {e}")
scheduler.add_job(job_task, trigger="cron", hour=2, minute=0, second=0, id="daily_gen_tips", replace_existing=True)
scheduler.add_job(tip_job_task, trigger="cron", hour=2, minute=0, second=0, id="daily_gen_tips", replace_existing=True)
scheduler.add_job(recipe_job_task, trigger="cron", hour=3, minute=0, second=0, id="daily_gen_recipes", replace_existing=True)
@asynccontextmanager
async def lifespan(app: FastAPI):