File contents Tasks: 新增新闻分析师 Agent
1. 基础架构搭建
2. 新闻数据源集成
3. 新闻服务实现
4. NewsAnalystAgent 实现
5. 集成到编排器
6. HTTP API 路由
7. 测试
8. 文档和示例
Dependencies
任务 4 依赖任务 1、2、3
任务 5 依赖任务 4
任务 6 依赖任务 3
任务 7 依赖任务 4、5、6
Parallelizable Work
任务 2.1 和 2.2 可并行(不同数据源集成)
任务 3.1、3.2、3.3 可并行(不同服务功能)
任务 6 和任务 5 可并行
Implementation Notes
已完成实现的文件:
src/stock_datasource/modules/news/__init__.py - 模块入口
src/stock_datasource/modules/news/schemas.py - 数据模型定义
src/stock_datasource/modules/news/service.py - 核心服务实现
src/stock_datasource/modules/news/router.py - HTTP API 路由
src/stock_datasource/agents/news_analyst_agent.py - NewsAnalystAgent 实现
数据源说明:
Tushare 公告 :通过 anns 接口获取上市公司公告,需要较高权限
Sina 财经 :通过公开 API 获取财经新闻,无需额外配置
缓存策略:
快讯缓存 TTL:5 分钟
公告缓存 TTL:1 小时
热点话题缓存 TTL:10 分钟
1 --- 2 name: 2479-tasks-3e835521 3 description: Tasks: 新增新闻分析师 Agent 4 --- 5 # Tasks: 新增新闻分析师 Agent 6 7 ## 1. 基础架构搭建 8 9 - [x] 1.1 创建 news 模块目录结构 10 - `src/stock_datasource/modules/news/__init__.py` 11 - `src/stock_datasource/modules/news/service.py` 12 - `src/stock_datasource/modules/news/router.py` 13 - `src/stock_datasource/modules/news/schemas.py` 14 15 - [x] 1.2 定义新闻数据模型 16 - NewsItem(新闻基础结构) 17 - NewsSentiment(情绪分析结果) 18 - HotTopic(热点主题) 19 20 ## 2. 新闻数据源集成 21 22 - [x] 2.1 集成 Tushare 公告数据 23 - 使用 `anns` 接口获取上市公司公告 24 - 在 NewsService 中直接实现(无需单独插件) 25 26 - [x] 2.2 集成 Sina 财经新闻 27 - 实现 Sina 新闻 API 爬取服务 28 - 支持按股票代码、关键词查询 29 30 - [x] 2.3 新闻数据缓存策略 31 - 使用 Redis 缓存热门新闻 32 - 设置合理的缓存过期时间(快讯5分钟,公告1小时,热点10分钟) 33 34 ## 3. 新闻服务实现 35 36 - [x] 3.1 实现 NewsService 核心服务 37 - `get_news_by_stock(stock_code, days=7)` - 获取股票相关新闻 38 - `get_market_news(category, limit=20)` - 获取市场新闻 39 - `search_news(keyword, limit=20)` - 关键词搜索新闻 40 41 - [x] 3.2 实现新闻情绪分析服务 42 - 使用 LLM 分析新闻情绪 43 - 返回利好/利空/中性标签 44 - 返回情绪分数(-1 到 1) 45 - 包含规则降级方案 46 47 - [x] 3.3 实现热点话题服务 48 - 分析最近新闻关键词 49 - 提取市场热点主题 50 - 使用 LLM 提取热点,包含规则降级方案 51 52 ## 4. NewsAnalystAgent 实现 53 54 - [x] 4.1 创建 NewsAnalystAgent 类 55 - 继承 `LangGraphAgent` 基类 56 - 配置 Agent 名称和描述 57 - 设置合适的 temperature (0.5) 58 59 - [x] 4.2 实现 Agent 工具函数 60 - `get_news_by_stock` - 获取股票新闻 61 - `get_market_news` - 获取市场新闻 62 - `analyze_news_sentiment` - 情绪分析 63 - `get_hot_topics` - 热点追踪 64 - `summarize_news` - 新闻摘要 65 66 - [x] 4.3 编写 Agent System Prompt 67 - 定义新闻分析师角色 68 - 说明可用工具 69 - 指导分析逻辑 70 71 ## 5. 集成到编排器 72 73 - [x] 5.1 在 OrchestratorAgent 中注册 NewsAnalystAgent 74 - Orchestrator 使用动态发现机制,无需手动注册 75 - Agent 命名遵循 `*_agent.py` 规范,自动被发现 76 77 - [x] 5.2 更新 agents/__init__.py 导出 78 - 添加 `NewsAnalystAgent` 和 `get_news_analyst_agent` 导出 79 80 ## 6. HTTP API 路由 81 82 - [x] 6.1 创建 news router 83 - `GET /api/news/stock/{code}` - 获取股票新闻 84 - `GET /api/news/market` - 获取市场新闻 85 - `GET /api/news/hot-topics` - 获取热点 86 - `POST /api/news/analyze-sentiment` - 情绪分析 87 - `POST /api/news/summarize` - 新闻摘要 88 - `GET /api/news/search` - 搜索新闻 89 90 - [x] 6.2 注册路由到 main app 91 - 更新 modules/__init__.py 添加 news router 92 93 ## 7. 测试 94 95 - [ ] 7.1 编写单元测试 96 - 测试新闻获取服务 97 - 测试情绪分析功能 98 - 测试 Agent 工具调用 99 100 - [ ] 7.2 编写集成测试 101 - 测试 Agent 端到端流程 102 - 测试与 Orchestrator 的路由 103 104 - [ ] 7.3 手动测试验证 105 - 通过 AI 对话测试新闻查询 106 - 验证情绪分析准确性 107 108 ## 8. 文档和示例 109 110 - [ ] 8.1 更新 README 添加 NewsAnalystAgent 说明 111 - [ ] 8.2 添加使用示例(自然语言查询示例) 112 113 ## Dependencies 114 115 - 任务 4 依赖任务 1、2、3 116 - 任务 5 依赖任务 4 117 - 任务 6 依赖任务 3 118 - 任务 7 依赖任务 4、5、6 119 120 ## Parallelizable Work 121 122 - 任务 2.1 和 2.2 可并行(不同数据源集成) 123 - 任务 3.1、3.2、3.3 可并行(不同服务功能) 124 - 任务 6 和任务 5 可并行 125 126 ## Implementation Notes 127 128 ### 已完成实现的文件: 129 1. `src/stock_datasource/modules/news/__init__.py` - 模块入口 130 2. `src/stock_datasource/modules/news/schemas.py` - 数据模型定义 131 3. `src/stock_datasource/modules/news/service.py` - 核心服务实现 132 4. `src/stock_datasource/modules/news/router.py` - HTTP API 路由 133 5. `src/stock_datasource/agents/news_analyst_agent.py` - NewsAnalystAgent 实现 134 135 ### 数据源说明: 136 - **Tushare 公告**:通过 `anns` 接口获取上市公司公告,需要较高权限 137 - **Sina 财经**:通过公开 API 获取财经新闻,无需额外配置 138 139 ### 缓存策略: 140 - 快讯缓存 TTL:5 分钟 141 - 公告缓存 TTL:1 小时 142 - 热点话题缓存 TTL:10 分钟
tools-only/X-Skills/tree/main/investment/2479-tasks_3e835521 commit 12db4bf2ab
Frequently asked questions How do I install the 2479 Tasks 3e835521 skill? Run npx skillmds@latest add tools-only/2479-tasks-3e835521 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the 2479 Tasks 3e835521 skill do? Tasks: 新增新闻分析师 Agent It is listed under AI & ML on SkillMD.
Is 2479 Tasks 3e835521 safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with 2479 Tasks 3e835521? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is 2479 Tasks 3e835521 free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published 2479 Tasks 3e835521? tools-only (@tools-only) published this skill. Their other Agent Skills are listed on their SkillMD profile.