新增AI
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
from airflow.operators.bash import BashOperator
|
||||||
|
import pendulum
|
||||||
|
from airflow import DAG
|
||||||
|
|
||||||
|
with DAG(
|
||||||
|
dag_id="ai_stock_dag",
|
||||||
|
# 每天运行
|
||||||
|
schedule_interval="20 9 * * *",
|
||||||
|
start_date=pendulum.datetime(2025, 4, 23, tz="Asia/Shanghai"),
|
||||||
|
catchup=True
|
||||||
|
) as dag:
|
||||||
|
t1 = BashOperator(
|
||||||
|
task_id='ai_stock',
|
||||||
|
bash_command='python /opt/airflow/dags/repo/dags/ai/stock/dag_ai_stock.py',
|
||||||
|
)
|
||||||
|
t1
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
from goojia_utils import MysqlClient, ArkAIClient, dingutils
|
||||||
|
|
||||||
|
db_util = MysqlClient(
|
||||||
|
host="192.168.0.93",
|
||||||
|
port=3306,
|
||||||
|
database="stock",
|
||||||
|
user="root",
|
||||||
|
password="Goojia123456"
|
||||||
|
)
|
||||||
|
|
||||||
|
stocks = db_util.scan_by_sql_to_data_frame("select * from mu_stocks where `year_month`= (select max(`year_month`) from mu_stocks)")
|
||||||
|
|
||||||
|
url = "http://didata-cloud-server.fangjia.com/chat/deepseek"
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'content': f"帮我分析一下以下哪只股票上涨概率比较大:\n{stocks.to_markdown()}",
|
||||||
|
'roleTips': '你是一个股票投资者,用表格的形式展示结果,你用1-10分来综合评价股票,按照评分高低顺序输出'
|
||||||
|
}
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
ark_client = ArkAIClient()
|
||||||
|
|
||||||
|
messages = [
|
||||||
|
ark_client.build_system_message("你是一个股票投资者,用表格的形式展示结果,你用1-10分来综合评价股票,按照评分高低顺序输出"),
|
||||||
|
ark_client.build_user_message(f"帮我分析一下以下哪只股票上涨概率比较大:\n{stocks.to_markdown()}")
|
||||||
|
]
|
||||||
|
|
||||||
|
# 发送请求
|
||||||
|
response = ark_client.chat_completion(messages)
|
||||||
|
|
||||||
|
if response:
|
||||||
|
dingutils.send_text("【选股】:\n" + response["content"], "1e5f9aaeb90b091bc79652b52800cad2f1dee1ac0990149252511965f6d1c12a")
|
||||||
Reference in New Issue
Block a user