update
This commit is contained in:
parent
94b77b1949
commit
a90256307c
@ -18,6 +18,7 @@ from cryptoai.agents.crypto_agent import CryptoAgent
|
|||||||
from cryptoai.agents.gold_agent import GoldAgent
|
from cryptoai.agents.gold_agent import GoldAgent
|
||||||
from cryptoai.utils.config_loader import ConfigLoader
|
from cryptoai.utils.config_loader import ConfigLoader
|
||||||
from cryptoai.tasks.user import task_run
|
from cryptoai.tasks.user import task_run
|
||||||
|
from cryptoai.tasks.news import task_run as news_task_run
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
@ -39,6 +40,11 @@ def task_start():
|
|||||||
logger.info("积分复位启动")
|
logger.info("积分复位启动")
|
||||||
schedule.every().day.at("00:00").do(task_run)
|
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:
|
while True:
|
||||||
schedule.run_pending()
|
schedule.run_pending()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|||||||
39
cryptoai/tasks/news.py
Normal file
39
cryptoai/tasks/news.py
Normal 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}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -4,7 +4,7 @@ services:
|
|||||||
cryptoai-task:
|
cryptoai-task:
|
||||||
build: .
|
build: .
|
||||||
container_name: cryptoai-task
|
container_name: cryptoai-task
|
||||||
image: cryptoai:0.0.22
|
image: cryptoai:0.0.23
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./cryptoai/data:/app/cryptoai/data
|
- ./cryptoai/data:/app/cryptoai/data
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user