# competitive-intelligence **Repository Path**: bright-data/competitive-intelligence ## Basic Information - **Project Name**: competitive-intelligence - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-09 - **Last Updated**: 2025-11-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🤖 多智能体竞品情报平台 [](https://www.python.org/downloads/) [](https://fastapi.tiangolo.com/) [](https://reactjs.org/) [](https://www.typescriptlang.org/) [](LICENSE) > 将原需数周的手动竞品调研,借助自治代理与企业级网页抓取,在数分钟内完成 AI 驱动分析。  ## 🌟 功能特性 - 🤖 多智能体工作流:三个专职 AI 代理协同工作 - 📊 研究员代理:使用 Bright Data 进行数据采集与网页抓取 - 🔍 分析师代理:战略性 SWOT 分析与威胁评估 - 📝 撰稿人代理:面向管理层的竞品情报报告 - 🌊 实时流式:进度与工具调用实时可视化 - ⚡ 企业级架构:基于 FastAPI、React 与 TypeScript - 🎯 全面分析:覆盖定价、管理层、市场定位与战略 - 📱 精美界面:借鉴 Vercel 风格的响应式设计 - 🔧 生产就绪:支持 Docker、架构可横向扩展 ## 🚀 快速开始 ### 前置条件 - Python 3.10+ - Node.js 18+ - [Gemini API Key](https://aistudio.google.com/app/apikey) - [Bright Data API Key](https://www.bright.cn/) ### 1. 克隆仓库 ```bash git clone https://github.com/bright-cn/competitive-intelligence.git cd competitive-intelligence ``` ### 2. 后端配置 ```bash # 安装 Python 依赖 cd api && pip install -r requirements.txt # 设置环境变量 export GEMINI_API_KEY="your_gemini_api_key" export BRIGHTDATA_API_KEY="your_brightdata_api_key" # 启动 API 服务 python app.py ``` API 将在 `http://localhost:8000` 提供服务 ### 3. 前端配置 ```bash # 进入前端目录 cd ci-agent-ui # 安装依赖 npm install # 启动开发服务器 npm run dev ``` 前端将运行于 `http://localhost:5173` ### 4. 开始体验! 1. 在浏览器打开前端 2. 选择一个演示场景(Slack、Notion、Figma)或输入自定义公司 3. 点击“Start Analysis”,观看 AI 代理的实时协作 4. 几分钟内获取全面的竞品情报! ## 📋 目录 - [架构](#-架构) - [安装](#-安装) - [API 文档](#-api-文档) - [前端指南](#-前端指南) - [配置](#-配置) - [Docker 部署](#-docker-部署) - [示例](#-示例) - [贡献](#-贡献) - [许可证](#-许可证) ## 🏗️ 架构 ``` ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ 📊 Researcher │───▶│ 🔍 Analyst │───▶│ 📝 Writer │ │ Agent │ │ Agent │ │ Agent │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │ │ │ ▼ ▼ ▼ Data Collection Strategic Analysis Report Generation - Web scraping - SWOT analysis - Executive summary - Market research - Threat assessment - Recommendations - Company intel - Competitive position - Action items ▲ │ ┌─────────────────┐ │ 🌐 FastAPI │ │ Backend │ └─────────────────┘ ▲ │ ┌─────────────────┐ │ ⚛️ React │ │ Frontend │ └─────────────────┘ ``` ### 技术栈 后端: - FastAPI:现代、高性能的 API 框架 - Strands Agents:自治 AI 代理框架 - Bright Data:企业级网页抓取与数据采集 - Google Gemini 2.0:高级语言模型用于分析 - LiteLLM:多模型统一接口 前端: - React 18:现代化 UI 框架(Hooks) - TypeScript:类型安全的 JavaScript 开发 - Vite:极速构建工具与开发服务器 - Tailwind CSS:原子化样式框架 - shadcn/ui:优雅、可访问的组件库 ## 🛠️ 安装 ### 开发环境搭建 1) 克隆并设置后端: ```bash git clone https://github.com/bright-cn/competitive-intelligence.git cd competitive-intelligence # 创建虚拟环境 python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate # 安装依赖 pip install -r requirements-api.txt ``` 2) 设置前端: ```bash cd ci-agent-ui npm install ``` 3) 配置环境变量: ```bash # 复制示例环境文件 cp .env.example .env # 编辑 .env,填入你的 API keys GEMINI_API_KEY=your_gemini_api_key_here BRIGHTDATA_API_KEY=your_brightdata_api_key_here ``` 4) 启动开发服务: ```bash # 终端 1:后端 python app.py # 终端 2:前端 cd ci-agent-ui && npm run dev ``` ### 生产部署 请查看 [Docker 部署](#-docker-部署) 章节获取生产环境部署说明。 ## 📚 API 文档 基础 URL ``` http://localhost:8000 ``` ### 接口 健康检查 ```http GET /health ``` 竞品分析(流式) ```http POST /analyze/stream Content-Type: application/json { "competitor_name": "Slack", "competitor_website": "https://slack.com", "stream": true } ``` 获取演示场景 ```http GET /demo-scenarios ``` 会话管理 ```http GET /sessions GET /sessions/{session_id} ``` 响应示例 ```json { "competitor": "Slack", "website": "https://slack.com", "research_findings": "Comprehensive research data...", "strategic_analysis": "SWOT and competitive analysis...", "final_report": "Executive summary and recommendations...", "timestamp": "2025-09-17T10:30:00Z", "status": "success" } ``` 交互式文档 - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc - OpenAPI Schema: http://localhost:8000/openapi.json ## 🎨 前端指南 关键组件 - `CompetitiveIntelligenceForm`:主分析界面,支持实时流 - `DemoScenarios`:预配置公司示例 - `Header`:导航与品牌 - `ProgressTracker`:代理工作流可视化 可用脚本 ```bash npm run dev # 启动开发服务器 npm run build # 生产构建 npm run preview # 预览生产构建 npm run lint # 运行 ESLint ``` 自定义 - 样式:修改 `tailwind.config.js` - 组件:使用 `npx shadcn@latest add [component]` 添加组件 - API 端点:在组件文件中更新 `API_BASE_URL` ## ⚙️ 配置 环境变量 | 变量 | 描述 | 必需 | 默认值 | |------|------|------|--------| | `GEMINI_API_KEY` | Google AI Studio API key | 是 | - | | `BRIGHTDATA_API_KEY` | Bright Data API key | 是 | - | | `GEMINI_MODEL_NAME` | Gemini 模型版本 | 否 | `gemini-2.0-flash` | | `API_HOST` | API 服务主机 | 否 | `0.0.0.0` | | `API_PORT` | API 服务端口 | 否 | `8000` | | `LOG_LEVEL` | 日志级别 | 否 | `info` | 代理配置 可在 `api/ci_agent.py` 中通过修改 System Prompt 定制各代理: - 研究员代理:数据采集与抓取行为 - 分析师代理:分析深度与战略侧重 - 撰稿人代理:报告结构与排版 ## 🐳 Docker 部署 使用 Docker Compose ```bash # 启动全部服务 docker-compose up -d # 查看日志 docker-compose logs -f # 停止服务 docker-compose down ``` 手动构建 后端: ```bash cd api docker build -t ci-backend . docker run -p 8000:8000 \ -e GEMINI_API_KEY=your_key \ -e BRIGHTDATA_API_KEY=your_key \ ci-backend ``` 前端: ```bash cd ci-agent-ui docker build -t ci-frontend . docker run -p 3000:80 ci-frontend ``` 生产注意事项 - 使用按环境区分的配置文件 - 实施完善的日志与监控 - 配置 SSL/TLS 证书 - 设置限流与安全响应头 - 使用反向代理(nginx/Cloudflare) ## 💻 示例 Python 客户端 ```python import requests # Start streaming analysis response = requests.post( "http://localhost:8000/analyze/stream", json={ "competitor_name": "Slack", "competitor_website": "https://slack.com", "stream": True }, stream=True ) for line in response.iter_lines(decode_unicode=True): if line.startswith("data: "): event = json.loads(line[6:]) print(f"Event: {event['type']}") if event['type'] == 'complete': print("Analysis completed!") break ``` JavaScript/Fetch ```javascript const response = await fetch('/analyze/stream', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ competitor_name: 'Slack', stream: true }) }); const reader = response.body.getReader(); const decoder = new TextDecoder(); while (true) { const { value, done } = await reader.read(); if (done) break; const chunk = decoder.decode(value); // Process streaming events } ``` CLI 用法 ```bash # 运行交互式演示 python api/ci_agent.py # 分析指定竞品 python -c " from api.ci_agent import MultiAgentCompetitiveIntelligence ci = MultiAgentCompetitiveIntelligence() result = ci.run_competitive_intelligence_workflow('Slack') print(result['final_report']) " ``` ## 🧪 测试 后端测试 ```bash cd api pip install pytest httpx pytest tests/ ``` 前端测试 ```bash cd ci-agent-ui npm test npm run test:coverage ``` 集成测试 ```bash # 启动服务 docker-compose up -d # 端到端测试 npm run test:e2e ``` ## 🤝 贡献 欢迎贡献!详情参见 [贡献指南](CONTRIBUTING.md)。 开发流程 1. Fork 仓库 2. 创建功能分支:`git checkout -b feature/amazing-feature` 3. 开发并补充测试 4. 规范化提交:`git commit -m "feat: add amazing feature"` 5. 推送到你的 Fork:`git push origin feature/amazing-feature` 6. 提交 Pull Request 代码风格 - Python:遵循 PEP 8,使用 Black - TypeScript:遵循项目 ESLint 规则 - 提交规范:使用 [Conventional Commits](https://conventionalcommits.org/) ## 📝 变更日志 详见 [CHANGELOG.md](CHANGELOG.md)。 ## 🐛 问题与支持 - Bug 反馈:[GitHub Issues](https://github.com/bright-cn/competitive-intelligence/issues) - 新功能建议:[GitHub Discussions](https://github.com/bright-cn/competitive-intelligence/discussions) - 文档:[Wiki](https://github.com/bright-cn/competitive-intelligence/wiki) ## 📄 许可证 本项目基于 MIT 协议开源,详见 [LICENSE](LICENSE)。 ## 🙏 致谢 - [Strands](https://github.com/strands-ai/strands):自治 AI 代理框架 - [Bright Data](https://www.bright.cn/):企业级网页抓取平台 - [Google Gemini](https://ai.google.dev/):先进语言模型 - [FastAPI](https://fastapi.tiangolo.com/):现代 Python Web 框架 - [shadcn/ui](https://ui.shadcn.com/):优雅的 React 组件库 ## 🔗 链接 - 博客文章:[技术深度解析](https://dev.to/bright-cn/building-multi-agent-competitive-intelligence) ---