update anspire for web link (#1955)

* update anspire info

* update anspire for web link

---------

Co-authored-by: xiaowei <4775987@qq.com>
This commit is contained in:
Tom
2026-07-07 21:34:31 +08:00
committed by GitHub
parent a3c039ac13
commit bfdee03241
3 changed files with 30 additions and 16 deletions

View File

@@ -24,7 +24,7 @@
## 💖 赞助商 (Sponsors)
<div align="center">
<p align="center">
<a href="https://open.anspire.cn/?share_code=QFBC0FYC" target="_blank"><img src="./docs/assets/anspire.png" alt="Anspire Open 一站式模型和搜索服务" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://open.anspire.cn/dsa?share_code=QFBC0FYC" target="_blank"><img src="./docs/assets/anspire.png" alt="Anspire Open 一站式模型和搜索服务" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis" target="_blank"><img src="./docs/assets/serpapi_banner_zh.png" alt="轻松抓取搜索引擎上的实时金融新闻数据 - SerpApi" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
</p>
</div>
@@ -53,9 +53,9 @@
| 类型 | 支持 |
|------|------|
| AI 模型 | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC)、[AIHubMix](https://aihubmix.com/?aff=CfMq)、Gemini、OpenAI 兼容、DeepSeek、通义千问、Claude、Ollama 本地模型等 |
| AI 模型 | [Anspire](https://open.anspire.cn/dsa?share_code=QFBC0FYC)、[AIHubMix](https://aihubmix.com/?aff=CfMq)、Gemini、OpenAI 兼容、DeepSeek、通义千问、Claude、Ollama 本地模型等 |
| 行情数据 | [TickFlow](https://tickflow.org/auth/register?ref=WDSGSPS5XC)、AkShare、Tushare、Pytdx、Baostock、YFinance、Longbridge |
| 新闻搜索 | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC)、[SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis)、[Tavily](https://tavily.com/)、[Bocha](https://open.bocha.cn/)、[Brave](https://brave.com/search/api/)、[MiniMax](https://platform.minimaxi.com/)、SearXNG |
| 新闻搜索 | [Anspire](https://open.anspire.cn/dsa/?share_code=QFBC0FYC)、[SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis)、[Tavily](https://tavily.com/)、[Bocha](https://open.bocha.cn/)、[Brave](https://brave.com/search/api/)、[MiniMax](https://platform.minimaxi.com/)、SearXNG |
| 社交舆情 | [Stock Sentiment API](https://api.adanos.org/docs)Reddit / X / Polymarket仅美股可选 |
> 项目默认内置 AkShare、Baostock、YFinance 等免费行情源,可零配置运行;免费源受上游限流、接口变动和网络波动影响,稳定性不保证。长期定时、批量分析或更稳定行情建议配置 TickFlow、Tushare、Longbridge 等 token 型数据源适用市场、Actions 映射和 fallback 规则见 [数据源配置](docs/full-guide.md#数据源配置)。
@@ -81,7 +81,7 @@
| Secret 名称 | 说明 | 必填 |
|------------|------|:----:|
| `ANSPIRE_API_KEYS` | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC) API Key一Key同时启用全球热门大模型和联网搜索本项目新用户提供35元等额的免费额度GLM5.2、GPT等模型特惠中 | **推荐** |
| `ANSPIRE_API_KEYS` | [Anspire](https://open.anspire.cn/dsa?share_code=QFBC0FYC) API Key一Key同时启用全球热门大模型和联网搜索本项目新用户提供35元等额的免费额度GLM5.2、GPT等模型特惠中 | **推荐** |
| `AIHUBMIX_KEY` | [AIHubMix](https://aihubmix.com/?aff=CfMq) API Key一Key切换使用全系模型无需科学上网本项目可享 10% 优惠 | **推荐** |
| `GEMINI_API_KEY` | Google Gemini API Key | 可选 |
| `ANTHROPIC_API_KEY` | Anthropic Claude API Key | 可选 |
@@ -115,7 +115,7 @@
| Secret 名称 | 说明 | 必填 |
|------------|------|:----:|
| `ANSPIRE_API_KEYS` | [Anspire AI Search](https://aisearch.anspire.cn/)汇聚全球舆情信息适配A股、美股、港股等新闻和舆情检索同一Key可复用大模型服务本项目新用户提供免费35元等额的免费点数 | **推荐** |
| `ANSPIRE_API_KEYS` | [Anspire AI Search](https://open.anspire.cn/dsa?share_code=QFBC0FYC)汇聚全球舆情信息适配A股、美股、港股等新闻和舆情检索同一Key可复用大模型服务本项目新用户提供免费35元等额的免费点数 | **推荐** |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis):搜索引擎结果补强,适合实时金融新闻 | **推荐** |
| `TAVILY_API_KEYS` | [Tavily](https://tavily.com/):通用新闻搜索 API | 可选 |
| `BOCHA_API_KEYS` | [博查搜索](https://open.bocha.cn/):中文搜索优化,支持 AI 摘要 | 可选 |

View File

@@ -1085,7 +1085,7 @@ class AnspireSearchProvider(BaseSearchProvider):
def __init__(self, api_keys: List[str]):
super().__init__(api_keys, "Anspire")
def _do_search(self, query: str, api_key: str, max_results: int, days: int = 7) -> SearchResponse:
def _do_search(self, query: str, api_key: str, max_results: int, days: int = 7, region_mode: int = 0) -> SearchResponse:
"""执行 Anspire 搜索"""
try:
import requests
@@ -1112,7 +1112,8 @@ class AnspireSearchProvider(BaseSearchProvider):
"query": query,
"top_k": min(max_results,50),
"FromTime": (datetime.now() - timedelta(days=days)).strftime("%Y-%m-%d %H:%M:%S"),
"ToTime": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
"ToTime": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"region_mode": region_mode
}
# 执行搜索

View File

@@ -444,18 +444,35 @@ class TestAnspireIntegration(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Check if API Key is configured."""
"""Check if API Key is configured and valid."""
cls.api_keys = [k.strip() for k in os.getenv('ANSPIRE_API_KEYS', '').split(',') if k.strip()]
cls.has_api_key = len(cls.api_keys) > 0
cls.has_valid_api_key = False # 标记是否有有效的 API Key
if cls.has_api_key:
reset_search_service()
cls.service = get_search_service()
# 验证 API Key 是否有效
try:
# 查找 Anspire provider
for provider in cls.service._providers:
if isinstance(provider, AnspireSearchProvider):
# 执行一次简单的搜索验证
test_response = provider.search("测试", max_results=1)
if test_response.success:
cls.has_valid_api_key = True
break
except Exception:
cls.has_valid_api_key = False
def setUp(self):
"""在每次测试前检查 API Key 是否有效"""
if not os.environ.get("ANSPIRE_API_KEYS"):
self.skipTest("未设置 ANSPIRE_API_KEYS 环境变量,跳过集成测试")
if not getattr(self.__class__, 'has_valid_api_key', False):
self.skipTest("ANSPIRE_API_KEYS 环境变量中的 API Key 无效,跳过集成测试")
@unittest.skipIf(
not os.environ.get("ANSPIRE_API_KEYS"),
"未设置 ANSPIRE_API_KEYS 环境变量,跳过集成测试"
)
@pytest.mark.network
def test_real_api_call_stock_news(self):
"""真实 API 调用测试 - 股票新闻搜索"""
@@ -494,10 +511,6 @@ class TestAnspireIntegration(unittest.TestCase):
# snippet 可能为空,视具体实现而定
# self.assertIsNotNone(result.snippet)
@unittest.skipIf(
not os.environ.get("ANSPIRE_API_KEYS"),
"未设置 ANSPIRE_API_KEYS 环境变量,跳过集成测试"
)
@pytest.mark.network
def test_real_api_call_general_search(self):
"""真实 API 调用测试 - 通用搜索"""