feat: AI分析第二档——get_news消息面、板块主力资金流TOPS、两融余额、截断续写机制
This commit is contained in:
@@ -71,6 +71,20 @@ TOOLS = [
|
||||
"required": ["code", "name"]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_news",
|
||||
"description": "获取最近的财经快讯(新浪7x24,含宏观/行业/公司/海外动态),用于重要消息面梳理",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"limit": {"type": "integer", "description": "获取条数,默认30,最大50"}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -92,12 +106,23 @@ async def execute_tool(tool_name: str, arguments: dict) -> str:
|
||||
arguments.get("name", ""),
|
||||
arguments.get("days", 30)
|
||||
)
|
||||
elif tool_name == "get_news":
|
||||
return await _get_news(arguments.get("limit", 30))
|
||||
else:
|
||||
return json.dumps({"error": f"未知工具: {tool_name}"})
|
||||
except Exception as e:
|
||||
return json.dumps({"error": str(e)})
|
||||
|
||||
|
||||
async def _get_news(limit: int = 30) -> str:
|
||||
"""获取财经快讯"""
|
||||
from services.market_extra import fetch_news
|
||||
news = await fetch_news(limit)
|
||||
if not news:
|
||||
return json.dumps({"error": "快讯获取失败或暂无数据"}, ensure_ascii=False)
|
||||
return json.dumps({"count": len(news), "items": news}, ensure_ascii=False)
|
||||
|
||||
|
||||
async def _get_market_dashboard() -> str:
|
||||
"""获取市场看板数据"""
|
||||
from routes.market_dashboard import _build_dashboard
|
||||
|
||||
Reference in New Issue
Block a user