{"repo": "akatrainning/streamguard", "files": {"README.md": {"01686d2b6f176b2ca64517fc0842eb5890ddbd65": {"t": 1785674035.5014544, "n": 2484, "h": "aec59707e93cff53", "c": "# StreamGuard\n\nStreamGuard is a live-stream compliance monitoring demo. It contains a FastAPI\nbackend and a React/Vite frontend for monitoring live-stream scripts, chat\nsentiment, risk alerts, rule checks, history reports, and Douyin live-room\ndiscovery.\n\n## Project Layout\n\n```text\nstreamguard/\n streamguard-backend/ FastAPI backend, WebSocket streams, ASR/LLM analysis\n streamguard-web/ React + Vite frontend dashboard\n start-backend.ps1 Windows helper for the backend\n start-frontend.ps1 Windows helper for the frontend\n start-dev.ps1 Starts backend and frontend in two PowerShell windows\n```\n\nRemoved legacy AgentDojo research code, experiment outputs, notebooks, and old\ndocumentation so this repository only keeps StreamGuard application content.\n\n## Requirements\n\n- Python 3.10+\n- Node.js 18+\n- Chrome, if you use Douyin live-room discovery or live capture\n\n## Backend\n\n```powershell\ncd streamguard-backend\npip install -r requirements.txt\ncopy .env.example .env\npython -m uvicorn app:app --reload --host 0.0.0.0 --port 8011\n```\n\nThe backend listens on `http://localhost:8011`.\n\nOptional `.env` values:\n\n```env\nLLM_PROVIDER=deepseek\nDEEPSEEK_API_KEY=sk-...\nLLM_BASE_URL=https://api.deepseek.com\nLLM_MODEL=deepseek-v4-flash\n\nASR_OPENAI_API_KEY=sk-...\nLOCAL_WHISPER_MODEL=tiny\nWHISPER_CPU_THREADS=2\nWHISPER_BEAM_SIZE=1\nAUDIO_CAPTURE_WINDOW_SECS=5\nENABLE_LIVE_AUDIO_ASR=1\nDOUYIN_SHOW_BROWSER=0\n```\n\nWithout API keys, the app still supports local/mock workflows and rule-based\nfallback behavior where available.\n\n## Frontend\n\n```powershell\ncd streamguard-web\nnpm install\nnpm run dev\n```\n\nOpen the Vite URL printed in the terminal, usually `http://localhost:5173`.\nThe frontend proxies API and WebSocket calls to backend port `8011`.\n\n## Quick Start On Windows\n\nFrom the repository root:\n\n```powershell\n.\\start-backend.ps1\n.\\start-frontend.ps1\n```\n\nOr start both in separate PowerShell windows:\n\n```powershell\n.\\start-dev.ps1\n```\n\n## Useful Checks\n\n```powershell\ncd streamguard-web\nnpm run build\n\ncd ..\\streamguard-backend\npython -m py_compile app.py douyin_cdp.py douyin_search.py douyin_selenium.py douyin_ws_client.py\n```\n\n## RAG Knowledge Architecture\n\nThe RAG layer is organized as a layered knowledge base: real-time transcript hot memory, historical records, rule graph, and citation-ready evidence documents. See [docs/rag_knowledge_architecture.md](docs/rag_knowledge_architecture.md) for the module design, retrieval policy, and API surface.\n"}, "d2098e6c6e508de536cb0cd437260e9c9f277cf3": {"t": 1785763900.8972054, "n": 2484, "h": "aec59707e93cff53", "c": "# StreamGuard\n\nStreamGuard is a live-stream compliance monitoring demo. It contains a FastAPI\nbackend and a React/Vite frontend for monitoring live-stream scripts, chat\nsentiment, risk alerts, rule checks, history reports, and Douyin live-room\ndiscovery.\n\n## Project Layout\n\n```text\nstreamguard/\n streamguard-backend/ FastAPI backend, WebSocket streams, ASR/LLM analysis\n streamguard-web/ React + Vite frontend dashboard\n start-backend.ps1 Windows helper for the backend\n start-frontend.ps1 Windows helper for the frontend\n start-dev.ps1 Starts backend and frontend in two PowerShell windows\n```\n\nRemoved legacy AgentDojo research code, experiment outputs, notebooks, and old\ndocumentation so this repository only keeps StreamGuard application content.\n\n## Requirements\n\n- Python 3.10+\n- Node.js 18+\n- Chrome, if you use Douyin live-room discovery or live capture\n\n## Backend\n\n```powershell\ncd streamguard-backend\npip install -r requirements.txt\ncopy .env.example .env\npython -m uvicorn app:app --reload --host 0.0.0.0 --port 8011\n```\n\nThe backend listens on `http://localhost:8011`.\n\nOptional `.env` values:\n\n```env\nLLM_PROVIDER=deepseek\nDEEPSEEK_API_KEY=sk-...\nLLM_BASE_URL=https://api.deepseek.com\nLLM_MODEL=deepseek-v4-flash\n\nASR_OPENAI_API_KEY=sk-...\nLOCAL_WHISPER_MODEL=tiny\nWHISPER_CPU_THREADS=2\nWHISPER_BEAM_SIZE=1\nAUDIO_CAPTURE_WINDOW_SECS=5\nENABLE_LIVE_AUDIO_ASR=1\nDOUYIN_SHOW_BROWSER=0\n```\n\nWithout API keys, the app still supports local/mock workflows and rule-based\nfallback behavior where available.\n\n## Frontend\n\n```powershell\ncd streamguard-web\nnpm install\nnpm run dev\n```\n\nOpen the Vite URL printed in the terminal, usually `http://localhost:5173`.\nThe frontend proxies API and WebSocket calls to backend port `8011`.\n\n## Quick Start On Windows\n\nFrom the repository root:\n\n```powershell\n.\\start-backend.ps1\n.\\start-frontend.ps1\n```\n\nOr start both in separate PowerShell windows:\n\n```powershell\n.\\start-dev.ps1\n```\n\n## Useful Checks\n\n```powershell\ncd streamguard-web\nnpm run build\n\ncd ..\\streamguard-backend\npython -m py_compile app.py douyin_cdp.py douyin_search.py douyin_selenium.py douyin_ws_client.py\n```\n\n## RAG Knowledge Architecture\n\nThe RAG layer is organized as a layered knowledge base: real-time transcript hot memory, historical records, rule graph, and citation-ready evidence documents. See [docs/rag_knowledge_architecture.md](docs/rag_knowledge_architecture.md) for the module design, retrieval policy, and API surface.\n"}, "56700f17c4f036bc118269e2a11e3708e0cef933": {"t": 1785763903.1998281, "n": 2157, "h": "4f919ee6fa70e932", "c": "# StreamGuard\n\nStreamGuard is a live-stream compliance monitoring demo. It contains a FastAPI\nbackend and a React/Vite frontend for monitoring live-stream scripts, chat\nsentiment, risk alerts, rule checks, history reports, and Douyin live-room\ndiscovery.\n\n## Project Layout\n\n```text\nstreamguard/\n streamguard-backend/ FastAPI backend, WebSocket streams, ASR/LLM analysis\n streamguard-web/ React + Vite frontend dashboard\n start-backend.ps1 Windows helper for the backend\n start-frontend.ps1 Windows helper for the frontend\n start-dev.ps1 Starts backend and frontend in two PowerShell windows\n```\n\nRemoved legacy AgentDojo research code, experiment outputs, notebooks, and old\ndocumentation so this repository only keeps StreamGuard application content.\n\n## Requirements\n\n- Python 3.10+\n- Node.js 18+\n- Chrome, if you use Douyin live-room discovery or live capture\n\n## Backend\n\n```powershell\ncd streamguard-backend\npip install -r requirements.txt\ncopy .env.example .env\npython -m uvicorn app:app --reload --host 0.0.0.0 --port 8011\n```\n\nThe backend listens on `http://localhost:8011`.\n\nOptional `.env` values:\n\n```env\nLLM_PROVIDER=deepseek\nDEEPSEEK_API_KEY=sk-...\nLLM_BASE_URL=https://api.deepseek.com\nLLM_MODEL=deepseek-v4-flash\n\nASR_OPENAI_API_KEY=sk-...\nLOCAL_WHISPER_MODEL=tiny\nWHISPER_CPU_THREADS=2\nWHISPER_BEAM_SIZE=1\nAUDIO_CAPTURE_WINDOW_SECS=5\nENABLE_LIVE_AUDIO_ASR=1\nDOUYIN_SHOW_BROWSER=0\n```\n\nWithout API keys, the app still supports local/mock workflows and rule-based\nfallback behavior where available.\n\n## Frontend\n\n```powershell\ncd streamguard-web\nnpm install\nnpm run dev\n```\n\nOpen the Vite URL printed in the terminal, usually `http://localhost:5173`.\nThe frontend proxies API and WebSocket calls to backend port `8011`.\n\n## Quick Start On Windows\n\nFrom the repository root:\n\n```powershell\n.\\start-backend.ps1\n.\\start-frontend.ps1\n```\n\nOr start both in separate PowerShell windows:\n\n```powershell\n.\\start-dev.ps1\n```\n\n## Useful Checks\n\n```powershell\ncd streamguard-web\nnpm run build\n\ncd ..\\streamguard-backend\npython -m py_compile app.py douyin_cdp.py douyin_search.py douyin_selenium.py douyin_ws_client.py\n```\n"}, "2d4c27572ac42e9ca597f8364dbb66b16ba0a089": {"t": 1785763904.6921685, "n": 2109, "h": "bfc5430d9661ec1d", "c": "# StreamGuard\n\nStreamGuard is a live-stream compliance monitoring demo. It contains a FastAPI\nbackend and a React/Vite frontend for monitoring live-stream scripts, chat\nsentiment, risk alerts, rule checks, history reports, and Douyin live-room\ndiscovery.\n\n## Project Layout\n\n```text\nstreamguard/\n streamguard-backend/ FastAPI backend, WebSocket streams, ASR/LLM analysis\n streamguard-web/ React + Vite frontend dashboard\n start-backend.ps1 Windows helper for the backend\n start-frontend.ps1 Windows helper for the frontend\n start-dev.ps1 Starts backend and frontend in two PowerShell windows\n```\n\nRemoved legacy AgentDojo research code, experiment outputs, notebooks, and old\ndocumentation so this repository only keeps StreamGuard application content.\n\n## Requirements\n\n- Python 3.10+\n- Node.js 18+\n- Chrome, if you use Douyin live-room discovery or live capture\n\n## Backend\n\n```powershell\ncd streamguard-backend\npip install -r requirements.txt\ncopy .env.example .env\npython -m uvicorn app:app --reload --host 0.0.0.0 --port 8011\n```\n\nThe backend listens on `http://localhost:8011`.\n\nOptional `.env` values:\n\n```env\nLLM_PROVIDER=deepseek\nDEEPSEEK_API_KEY=sk-...\nLLM_BASE_URL=https://api.deepseek.com\nLLM_MODEL=deepseek-v4-flash\n\nASR_OPENAI_API_KEY=sk-...\nLOCAL_WHISPER_MODEL=base\nWHISPER_CPU_THREADS=2\nENABLE_LIVE_AUDIO_ASR=0\nDOUYIN_SHOW_BROWSER=0\n```\n\nWithout API keys, the app still supports local/mock workflows and rule-based\nfallback behavior where available.\n\n## Frontend\n\n```powershell\ncd streamguard-web\nnpm install\nnpm run dev\n```\n\nOpen the Vite URL printed in the terminal, usually `http://localhost:5173`.\nThe frontend proxies API and WebSocket calls to backend port `8011`.\n\n## Quick Start On Windows\n\nFrom the repository root:\n\n```powershell\n.\\start-backend.ps1\n.\\start-frontend.ps1\n```\n\nOr start both in separate PowerShell windows:\n\n```powershell\n.\\start-dev.ps1\n```\n\n## Useful Checks\n\n```powershell\ncd streamguard-web\nnpm run build\n\ncd ..\\streamguard-backend\npython -m py_compile app.py douyin_cdp.py douyin_search.py douyin_selenium.py douyin_ws_client.py\n```\n"}, "6c2cc5f59ca09e2660b14bd4de92dd6090b3c176": {"t": 1785763905.9768803, "n": 4776, "h": "6b3957536df342ec", "c": "# StreamGuard — 直播语义鉴别系统\n\n> 实时感知直播间话术风险、弹幕舆情与合规异常的 AI 监控平台\n\n---\n\n## 项目简介\n\nStreamGuard 是一套面向直播电商场景的实时合规监控系统。系统通过接入直播音频,将主播话术转写为文本后,联合大语言模型(LLM)与规则引擎进行语义合规分析;同时对弹幕舆情进行轻量级情感意图识别,最终在可视化仪表盘上展示风险评分、违规告警与趋势分析,帮助运营团队在直播进行中实时发现陷阱话术、虚假宣传等违规内容。\n\n---\n\n## 核心功能\n\n### 1. 实时话术分析\n- **音频自动转写**:优先调用 OpenAI Whisper API(云端),网络不可用时自动切换为本地 faster-whisper 模型(无需 API Key)\n- **LLM + 规则双引擎**:DeepSeek / OpenAI 大模型对话术进行语义合规评分,同时以规则引擎作为零延迟基线兜底\n- **三类话术分类**:事实陈述(fact)/ 夸大话术(hype)/ 陷阱话术(trap)\n- **四维子评分**:语义一致性、事实核验度、合规分、主观性指数\n- **润色与关键词提取**:LLM 自动将 ASR 原始转写整理为通顺句子并提取核心关键词\n\n### 2. 弹幕舆情分析\n- **零延迟规则识别**:纯关键词规则引擎,无需 LLM 调用,即时输出\n- **七类意图分类**:购买意向 / 提问咨询 / 客诉投诉 / 质疑话术 / 支持主播 / 广告刷屏 / 普通弹幕\n- **情感极性判断**:正向 / 负向 / 中性\n- **弹幕-话术关联性**:识别弹幕是否在支持或质疑当前主播话术\n- **刷屏过滤**:检测重复字符集刷屏行为\n\n### 3. 可视化仪表盘\n- **理性指数仪表盘(RationalityGauge)**:实时显示当前直播间整体话术合规水位\n- **风险雷达图(RiskRadar)**:多维度合规评分雷达可视化\n- **语义拓扑图(TopologyGraph)**:话术节点与弹幕关联网络图\n- **语义信息流(SemanticFeed)**:按时间线滚动展示话术与弹幕分析结果\n- **高危告警横幅(AlertBanner)**:检测到高风险内容时自动弹出告警\n\n### 4. 直播发现与对比\n- **抖音直播间搜索**:通过关键词搜索抖音在播直播间,展示主播信息、观众数、直播标题等\n- **AI 评分对比**:同时选取多个直播间,由 AI 进行综合评级与横向对比\n- **Cookie 鉴权**:支持扫码登录或粘贴 Cookie 方式实现账号授权\n- **直播流接入**:通过 Selenium + Chrome CDP 自动发现 m3u8/flv 直播媒体流,免手动配置\n\n### 5. 消费者顾问\n- **商品搜索**:输入关键词,搜索当前直播间相关商品\n- **个性化分析**:结合用户预算、核心需求与当前直播话术证据,由 AI 生成购买建议\n- **风险提示**:将直播话术中检测到的违规内容作为负面证据纳入购买建议报告\n\n### 6. 规则中心\n- **30 条合规规则**,覆盖四大法规领域:\n - 《广告法》7 条(极限词、虚假广告、医疗广告等)\n - 《消费者权益保护法》6 条(知情权、虚假承诺等)\n - 《电子商务法》6 条(强制搭售、平台责任等)\n - 直播行业规范 10 条(主播资质、数据造假、未成年人保护等)\n- 每条规则含:风险等级 / 违规次数统计 / 监测关键词 / 违规示例 / 详细条文说明\n- 支持按法规分类筛选与全文关键词搜索\n\n### 7. 历史归档与会话报告\n- **会话存储**:每次监控会话结束后自动生成并保存报告(基于 localStorage)\n- **报告内容**:话术总数、三类分布、合规评分、高危话术摘录、弹幕舆情统计\n- **历史列表**:支持重命名、查看详情、删除单条及清空全部\n- **可视化报告**:以柱状图展示历史会话合规分趋势\n\n### 8. 数据统计分析\n- 7 日话术类型趋势折线图\n- 话术类型分布饼图\n- 多维合规能力雷达图(价格透明度 / 话术压力值 / 描述真实度 / 时间紧迫感 / 证据充分度 / 合规得分)\n- KPI 卡片:总话术数 / 高危话术数 / 平均合规分 / 监测时长\n\n### 9. 指挥中心(Command Center)\n- WebSocket 连接状态实时监控(已连接 / 连接中 / 重试中 / 已断开)\n- 消息吞吐量统计(总消息数 / 每分钟消息率)\n- 实时日志滚动面板(终端风格,自动滚底)\n- 快速导出当前会话 JSON 快照\n\n---\n\n## 技术栈\n\n| 层级 | 技术 |\n|------|------|\n| 前端框架 | React 18 + Vite |\n| 动效库 | Framer Motion |\n| 图表库 | Recharts |\n| 后端框架 | FastAPI(Python 3.10+) |\n| 大语言模型 | DeepSeek(默认)/ OpenRouter / OpenAI |\n| 语音转写(云端)| OpenAI Whisper API |\n| 语音转写(本地)| faster-whisper(CPU int8 量化) |\n| 音频采集 | imageio-ffmpeg(内置 ffmpeg,无需手动安装) |\n| 浏览器自动化 | Selenium + webdriver-manager + Chrome CDP |\n| 环境配置 | python-dotenv |\n\n---\n\n## 快速启动\n\n### 环境要求\n- Python 3.10+\n- Node.js 18+\n- (可选)Conda 环境\n\n### 1. 后端启动\n\n```bash\ncd streamguard-backend\n\n# 安装依赖\npip install -r requirements.txt\n\n# 配置环境变量(复制示例文件后填写 API Key)\n# 编辑 .env,填入 DEEPSEEK_API_KEY 等\n\n# 启动后端服务(默认端口 8011)\nuvicorn app:app --host 0.0.0.0 --port 8011 --reload\n```\n\n或使用项目根目录的启动脚本:\n\n```powershell\n.\\start-backend.ps1\n```\n\n### 2. 前端启动\n\n```bash\ncd streamguard-web\nnpm install\nnpm run dev\n# 打开 http://localhost:5173\n```\n\n### 3. 环境变量配置\n\n在 `streamguard-backend/.env` 中配置以下变量:\n\n```env\n# 大语言模型(三选一,优先级:DeepSeek > OpenRouter > OpenAI)\nDEEPSEEK_API_KEY=sk-xxxxxxxx\nLLM_BASE_URL=https://api.deepseek.com/v1\nLLM_MODEL=deepseek-chat\n\n# 语音转写(可选,不填则自动使用本地 faster-whisper)\nASR_OPENAI_API_KEY=sk-xxxxxxxx\n\n# 本地 Whisper 模型大小(tiny/base/small/medium,默认 base)\nLOCAL_WHISPER_MODEL=base\n\n# ASR 性能调优(可选)\nWHISPER_CPU_THREADS=2\nWHISPER_BEAM_SIZE=1\nAUDIO_CAPTURE_IDLE=2\n```\n\n---\n\n## 数据源模式\n\n| 模式 | 说明 |\n|------|------|\n| 模拟数据 | 内置 15 条话术 + 20 条弹幕随机循环播放,无需任何账号或网络 |\n| 抖音直播间 | 输入直播间 ID,通过 Selenium 自动发现媒体流,采集真实音频进行转写分析 |\n\n---\n\n## 项目结构\n\n```\nstreamguard/\n├── streamguard-backend/ # FastAPI 后端\n│ ├── app.py # 主入口:API 路由、ASR、LLM 分析、WebSocket\n│ ├── douyin_search.py # 抖音直播间搜索与 Cookie 管理\n│ ├── requirements.txt # Python 依赖\n│ └── .env # 环境变量(需自行创建)\n│\n└── streamguard-web/ # React 前端\n └── src/\n ├── pages/\n │ ├── WelcomePage.jsx # 欢迎引导页\n │ ├── AnalyticsPage.jsx # 数据统计分析\n │ ├── HistoryPage.jsx # 历史会话归档\n │ ├── RulesPage.jsx # 合规规则中心(30 条)\n │ ├── ConsumerAdvisorPage.jsx # 消费者顾问\n │ └── LiveDiscoverPage.jsx # 抖音直播间发现\n └── components/\n ├── Header.jsx # 顶部导航与会话控制栏\n ├── CommandCenter.jsx # 指挥中心(连接状态与日志)\n ├── SemanticFeed.jsx # 话术/弹幕实时信息流\n ├── RationalityGauge.jsx # 理性指数仪表盘\n ├── RiskRadar.jsx # 风险雷达图\n ├── TopologyGraph.jsx # 语义拓扑图\n ├── AlertBanner.jsx # 高危告警横幅\n ├── LiveVideoPlayer.jsx # 直播视频播放器\n └── SessionReportModal.jsx # 会话报告弹窗\n```\n\n---\n\n## 合规覆盖范围\n\n| 法规 | 条数 | 典型违规场景 |\n|------|------|------------|\n| 广告法 | 7 条 | 极限词、虚假广告、医疗夸大、未成年人广告 |\n| 消费者权益保护法 | 6 条 | 知情权缺失、虚假承诺、强制搭售 |\n| 电子商务法 | 6 条 | 平台连带责任、价格欺诈、刷单造假 |\n| 直播行业规范 | 10 条 | 主播资质、数据造假、打赏诱导、内容低俗、未成年人保护 |\n\n---\n\n## License\n\n本项目仅供学习与研究使用。\n"}, "4826c4d6a64efcdea7ac2e4500ce1965419574ac": {"t": 1785763907.2972639, "n": 3186, "h": "6349ef886bc81da4", "c": "