-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fix/openrouter embeddings #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
00make
wants to merge
2
commits into
TauricResearch:main
Choose a base branch
from
00make:fix/openrouter-embeddings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| --- | ||
| description: 如何部署 TradingAgents 项目 | ||
| --- | ||
|
|
||
| # TradingAgents 部署工作流 | ||
|
|
||
| 本工作流描述如何从零开始部署 TradingAgents 多智能体交易框架。 | ||
|
|
||
| ## 前置条件 | ||
|
|
||
| - 已安装 Conda | ||
| - 已安装 Git | ||
| - 有 OpenAI API 密钥 | ||
| - 有 Alpha Vantage API 密钥(免费获取:https://www.alphavantage.co/support/#api-key) | ||
|
|
||
| ## 部署步骤 | ||
|
|
||
| ### 1. 克隆项目(如果还未克隆) | ||
|
|
||
| ```bash | ||
| git clone https://github.com/TauricResearch/TradingAgents.git | ||
| cd TradingAgents | ||
| ``` | ||
|
|
||
| ### 2. 创建 Conda 虚拟环境 | ||
|
|
||
| // turbo | ||
| ```bash | ||
| conda create -n tradingagents python=3.13 -y | ||
| ``` | ||
|
|
||
| ### 3. 激活环境并安装依赖 | ||
|
|
||
| ```bash | ||
| conda activate tradingagents | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| ### 4. 配置 API 密钥 | ||
|
|
||
| 复制示例环境文件: | ||
| python -m cli.main | ||
| ``` | ||
|
|
||
| 这将启动一个交互式界面,你可以选择: | ||
| - 股票代码(ticker) | ||
| - 日期 | ||
| - LLM 模型 | ||
| - 研究深度等参数 | ||
|
|
||
|
Comment on lines
+41
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| #### 方式 2: 使用 Python 代码 | ||
|
|
||
| 创建测试脚本或运行 `main.py`: | ||
|
|
||
| ```python | ||
| from tradingagents.graph.trading_graph import TradingAgentsGraph | ||
| from tradingagents.default_config import DEFAULT_CONFIG | ||
|
|
||
| ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy()) | ||
| _, decision = ta.propagate("NVDA", "2024-05-10") | ||
| print(decision) | ||
| ``` | ||
|
|
||
| ### 6. 自定义配置(可选) | ||
|
|
||
| 你可以修改默认配置来使用不同的 LLM 模型或数据源: | ||
|
|
||
| ```python | ||
| from tradingagents.default_config import DEFAULT_CONFIG | ||
|
|
||
| config = DEFAULT_CONFIG.copy() | ||
| config["deep_think_llm"] = "gpt-4o-mini" # 节省成本 | ||
| config["quick_think_llm"] = "gpt-4o-mini" | ||
| config["max_debate_rounds"] = 1 | ||
|
|
||
| # 配置数据供应商 | ||
| config["data_vendors"] = { | ||
| "core_stock_apis": "yfinance", | ||
| "technical_indicators": "yfinance", | ||
| "fundamental_data": "alpha_vantage", | ||
| "news_data": "alpha_vantage", | ||
| } | ||
|
|
||
| ta = TradingAgentsGraph(debug=True, config=config) | ||
| ``` | ||
|
|
||
| ## 重要提示 | ||
|
|
||
| ⚠️ **成本控制**: 该框架会进行大量 API 调用。测试时建议使用 `gpt-4o-mini` 等较便宜的模型。 | ||
|
|
||
| ⚠️ **免责声明**: TradingAgents 仅用于研究目的,不构成财务、投资或交易建议。 | ||
|
|
||
| ⚠️ **API 限制**: Alpha Vantage 免费版有速率限制。TradingAgents 用户可获得提升的限制(每分钟 60 次请求,无每日限制)。 | ||
|
|
||
| ## 验证部署 | ||
|
|
||
| 运行以下命令验证环境配置正确: | ||
|
|
||
| // turbo | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ```bash | ||
| python test.py | ||
| ``` | ||
|
|
||
| 或者运行一个简单的测试: | ||
|
|
||
| ```bash | ||
| python -c "from tradingagents.graph.trading_graph import TradingAgentsGraph; print('部署成功!')" | ||
| ``` | ||
|
|
||
| ## 故障排除 | ||
|
|
||
| ### 问题: 缺少 API 密钥 | ||
| **解决方案**: 确保 `.env` 文件存在且包含有效的 API 密钥,或设置环境变量。 | ||
|
|
||
| ### 问题: 依赖安装失败 | ||
| **解决方案**: | ||
| - 确保使用 Python 3.13 | ||
| - 尝试升级 pip: `pip install --upgrade pip` | ||
| - 逐个安装依赖以识别问题包 | ||
|
|
||
| ### 问题: Alpha Vantage 速率限制 | ||
| **解决方案**: | ||
| - 等待一分钟后重试 | ||
| - 考虑升级到 Alpha Vantage Premium | ||
| - 或在配置中切换到其他数据源 | ||
|
|
||
| ## 下一步 | ||
|
|
||
| - 查看 `tradingagents/default_config.py` 了解所有可配置选项 | ||
| - 阅读项目文档了解多智能体架构 | ||
| - 加入 Discord 社区: https://discord.com/invite/hk9PGKShPK | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| # DeepSeek API 配置指南 | ||
|
|
||
| ## 📋 配置步骤 | ||
|
|
||
| ### 1. 获取 DeepSeek API 密钥 | ||
|
|
||
| 访问 DeepSeek 官网获取 API 密钥: | ||
| - 网址: https://platform.deepseek.com/ | ||
| - 注册并登录账户 | ||
| - 在 API Keys 页面创建新的 API 密钥 | ||
|
|
||
| ### 2. 配置环境变量 | ||
|
|
||
| 编辑项目根目录下的 `.env` 文件,填入您的 API 密钥: | ||
|
|
||
| ```bash | ||
| # DeepSeek API 密钥(使用 OPENAI_API_KEY 变量名,因为 DeepSeek 兼容 OpenAI SDK) | ||
| OPENAI_API_KEY=your_deepseek_api_key_here | ||
|
|
||
| # Alpha Vantage API 密钥(用于获取股票数据) | ||
| ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here | ||
| ``` | ||
|
|
||
| **重要提示**: | ||
| - DeepSeek API 使用 `OPENAI_API_KEY` 作为环境变量名 | ||
| - 这是因为 DeepSeek 使用 OpenAI 兼容的 API 格式 | ||
| - 不要将其与 OpenAI 的 API 密钥混淆 | ||
|
|
||
| ### 3. 验证配置 | ||
|
|
||
| 运行测试脚本验证 DeepSeek API 是否配置正确: | ||
|
|
||
| ```bash | ||
| conda activate tradingagents | ||
| python test_deepseek.py | ||
| ``` | ||
|
|
||
| 如果看到 "✅ DeepSeek API 配置正确",说明配置成功! | ||
|
|
||
| ## 🚀 运行 TradingAgents | ||
|
|
||
| ### 使用 Python 脚本 | ||
|
|
||
| 已经为您配置好了 `main.py`,直接运行: | ||
|
|
||
| ```bash | ||
| conda activate tradingagents | ||
| python main.py | ||
| ``` | ||
|
|
||
| ### 使用 CLI 界面 | ||
|
|
||
| ```bash | ||
| conda activate tradingagents | ||
| python -m cli.main | ||
| ``` | ||
|
|
||
| ## 🔧 DeepSeek 模型说明 | ||
|
|
||
| 项目已配置使用以下 DeepSeek 模型: | ||
|
|
||
| - **deepseek-reasoner**: 深度思考模型(思考模式) | ||
| - 用于复杂的分析和决策任务 | ||
| - 对应 `deep_think_llm` 配置 | ||
|
|
||
| - **deepseek-chat**: 快速对话模型(非思考模式) | ||
| - 用于快速响应和简单任务 | ||
| - 对应 `quick_think_llm` 配置 | ||
|
|
||
| ## 💰 成本优化建议 | ||
|
|
||
| DeepSeek API 的定价比 OpenAI 更实惠,但仍建议: | ||
|
|
||
| 1. **测试时使用较少的辩论轮次** | ||
| - 当前配置: `max_debate_rounds = 1` | ||
| - 可以根据需要调整 | ||
|
|
||
| 2. **监控 API 使用量** | ||
| - 在 DeepSeek 控制台查看使用情况 | ||
| - 设置使用限额避免超支 | ||
|
|
||
| 3. **使用缓存** | ||
| - 项目会缓存股票数据 | ||
| - 避免重复调用相同数据 | ||
|
|
||
| ## 📊 配置文件说明 | ||
|
|
||
| 主要配置在 `main.py` 中: | ||
|
|
||
| ```python | ||
| config = DEFAULT_CONFIG.copy() | ||
|
|
||
| # DeepSeek API 配置 | ||
| config["llm_provider"] = "openai" # 使用 OpenAI 兼容接口 | ||
| config["backend_url"] = "https://api.deepseek.com" # DeepSeek API 端点 | ||
| config["deep_think_llm"] = "deepseek-reasoner" # 思考模式 | ||
| config["quick_think_llm"] = "deepseek-chat" # 非思考模式 | ||
| config["max_debate_rounds"] = 1 # 辩论轮次 | ||
|
|
||
| # 数据源配置 | ||
| config["data_vendors"] = { | ||
| "core_stock_apis": "yfinance", | ||
| "technical_indicators": "yfinance", | ||
| "fundamental_data": "alpha_vantage", | ||
| "news_data": "alpha_vantage", | ||
| } | ||
| ``` | ||
|
|
||
| ## ❓ 常见问题 | ||
|
|
||
| ### Q: 为什么使用 OPENAI_API_KEY 而不是 DEEPSEEK_API_KEY? | ||
|
|
||
| A: DeepSeek API 使用 OpenAI 兼容的格式,langchain-openai 库默认读取 `OPENAI_API_KEY` 环境变量。通过设置 `base_url="https://api.deepseek.com"`,我们将请求重定向到 DeepSeek 的服务器。 | ||
|
|
||
| ### Q: 可以同时使用 OpenAI 和 DeepSeek 吗? | ||
|
|
||
| A: 可以,但需要修改代码来支持不同的 API 密钥。当前配置只支持一个 LLM 提供商。 | ||
|
|
||
| ### Q: Alpha Vantage API 是必需的吗? | ||
|
|
||
| A: 是的,用于获取股票基本面数据和新闻。您可以免费获取 API 密钥: https://www.alphavantage.co/support/#api-key | ||
|
|
||
| ### Q: 如何切换回 OpenAI? | ||
|
|
||
| A: 修改 `main.py` 中的配置: | ||
| ```python | ||
| config["backend_url"] = "https://api.openai.com/v1" | ||
| config["deep_think_llm"] = "gpt-4o" | ||
| config["quick_think_llm"] = "gpt-4o-mini" | ||
| ``` | ||
| 并在 `.env` 中使用 OpenAI 的 API 密钥。 | ||
|
|
||
| ## 🔗 相关链接 | ||
|
|
||
| - DeepSeek 平台: https://platform.deepseek.com/ | ||
| - DeepSeek API 文档: https://platform.deepseek.com/api-docs/ | ||
| - Alpha Vantage: https://www.alphavantage.co/ | ||
| - TradingAgents GitHub: https://github.com/TauricResearch/TradingAgents |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个
// turbo注释似乎是开发过程中遗留的标记,建议在最终的文档中移除以保持整洁。