Python 搭建 GEO 多平台监控系统:支持 ChatGPT、豆包、Kimi
背景
随着 AI 模型快速迭代,单一平台监控脚本维护成本较高。痛定思痛,决定写一套通用的 GEO 多平台监控方案。
本文分享完整代码,支持:ChatGPT、豆包、Kimi、文心一言、通义千问。
系统架构
┌─────────────────────────────────────────────────────────┐
│ GEO 多平台监控系统 │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ 任务调度 │→ │ 平台查询 │→ │ 结果分析 │ │
│ └───────────┘ └───────────┘ └───────────┘ │
│ ↑ ↓ ↓ │
│ └──── 告警通知 ←────── 报告生成 ←────── │
│ │
│ 支持平台: │
│ ✅ ChatGPT ✅ 豆包 ✅ Kimi │
│ ✅ 文心一言 ✅ 通义千问 │
└─────────────────────────────────────────────────────────┘
核心代码实现
1. 平台基类
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List, Optional, Dict
from datetime import datetime
import time
import random
@dataclass
class GEOResult:
"""GEO 查询结果"""
platform: str
query: str
brand: str
mentioned: bool
position: int
context: str
timestamp: str
response_time_ms: float
error: Optional[str] =
():
():
.name = name
.api_key = api_key
.base_delay =
() -> :
() -> :
() -> GEOResult:
start_time = time.time()
:
response = .query(search_query)
brand_info = .extract_brand_info(response, brand)
response_time = (time.time() - start_time) *
GEOResult(
platform=.name,
query=search_query,
brand=brand,
mentioned=brand_info[],
position=brand_info[],
context=brand_info[],
timestamp=datetime.now().isoformat(),
response_time_ms=response_time
)
Exception e:
response_time = (time.time() - start_time) *
GEOResult(
platform=.name,
query=search_query,
brand=brand,
mentioned=,
position=,
context=,
timestamp=datetime.now().isoformat(),
response_time_ms=response_time,
error=(e)
)


