XunLong (寻龙) 是一个基于大语言模型的智能内容生成系统,能够通过自然语言指令自动生成高质量的研究报告、小说和演示文稿(PPT)。
系统采用多智能体协作架构,通过LangGraph编排智能体工作流,实现从需求分析、资料搜索、内容生成到格式导出的全流程自动化。
克隆项目 ```bash git clone https://github.com/yourusername/XunLong.git cd XunLong ```
创建虚拟环境 ```bash python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate ```
安装依赖 ```bash pip install -r requirements.txt ```
安装系统依赖(PDF导出功能)
macOS: ```bash brew install pango gdk-pixbuf libffi ```
Ubuntu/Debian: ```bash sudo apt-get install libpango-1.0-0 libpangoft2-1.0-0 gdk-pixbuf2.0 ```
安装浏览器(网页搜索功能) ```bash playwright install chromium ```
配置环境变量
复制`.env.example`为`.env`并填入你的API密钥: ```bash cp .env.example .env ```
编辑`.env`文件: ```env
OPENAI_API_KEY=your_openai_api_key OPENAI_BASE_URL=https://api.openai.com/v1 OPENAI_MODEL=gpt-4o
ANTHROPIC_API_KEY=your_anthropic_api_key ANTHROPIC_MODEL=claude-3-5-sonnet-20241022
DEEPSEEK_API_KEY=your_deepseek_api_key DEEPSEEK_BASE_URL=https://api.deepseek.com/v1 DEEPSEEK_MODEL=deepseek-chat
PERPLEXITY_API_KEY=your_perplexity_api_key
LANGFUSE_PUBLIC_KEY=your_langfuse_public_key LANGFUSE_SECRET_KEY=your_langfuse_secret_key LANGFUSE_HOST=https://cloud.langfuse.com ```
XunLong提供简洁的命令行界面:
```bash python xunlong.py [命令] [参数] [选项] ```
```bash
python xunlong.py report "2025年人工智能行业趋势分析"
python xunlong.py report "区块链技术应用研究" \ --style academic \ --depth comprehensive \ --verbose ```
风格选项:
深度选项:
```bash
python xunlong.py fiction "一个关于时间旅行的科幻故事"
python xunlong.py fiction "都市悬疑推理小说" \ --style mystery \ --chapters 10 \ --verbose ```
风格选项:
```bash
python xunlong.py ppt "2025年AI产品发布会" --slides 15
python xunlong.py ppt "公司年度总结报告" \ --style business \ --slides 20 \ --speech-notes "面向全体员工的年度总结" \ --verbose ```
风格选项:
演说稿功能: 使用`--speech-notes`参数可生成每页幻灯片的演讲稿
对已生成的内容进行修改:
```bash
python xunlong.py iterate <项目ID> "在第二章添加更多案例分析"
python xunlong.py iterate <项目ID> "将第5页的图表改为饼图"
python xunlong.py iterate <项目ID> "重写第三章,增加更多悬念" ```
项目ID: 在`storage/`目录下的项目文件夹名,格式如`20251004_220823`
```bash
python xunlong.py export <项目ID> pdf
python xunlong.py export <项目ID> docx
python xunlong.py export <项目ID> pptx
python xunlong.py export <项目ID> pdf --output /path/to/output.pdf ```
``` XunLong/ ├── src/ │ ├── agents/ # 智能体模块 │ │ ├── coordinator.py # 主协调器 │ │ ├── iteration_agent.py # 迭代优化智能体 │ │ ├── report/ # 报告生成智能体 │ │ ├── fiction/ # 小说生成智能体 │ │ ├── ppt/ # PPT生成智能体 │ │ └── html/ # HTML转换智能体 │ ├── llm/ # LLM管理 │ │ ├── manager.py # LLM管理器 │ │ ├── client.py # LLM客户端 │ │ └── prompts.py # 提示词管理 │ ├── search/ # 搜索模块 │ │ ├── web_search.py # 网页搜索 │ │ └── content_extractor.py # 内容提取 │ ├── export/ # 导出模块 │ │ ├── pdf_exporter.py # PDF导出 │ │ ├── docx_exporter.py # DOCX导出 │ │ └── pptx_exporter.py # PPTX导出 │ └── storage/ # 存储管理 │ └── manager.py ├── config/ # 配置文件 ├── templates/ # HTML模板 ├── storage/ # 项目存储目录 ├── xunlong.py # CLI入口 ├── requirements.txt # 依赖清单 └── README_CN.md # 中文文档 ```
XunLong采用基于LangGraph的状态机工作流:
每个项目在`storage/`目录下创建独立文件夹:
``` storage/20251004_220823_项目名称/ ├── metadata.json # 项目元数据 ├── intermediate/ # 中间结果 │ ├── 01_task_decomposition.json │ ├── 02_search_results.json │ └── 03_content_outline.json ├── reports/ # 最终输出 │ ├── FINAL_REPORT.md │ ├── FINAL_REPORT.html │ └── PPT_DATA.json # PPT项目专用 ├── versions/ # 迭代版本 │ └── 20251005_101435/ └── exports/ # 导出文件 ├── report.pdf └── report.docx ```
在`config/llm_config.yaml`中配置多个LLM提供商:
```yaml providers: default: provider: "openai" model: "gpt-4o" temperature: 0.7
creative: provider: "anthropic" model: "claude-3-5-sonnet-20241022" temperature: 0.9
search: provider: "perplexity" model: "sonar" ```
在`config/search_config.yaml`中配置搜索行为:
```yaml search: max_results: 10 timeout: 30 engines: - perplexity # 优先使用Perplexity - playwright # 备用浏览器搜索 ```
HTML模板位于`templates/`目录,支持自定义:
我们欢迎各种形式的贡献!
请通过GitHub Issues报告问题,并提供:
A: 目前支持OpenAI(GPT-4/GPT-3.5)、Anthropic(Claude系列)、DeepSeek等,通过LangChain集成,理论上支持所有兼容OpenAI API的模型。
A: 取决于报告深度和搜索范围,标准报告约5-10分钟,深度报告可能需要15-20分钟。
A: 不可以。系统需要调用LLM API和执行网络搜索,必须联网使用。
A: 生成的内容遵循MIT许可证,但需注意:1) 遵守LLM服务商的使用条款 2) 对内容的准确性和合法性自行负责。
A: 建议:1) 使用更强大的模型(如GPT-4) 2) 提供更详细的需求描述 3) 使用迭代功能多次优化 4) 配置Perplexity API以获得更好的搜索结果。
本项目采用MIT许可证。
感谢以下开源项目:
如果这个项目对你有帮助,请给我们一个⭐️
Made with ❤️ by XunLong Team