agent功能开发增加MCP后端
This commit is contained in:
@@ -1071,38 +1071,68 @@ class MCPAgentIntegrated:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## 规划原则
|
## 规划原则
|
||||||
1. 先收集数据,再分析总结
|
1. **先收集数据,再分析总结**
|
||||||
2. 使用 summarize_news 总结新闻类数据
|
2. **使用 summarize_news 总结新闻类数据**
|
||||||
3. 不超过5个步骤
|
3. **根据问题复杂度灵活规划步骤数**:
|
||||||
4. 最后一步通常是总结
|
- 简单问题(如查询单只股票):2-3 步
|
||||||
|
- 中等复杂度(如对比分析):3-5 步
|
||||||
|
- 复杂问题(如多维度深度分析):5-8 步
|
||||||
|
- 避免过度拆分简单任务
|
||||||
|
4. **每个步骤应有明确目的,避免冗余**
|
||||||
|
5. **最后通常需要总结步骤**(除非用户只要原始数据)
|
||||||
|
|
||||||
## 示例
|
## 示例
|
||||||
|
|
||||||
|
**示例 1: 简单查询(2 步)**
|
||||||
用户:"贵州茅台最近有什么新闻"
|
用户:"贵州茅台最近有什么新闻"
|
||||||
|
|
||||||
计划:
|
|
||||||
```json
|
```json
|
||||||
{{
|
{{
|
||||||
"goal": "查询并总结贵州茅台最新新闻",
|
"goal": "查询并总结贵州茅台最新新闻",
|
||||||
"reasoning": "先搜索新闻,再用 DeepMoney 总结",
|
"reasoning": "简单的新闻查询,只需搜索和总结两步",
|
||||||
"steps": [
|
"steps": [
|
||||||
{{
|
{{"tool": "search_china_news", "arguments": {{"query": "贵州茅台", "top_k": 10}}, "reason": "搜索新闻"}},
|
||||||
"tool": "search_china_news",
|
{{"tool": "summarize_news", "arguments": {{"data": "新闻数据", "focus": "重要动态"}}, "reason": "总结要点"}}
|
||||||
"arguments": {{"query": "贵州茅台", "top_k": 10}},
|
|
||||||
"reason": "搜索贵州茅台相关新闻"
|
|
||||||
}},
|
|
||||||
{{
|
|
||||||
"tool": "summarize_news",
|
|
||||||
"arguments": {{
|
|
||||||
"data": "前面的新闻数据",
|
|
||||||
"focus": "贵州茅台的重要动态和市场影响"
|
|
||||||
}},
|
|
||||||
"reason": "使用DeepMoney总结新闻要点"
|
|
||||||
}}
|
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**示例 2: 中等复杂度(4 步)**
|
||||||
|
用户:"对比分析贵州茅台和五粮液的投资价值"
|
||||||
|
```json
|
||||||
|
{{
|
||||||
|
"goal": "对比分析两只股票的投资价值",
|
||||||
|
"reasoning": "需要分别获取两只股票的数据,然后对比分析",
|
||||||
|
"steps": [
|
||||||
|
{{"tool": "get_stock_info", "arguments": {{"stock_code": "600519"}}, "reason": "获取茅台数据"}},
|
||||||
|
{{"tool": "get_stock_info", "arguments": {{"stock_code": "000858"}}, "reason": "获取五粮液数据"}},
|
||||||
|
{{"tool": "search_china_news", "arguments": {{"query": "茅台 五粮液 对比", "top_k": 5}}, "reason": "搜索对比分析文章"}},
|
||||||
|
{{"tool": "summarize_news", "arguments": {{"data": "新闻", "focus": "投资价值对比"}}, "reason": "总结对比结论"}}
|
||||||
|
]
|
||||||
|
}}
|
||||||
|
```
|
||||||
|
|
||||||
|
**示例 3: 复杂分析(6 步)**
|
||||||
|
用户:"全面分析人工智能概念板块的投资机会"
|
||||||
|
```json
|
||||||
|
{{
|
||||||
|
"goal": "深度分析人工智能板块的投资机会",
|
||||||
|
"reasoning": "需要获取板块数据、龙头股、资金流向、新闻动态等多维度信息",
|
||||||
|
"steps": [
|
||||||
|
{{"tool": "get_concept_stocks", "arguments": {{"concept": "人工智能"}}, "reason": "获取概念成分股"}},
|
||||||
|
{{"tool": "get_concept_money_flow", "arguments": {{"concept": "人工智能"}}, "reason": "获取资金流向"}},
|
||||||
|
{{"tool": "get_limit_up_stocks", "arguments": {{"concept": "人工智能"}}, "reason": "查看涨停股情况"}},
|
||||||
|
{{"tool": "search_china_news", "arguments": {{"query": "人工智能概念股", "top_k": 15}}, "reason": "搜索最新新闻"}},
|
||||||
|
{{"tool": "get_stock_info", "arguments": {{"stock_code": "300496"}}, "reason": "分析龙头股中科创达"}},
|
||||||
|
{{"tool": "summarize_news", "arguments": {{"data": "所有数据", "focus": "投资机会和风险"}}, "reason": "综合分析总结"}}
|
||||||
|
]
|
||||||
|
}}
|
||||||
|
```
|
||||||
|
|
||||||
|
**重要提示**:
|
||||||
|
- 简单问题不要硬凑步骤,2-3 步足够
|
||||||
|
- 复杂问题可以拆分到 6-8 步,但每步必须有实际价值
|
||||||
|
- 避免重复调用相同工具(除非参数不同)
|
||||||
|
|
||||||
只返回JSON,不要其他内容。"""
|
只返回JSON,不要其他内容。"""
|
||||||
|
|
||||||
async def create_plan(self, user_query: str, tools: List[dict]) -> ExecutionPlan:
|
async def create_plan(self, user_query: str, tools: List[dict]) -> ExecutionPlan:
|
||||||
|
|||||||
Reference in New Issue
Block a user