This commit is contained in:
aaron 2025-06-21 12:31:36 +08:00
parent 94b77b1949
commit a90256307c
3 changed files with 46 additions and 1 deletions

View File

@ -18,6 +18,7 @@ from cryptoai.agents.crypto_agent import CryptoAgent
from cryptoai.agents.gold_agent import GoldAgent
from cryptoai.utils.config_loader import ConfigLoader
from cryptoai.tasks.user import task_run
from cryptoai.tasks.news import task_run as news_task_run
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
@ -39,6 +40,11 @@ def task_start():
logger.info("积分复位启动")
schedule.every().day.at("00:00").do(task_run)
# 每天08:00执行 新闻获取
logger.info("新闻获取启动")
schedule.every().day.at("08:00").do(news_task_run)
schedule.every().day.at("20:00").do(news_task_run)
while True:
schedule.run_pending()
time.sleep(1)

39
cryptoai/tasks/news.py Normal file
View File

@ -0,0 +1,39 @@
from cryptoai.models.user import User
from cryptoai.utils.db_manager import get_db_context, SessionLocal
from sqlalchemy.orm import Session
import logging
import requests
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
def task_run():
try:
#dify api
url = "http://ai.meida.fit/v1/workflows/run"
token = "app-ov8ji3bC6WrRlOdNt0cxPyg6"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
payload = {
"inputs": {},
"response_mode": "blocking",
"user": "system",
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
except Exception as e:
logger.error(f"新闻获取失败: {e}")

View File

@ -4,7 +4,7 @@ services:
cryptoai-task:
build: .
container_name: cryptoai-task
image: cryptoai:0.0.22
image: cryptoai:0.0.23
restart: always
volumes:
- ./cryptoai/data:/app/cryptoai/data