This commit is contained in:
parent
8ce12c8183
commit
91ad37412b
|
|
@ -5,7 +5,9 @@ OPENAI_API_KEY=openai_api_key_placeholder
|
||||||
# Optional API Keys (for alternative LLM providers)
|
# Optional API Keys (for alternative LLM providers)
|
||||||
ANTHROPIC_API_KEY=anthropic_api_key_placeholder
|
ANTHROPIC_API_KEY=anthropic_api_key_placeholder
|
||||||
GOOGLE_API_KEY=GOOGLE_API_KEY_placeholder
|
GOOGLE_API_KEY=GOOGLE_API_KEY_placeholder
|
||||||
OPENROUTER_API_KEY=openrouter_api_key_placeholder
|
XAI_API_KEY=XAI_API_KEY_placeholder
|
||||||
|
DEEPSEEK_API_KEY=deepseek_api_key_placeholder
|
||||||
|
DASHSCOPE_API_KEY=dashscope_api_key_placeholder
|
||||||
|
|
||||||
# Deployment Configuration
|
# Deployment Configuration
|
||||||
TRADINGAGENTS_RESULTS_DIR=/app/results
|
TRADINGAGENTS_RESULTS_DIR=/app/results
|
||||||
|
|
|
||||||
16
README.md
16
README.md
|
|
@ -207,7 +207,7 @@ ALPHA_VANTAGE_API_KEY=your-alpha-vantage-key
|
||||||
# 其他 LLM 提供商 (可選)
|
# 其他 LLM 提供商 (可選)
|
||||||
ANTHROPIC_API_KEY=your-claude-api-key
|
ANTHROPIC_API_KEY=your-claude-api-key
|
||||||
GOOGLE_API_KEY=your-gemini-api-key
|
GOOGLE_API_KEY=your-gemini-api-key
|
||||||
OPENROUTER_API_KEY=your-openrouter-api-key
|
GOOGLE_API_KEY=your-gemini-api-key
|
||||||
|
|
||||||
# ============ 後端服務配置 ============
|
# ============ 後端服務配置 ============
|
||||||
BACKEND_HOST=0.0.0.0
|
BACKEND_HOST=0.0.0.0
|
||||||
|
|
@ -341,21 +341,19 @@ docker compose down -v
|
||||||
|
|
||||||
**快速思維模型** (用於快速分析和即時回應):
|
**快速思維模型** (用於快速分析和即時回應):
|
||||||
- `gpt-5.1-2025-11-13` - GPT-5.1 (最新)
|
- `gpt-5.1-2025-11-13` - GPT-5.1 (最新)
|
||||||
- `gpt-5-mini-2025-08-07` - GPT-5 Mini
|
- `gpt-5-mini-2025-08-07` - GPT-5 Mini (預設)
|
||||||
- `gpt-5-nano-2025-08-07` - GPT-5 Nano
|
- `gpt-5-nano-2025-08-07` - GPT-5 Nano
|
||||||
- `gpt-4.1-mini` - GPT-4.1 Mini
|
- `gpt-4.1-mini` - GPT-4.1 Mini
|
||||||
- `gpt-4.1-nano` - GPT-4.1 Nano
|
- `gpt-4.1-nano` - GPT-4.1 Nano
|
||||||
- `gpt-4o` - GPT-4o (推薦預設)
|
- `o4-mini-2025-04-16` - o4-mini
|
||||||
- `gpt-4o-mini` - GPT-4o Mini (預設)
|
|
||||||
|
|
||||||
**深層思維模型** (用於複雜推理和深度分析):
|
**深層思維模型** (用於複雜推理和深度分析):
|
||||||
- `gpt-5.1-2025-11-13` - GPT-5.1 (最新)
|
- `gpt-5.1-2025-11-13` - GPT-5.1 (最新)
|
||||||
- `gpt-5-mini-2025-08-07` - GPT-5 Mini
|
- `gpt-5-mini-2025-08-07` - GPT-5 Mini (預設)
|
||||||
- `gpt-5-nano-2025-08-07` - GPT-5 Nano
|
- `gpt-5-nano-2025-08-07` - GPT-5 Nano
|
||||||
- `gpt-4.1-mini` - GPT-4.1 Mini
|
- `gpt-4.1-mini` - GPT-4.1 Mini
|
||||||
- `gpt-4.1-nano` - GPT-4.1 Nano
|
- `gpt-4.1-nano` - GPT-4.1 Nano
|
||||||
- `gpt-4o` - GPT-4o (推薦預設)
|
- `o4-mini-2025-04-16` - o4-mini
|
||||||
- `gpt-4o-mini` - GPT-4o Mini
|
|
||||||
|
|
||||||
> 💡 **提示**: 快速思維模型用於初步分析和資料收集,深層思維模型用於複雜決策和策略制定。您可以根據需求選擇不同的模型組合。
|
> 💡 **提示**: 快速思維模型用於初步分析和資料收集,深層思維模型用於複雜決策和策略制定。您可以根據需求選擇不同的模型組合。
|
||||||
|
|
||||||
|
|
@ -410,7 +408,7 @@ curl -X POST http://localhost:8000/api/analyze \
|
||||||
"ticker": "NVDA",
|
"ticker": "NVDA",
|
||||||
"analysis_date": "2024-01-15",
|
"analysis_date": "2024-01-15",
|
||||||
"research_depth": "medium",
|
"research_depth": "medium",
|
||||||
"model": "gpt-4o",
|
"model": "gpt-5-mini-2025-08-07",
|
||||||
"selected_analysts": ["market", "sentiment", "news", "fundamental"],
|
"selected_analysts": ["market", "sentiment", "news", "fundamental"],
|
||||||
"api_key": "sk-your-openai-key"
|
"api_key": "sk-your-openai-key"
|
||||||
}'
|
}'
|
||||||
|
|
@ -502,7 +500,7 @@ TradingAgents 模擬真實交易公司的組織架構,每個代理都有其專
|
||||||
- 支援 OpenAI (GPT-4, GPT-4o, o1 系列)
|
- 支援 OpenAI (GPT-4, GPT-4o, o1 系列)
|
||||||
- 支援 Anthropic Claude
|
- 支援 Anthropic Claude
|
||||||
- 支援 Google Gemini
|
- 支援 Google Gemini
|
||||||
- 可透過 OpenRouter 存取更多模型
|
- 支援 Google Gemini
|
||||||
|
|
||||||
#### 3. 長期記憶系統
|
#### 3. 長期記憶系統
|
||||||
- 使用 ChromaDB 向量資料庫儲存歷史決策
|
- 使用 ChromaDB 向量資料庫儲存歷史決策
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ class Settings(BaseSettings):
|
||||||
results_dir: str = "./results"
|
results_dir: str = "./results"
|
||||||
max_debate_rounds: int = 1
|
max_debate_rounds: int = 1
|
||||||
max_risk_discuss_rounds: int = 1
|
max_risk_discuss_rounds: int = 1
|
||||||
deep_think_llm: str = "gpt-4o-mini"
|
deep_think_llm: str = "gpt-5-mini-2025-08-07"
|
||||||
quick_think_llm: str = "gpt-4o-mini"
|
quick_think_llm: str = "gpt-5-mini-2025-08-07"
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
env_file = ".env"
|
env_file = ".env"
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ class AnalysisRequest(BaseModel):
|
||||||
description="List of analysts to include in analysis"
|
description="List of analysts to include in analysis"
|
||||||
)
|
)
|
||||||
research_depth: Optional[int] = Field(default=1, ge=1, le=5, description="Research depth (1-5)")
|
research_depth: Optional[int] = Field(default=1, ge=1, le=5, description="Research depth (1-5)")
|
||||||
deep_think_llm: Optional[str] = Field(default="gpt-4o-mini", description="Deep thinking LLM model")
|
deep_think_llm: Optional[str] = Field(default="gpt-5-mini-2025-08-07", description="Deep thinking LLM model")
|
||||||
quick_think_llm: Optional[str] = Field(default="gpt-4o-mini", description="Quick thinking LLM model")
|
quick_think_llm: Optional[str] = Field(default="gpt-5-mini-2025-08-07", description="Quick thinking LLM model")
|
||||||
|
|
||||||
# API Configuration
|
# API Configuration
|
||||||
openai_api_key: Optional[str] = Field(None, description="OpenAI API Key (optional if set on server)", min_length=0)
|
openai_api_key: Optional[str] = Field(None, description="OpenAI API Key (optional if set on server)", min_length=0)
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ class TradingService:
|
||||||
def create_config(
|
def create_config(
|
||||||
self,
|
self,
|
||||||
research_depth: int = 1,
|
research_depth: int = 1,
|
||||||
deep_think_llm: str = "gpt-4o-mini",
|
deep_think_llm: str = "gpt-5-mini-2025-08-07",
|
||||||
quick_think_llm: str = "gpt-4o-mini",
|
quick_think_llm: str = "gpt-5-mini-2025-08-07",
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Create configuration for TradingAgents"""
|
"""Create configuration for TradingAgents"""
|
||||||
config = self.default_config.copy()
|
config = self.default_config.copy()
|
||||||
|
|
@ -47,8 +47,8 @@ class TradingService:
|
||||||
alpha_vantage_api_key: Optional[str] = None,
|
alpha_vantage_api_key: Optional[str] = None,
|
||||||
analysts: Optional[List[str]] = None,
|
analysts: Optional[List[str]] = None,
|
||||||
research_depth: int = 1,
|
research_depth: int = 1,
|
||||||
deep_think_llm: str = "gpt-4o-mini",
|
deep_think_llm: str = "gpt-5-mini-2025-08-07",
|
||||||
quick_think_llm: str = "gpt-4o-mini",
|
quick_think_llm: str = "gpt-5-mini-2025-08-07",
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Run trading analysis for a given ticker and date with user-provided API keys
|
Run trading analysis for a given ticker and date with user-provided API keys
|
||||||
|
|
@ -170,21 +170,45 @@ class TradingService:
|
||||||
def get_available_llms(self) -> List[str]:
|
def get_available_llms(self) -> List[str]:
|
||||||
"""Get list of available OpenAI LLM models"""
|
"""Get list of available OpenAI LLM models"""
|
||||||
return [
|
return [
|
||||||
|
# OpenAI
|
||||||
"gpt-5.1-2025-11-13",
|
"gpt-5.1-2025-11-13",
|
||||||
"gpt-5-mini-2025-08-07",
|
"gpt-5-mini-2025-08-07",
|
||||||
"gpt-5-nano-2025-08-07",
|
"gpt-5-nano-2025-08-07",
|
||||||
"gpt-4.1-mini",
|
"gpt-4.1-mini",
|
||||||
"gpt-4.1-nano",
|
"gpt-4.1-nano",
|
||||||
"gpt-4o",
|
"o4-mini-2025-04-16",
|
||||||
"gpt-4o-mini",
|
# Anthropic
|
||||||
|
"claude-haiku-4-5-20251001",
|
||||||
|
"claude-sonnet-4-5-20250929",
|
||||||
|
"claude-sonnet-4-0",
|
||||||
|
"claude-3-5-haiku-20241022",
|
||||||
|
"claude-3-haiku-20240307",
|
||||||
|
# Google
|
||||||
|
"gemini-2.0-flash-lite",
|
||||||
|
"gemini-2.0-flash",
|
||||||
|
"gemini-2.5-flash-lite",
|
||||||
|
# Grok
|
||||||
|
"grok-4-1-fast-reasoning",
|
||||||
|
"grok-4-1-fast-non-reasoning",
|
||||||
|
"grok-4-fast-reasoning",
|
||||||
|
"grok-4-fast-non-reasoning",
|
||||||
|
"grok-4-0709",
|
||||||
|
"grok-3",
|
||||||
|
"grok-3-mini",
|
||||||
|
# DeepSeek
|
||||||
|
"deepseek-reasoner",
|
||||||
|
"deepseek-chat",
|
||||||
|
# Qwen
|
||||||
|
"qwen3-max",
|
||||||
|
"qwen-plus",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_default_config(self) -> Dict[str, Any]:
|
def get_default_config(self) -> Dict[str, Any]:
|
||||||
"""Get default configuration"""
|
"""Get default configuration"""
|
||||||
return {
|
return {
|
||||||
"research_depth": 1,
|
"research_depth": 1,
|
||||||
"deep_think_llm": "gpt-4o-mini",
|
"deep_think_llm": "gpt-5-mini-2025-08-07",
|
||||||
"quick_think_llm": "gpt-4o-mini",
|
"quick_think_llm": "gpt-5-mini-2025-08-07",
|
||||||
"max_debate_rounds": 1,
|
"max_debate_rounds": 1,
|
||||||
"max_risk_discuss_rounds": 1,
|
"max_risk_discuss_rounds": 1,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
74
cli/utils.py
74
cli/utils.py
|
|
@ -187,28 +187,36 @@ def select_shallow_thinking_agent(provider) -> str:
|
||||||
("GPT-5-nano","gpt-5-nano-2025-08-07"),
|
("GPT-5-nano","gpt-5-nano-2025-08-07"),
|
||||||
("GPT-4.1-mini", "gpt-4.1-mini"),
|
("GPT-4.1-mini", "gpt-4.1-mini"),
|
||||||
("GPT-4.1-nano", "gpt-4.1-nano"),
|
("GPT-4.1-nano", "gpt-4.1-nano"),
|
||||||
("GPT-4o", "gpt-4o"),
|
("o4-mini", "o4-mini-2025-04-16")
|
||||||
("GPT-4o-mini", "gpt-4o-mini")
|
|
||||||
],
|
],
|
||||||
"anthropic": [
|
"anthropic": [
|
||||||
("Claude Haiku 3.5", "claude-3-5-haiku-latest"),
|
("Claude Haiku 4.5", "claude-haiku-4-5-20251001"),
|
||||||
("Claude Sonnet 3.5", "claude-3-5-sonnet-latest"),
|
("Claude Sonnet 4.5", "claude-sonnet-4-5-20250929"),
|
||||||
("Claude Sonnet 3.7", "claude-3-7-sonnet-latest"),
|
|
||||||
("Claude Sonnet 4", "claude-sonnet-4-0"),
|
("Claude Sonnet 4", "claude-sonnet-4-0"),
|
||||||
|
("Claude Haiku 3.5", "claude-3-5-haiku-20241022"),
|
||||||
|
("Claude Haiku 3", "claude-3-haiku-20240307")
|
||||||
],
|
],
|
||||||
"google": [
|
"google": [
|
||||||
("Gemini 2.0 Flash-Lite", "gemini-2.0-flash-lite"),
|
("Gemini 2.0 Flash-Lite", "gemini-2.0-flash-lite"),
|
||||||
("Gemini 2.0 Flash", "gemini-2.0-flash"),
|
("Gemini 2.0 Flash", "gemini-2.0-flash"),
|
||||||
("Gemini 2.5 Flash", "gemini-2.5-flash-preview-05-20"),
|
("Gemini 2.5 Flash Lite", "gemini-2.5-flash-lite")
|
||||||
],
|
],
|
||||||
"openrouter": [
|
"Grok":[
|
||||||
("Meta: Llama 4 Scout", "meta-llama/llama-4-scout:free"),
|
("Grok 4.1 Fast Reasoning","grok-4-1-fast-reasoning"),
|
||||||
("Meta: Llama 3.3 8B Instruct - Llama 3.3 70B", "meta-llama/llama-3.3-8b-instruct:free"),
|
("Grok 4.1 Fast Non Reasoning","grok-4-1-fast-non-reasoning"),
|
||||||
("google/gemini-2.0-flash-exp:free - Gemini Flash 2.0", "google/gemini-2.0-flash-exp:free"),
|
("Grok 4 Fast Reasoning","grok-4-fast-reasoning"),
|
||||||
|
("Grok 4 Fast Non Reasoning","grok-4-fast-non-reasoning"),
|
||||||
|
("Grok 4","grok-4-0709"),
|
||||||
|
("Grok 3","grok-3"),
|
||||||
|
("Grok 3 Mini","grok-3-mini")
|
||||||
],
|
],
|
||||||
"ollama": [
|
"DeepSeek": [
|
||||||
("llama3.1 本機版", "llama3.1"),
|
("DeepSeek Reasoner","deepseek-reasoner"),
|
||||||
("llama3.2 本機版", "llama3.2"),
|
("DeepSeek Chat","deepseek-chat")
|
||||||
|
],
|
||||||
|
"Qwen":[
|
||||||
|
("Qwen 3.5 Max", "qwen3-max"),
|
||||||
|
("Qwen Plus", "qwen-plus")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,29 +269,36 @@ def select_deep_thinking_agent(provider) -> str:
|
||||||
("GPT-5-nano","gpt-5-nano-2025-08-07"),
|
("GPT-5-nano","gpt-5-nano-2025-08-07"),
|
||||||
("GPT-4.1-mini", "gpt-4.1-mini"),
|
("GPT-4.1-mini", "gpt-4.1-mini"),
|
||||||
("GPT-4.1-nano", "gpt-4.1-nano"),
|
("GPT-4.1-nano", "gpt-4.1-nano"),
|
||||||
("GPT-4o", "gpt-4o"),
|
("o4-mini", "o4-mini-2025-04-16")
|
||||||
("GPT-4o-mini", "gpt-4o-mini")
|
|
||||||
],
|
],
|
||||||
"anthropic": [
|
"anthropic": [
|
||||||
("Claude Haiku 3.5", "claude-3-5-haiku-latest"),
|
("Claude Haiku 4.5", "claude-haiku-4-5-20251001"),
|
||||||
("Claude Sonnet 3.5", "claude-3-5-sonnet-latest"),
|
("Claude Sonnet 4.5", "claude-sonnet-4-5-20250929"),
|
||||||
("Claude Sonnet 3.7", "claude-3-7-sonnet-latest"),
|
|
||||||
("Claude Sonnet 4", "claude-sonnet-4-0"),
|
("Claude Sonnet 4", "claude-sonnet-4-0"),
|
||||||
("Claude Opus 4", "claude-opus-4-0"),
|
("Claude Haiku 3.5", "claude-3-5-haiku-20241022"),
|
||||||
|
("Claude Haiku 3", "claude-3-haiku-20240307")
|
||||||
],
|
],
|
||||||
"google": [
|
"google": [
|
||||||
("Gemini 2.0 Flash-Lite", "gemini-2.0-flash-lite"),
|
("Gemini 2.0 Flash-Lite", "gemini-2.0-flash-lite"),
|
||||||
("Gemini 2.0 Flash", "gemini-2.0-flash"),
|
("Gemini 2.0 Flash", "gemini-2.0-flash"),
|
||||||
("Gemini 2.5 Flash", "gemini-2.5-flash-preview-05-20"),
|
("Gemini 2.5 Flash Lite", "gemini-2.5-flash-lite")
|
||||||
("Gemini 2.5 Pro", "gemini-2.5-pro-preview-06-05"),
|
|
||||||
],
|
],
|
||||||
"openrouter": [
|
"Grok":[
|
||||||
("DeepSeek V3 - 一個 685B 參數的專家混合模型", "deepseek/deepseek-chat-v3-0324:free"),
|
("Grok 4.1 Fast Reasoning","grok-4-1-fast-reasoning"),
|
||||||
("Deepseek - DeepSeek 團隊旗艦聊天模型的最新版本", "deepseek/deepseek-chat-v3-0324:free"),
|
("Grok 4.1 Fast Non Reasoning","grok-4-1-fast-non-reasoning"),
|
||||||
|
("Grok 4 Fast Reasoning","grok-4-fast-reasoning"),
|
||||||
|
("Grok 4 Fast Non Reasoning","grok-4-fast-non-reasoning"),
|
||||||
|
("Grok 4","grok-4-0709"),
|
||||||
|
("Grok 3","grok-3"),
|
||||||
|
("Grok 3 Mini","grok-3-mini")
|
||||||
],
|
],
|
||||||
"ollama": [
|
"DeepSeek":[
|
||||||
("llama3.1 本機版", "llama3.1"),
|
("DeepSeek Reasoner","deepseek-reasoner"),
|
||||||
("qwen3", "qwen3"),
|
("DeepSeek Chat","deepseek-chat")
|
||||||
|
],
|
||||||
|
"Qwen":[
|
||||||
|
("Qwen 3.5 Max", "qwen3-max"),
|
||||||
|
("Qwen Plus", "qwen-plus")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,8 +341,9 @@ def select_llm_provider() -> tuple[str, str]:
|
||||||
("OpenAI", "https://api.openai.com/v1"),
|
("OpenAI", "https://api.openai.com/v1"),
|
||||||
("Anthropic", "https://api.anthropic.com/"),
|
("Anthropic", "https://api.anthropic.com/"),
|
||||||
("Google", "https://generativelanguage.googleapis.com/v1"),
|
("Google", "https://generativelanguage.googleapis.com/v1"),
|
||||||
("Openrouter", "https://openrouter.ai/api/v1"),
|
("Grok", "https://api.x.ai/v1"),
|
||||||
("Ollama", "http://localhost:11434/v1"),
|
("DeepSeek", "https://api.deepseek.com"),
|
||||||
|
("Qwen", "https://dashscope-intl.aliyuncs.com/compatible-mode/v1")
|
||||||
]
|
]
|
||||||
|
|
||||||
choice = questionary.select(
|
choice = questionary.select(
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ export function AnalysisForm({ onSubmit, loading = false }: AnalysisFormProps) {
|
||||||
analysis_date: format(new Date(), "yyyy-MM-dd"),
|
analysis_date: format(new Date(), "yyyy-MM-dd"),
|
||||||
analysts: ["market", "social", "news", "fundamentals"], // 預設全選
|
analysts: ["market", "social", "news", "fundamentals"], // 預設全選
|
||||||
research_depth: 3, // 預設中等層級
|
research_depth: 3, // 預設中等層級
|
||||||
shallow_thinking_agent: "gpt-4o-mini",
|
shallow_thinking_agent: "gpt-5-mini-2025-08-07",
|
||||||
deep_thinking_agent: "gpt-4o",
|
deep_thinking_agent: "gpt-5-mini-2025-08-07",
|
||||||
openai_api_key: "",
|
openai_api_key: "",
|
||||||
openai_base_url: "https://api.openai.com/v1",
|
openai_base_url: "https://api.openai.com/v1",
|
||||||
alpha_vantage_api_key: "",
|
alpha_vantage_api_key: "",
|
||||||
|
|
@ -236,13 +236,42 @@ export function AnalysisForm({ onSubmit, loading = false }: AnalysisFormProps) {
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="gpt-5.1-2025-11-13">GPT-5.1</SelectItem>
|
{/* OpenAI */}
|
||||||
<SelectItem value="gpt-5-mini-2025-08-07">GPT-5 Mini</SelectItem>
|
<SelectItem value="gpt-5.1-2025-11-13">OpenAI: GPT-5.1</SelectItem>
|
||||||
<SelectItem value="gpt-5-nano-2025-08-07">GPT-5 Nano</SelectItem>
|
<SelectItem value="gpt-5-mini-2025-08-07">OpenAI: GPT-5 Mini</SelectItem>
|
||||||
<SelectItem value="gpt-4.1-mini">GPT-4.1 Mini</SelectItem>
|
<SelectItem value="gpt-5-nano-2025-08-07">OpenAI: GPT-5 Nano</SelectItem>
|
||||||
<SelectItem value="gpt-4.1-nano">GPT-4.1 Nano</SelectItem>
|
<SelectItem value="gpt-4.1-mini">OpenAI: GPT-4.1 Mini</SelectItem>
|
||||||
<SelectItem value="gpt-4o">GPT-4o</SelectItem>
|
<SelectItem value="gpt-4.1-nano">OpenAI: GPT-4.1 Nano</SelectItem>
|
||||||
<SelectItem value="gpt-4o-mini">GPT-4o Mini</SelectItem>
|
<SelectItem value="o4-mini-2025-04-16">OpenAI: o4-mini</SelectItem>
|
||||||
|
|
||||||
|
{/* Anthropic */}
|
||||||
|
<SelectItem value="claude-haiku-4-5-20251001">Anthropic: Claude Haiku 4.5</SelectItem>
|
||||||
|
<SelectItem value="claude-sonnet-4-5-20250929">Anthropic: Claude Sonnet 4.5</SelectItem>
|
||||||
|
<SelectItem value="claude-sonnet-4-0">Anthropic: Claude Sonnet 4</SelectItem>
|
||||||
|
<SelectItem value="claude-3-5-haiku-20241022">Anthropic: Claude 3.5 Haiku</SelectItem>
|
||||||
|
<SelectItem value="claude-3-haiku-20240307">Anthropic: Claude 3 Haiku</SelectItem>
|
||||||
|
|
||||||
|
{/* Google */}
|
||||||
|
<SelectItem value="gemini-2.0-flash-lite">Google: Gemini 2.0 Flash-Lite</SelectItem>
|
||||||
|
<SelectItem value="gemini-2.0-flash">Google: Gemini 2.0 Flash</SelectItem>
|
||||||
|
<SelectItem value="gemini-2.5-flash-lite">Google: Gemini 2.5 Flash Lite</SelectItem>
|
||||||
|
|
||||||
|
{/* Grok */}
|
||||||
|
<SelectItem value="grok-4-1-fast-reasoning">Grok: 4.1 Fast Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-1-fast-non-reasoning">Grok: 4.1 Fast Non Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-fast-reasoning">Grok: 4 Fast Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-fast-non-reasoning">Grok: 4 Fast Non Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-0709">Grok: 4</SelectItem>
|
||||||
|
<SelectItem value="grok-3">Grok: 3</SelectItem>
|
||||||
|
<SelectItem value="grok-3-mini">Grok: 3 Mini</SelectItem>
|
||||||
|
|
||||||
|
{/* DeepSeek */}
|
||||||
|
<SelectItem value="deepseek-reasoner">DeepSeek: Reasoner</SelectItem>
|
||||||
|
<SelectItem value="deepseek-chat">DeepSeek: Chat</SelectItem>
|
||||||
|
|
||||||
|
{/* Qwen */}
|
||||||
|
<SelectItem value="qwen3-max">Qwen: 3.5 Max</SelectItem>
|
||||||
|
<SelectItem value="qwen-plus">Qwen: Plus</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
|
|
@ -266,13 +295,42 @@ export function AnalysisForm({ onSubmit, loading = false }: AnalysisFormProps) {
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="gpt-5.1-2025-11-13">GPT-5.1</SelectItem>
|
{/* OpenAI */}
|
||||||
<SelectItem value="gpt-5-mini-2025-08-07">GPT-5 Mini</SelectItem>
|
<SelectItem value="gpt-5.1-2025-11-13">OpenAI: GPT-5.1</SelectItem>
|
||||||
<SelectItem value="gpt-5-nano-2025-08-07">GPT-5 Nano</SelectItem>
|
<SelectItem value="gpt-5-mini-2025-08-07">OpenAI: GPT-5 Mini</SelectItem>
|
||||||
<SelectItem value="gpt-4.1-mini">GPT-4.1 Mini</SelectItem>
|
<SelectItem value="gpt-5-nano-2025-08-07">OpenAI: GPT-5 Nano</SelectItem>
|
||||||
<SelectItem value="gpt-4.1-nano">GPT-4.1 Nano</SelectItem>
|
<SelectItem value="gpt-4.1-mini">OpenAI: GPT-4.1 Mini</SelectItem>
|
||||||
<SelectItem value="gpt-4o">GPT-4o</SelectItem>
|
<SelectItem value="gpt-4.1-nano">OpenAI: GPT-4.1 Nano</SelectItem>
|
||||||
<SelectItem value="gpt-4o-mini">GPT-4o Mini</SelectItem>
|
<SelectItem value="o4-mini-2025-04-16">OpenAI: o4-mini</SelectItem>
|
||||||
|
|
||||||
|
{/* Anthropic */}
|
||||||
|
<SelectItem value="claude-haiku-4-5-20251001">Anthropic: Claude Haiku 4.5</SelectItem>
|
||||||
|
<SelectItem value="claude-sonnet-4-5-20250929">Anthropic: Claude Sonnet 4.5</SelectItem>
|
||||||
|
<SelectItem value="claude-sonnet-4-0">Anthropic: Claude Sonnet 4</SelectItem>
|
||||||
|
<SelectItem value="claude-3-5-haiku-20241022">Anthropic: Claude 3.5 Haiku</SelectItem>
|
||||||
|
<SelectItem value="claude-3-haiku-20240307">Anthropic: Claude 3 Haiku</SelectItem>
|
||||||
|
|
||||||
|
{/* Google */}
|
||||||
|
<SelectItem value="gemini-2.0-flash-lite">Google: Gemini 2.0 Flash-Lite</SelectItem>
|
||||||
|
<SelectItem value="gemini-2.0-flash">Google: Gemini 2.0 Flash</SelectItem>
|
||||||
|
<SelectItem value="gemini-2.5-flash-lite">Google: Gemini 2.5 Flash Lite</SelectItem>
|
||||||
|
|
||||||
|
{/* Grok */}
|
||||||
|
<SelectItem value="grok-4-1-fast-reasoning">Grok: 4.1 Fast Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-1-fast-non-reasoning">Grok: 4.1 Fast Non Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-fast-reasoning">Grok: 4 Fast Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-fast-non-reasoning">Grok: 4 Fast Non Reasoning</SelectItem>
|
||||||
|
<SelectItem value="grok-4-0709">Grok: 4</SelectItem>
|
||||||
|
<SelectItem value="grok-3">Grok: 3</SelectItem>
|
||||||
|
<SelectItem value="grok-3-mini">Grok: 3 Mini</SelectItem>
|
||||||
|
|
||||||
|
{/* DeepSeek */}
|
||||||
|
<SelectItem value="deepseek-reasoner">DeepSeek: Reasoner</SelectItem>
|
||||||
|
<SelectItem value="deepseek-chat">DeepSeek: Chat</SelectItem>
|
||||||
|
|
||||||
|
{/* Qwen */}
|
||||||
|
<SelectItem value="qwen3-max">Qwen: 3.5 Max</SelectItem>
|
||||||
|
<SelectItem value="qwen-plus">Qwen: Plus</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
|
|
@ -311,12 +369,67 @@ export function AnalysisForm({ onSubmit, loading = false }: AnalysisFormProps) {
|
||||||
name="openai_base_url"
|
name="openai_base_url"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>OpenAI Base URL(選填)</FormLabel>
|
<FormLabel>API Base URL</FormLabel>
|
||||||
<FormControl>
|
<Select
|
||||||
<Input placeholder="https://api.openai.com/v1" {...field} />
|
onValueChange={(value) => {
|
||||||
</FormControl>
|
if (value !== "custom") {
|
||||||
|
field.onChange(value);
|
||||||
|
} else {
|
||||||
|
field.onChange(""); // Clear value for custom input
|
||||||
|
}
|
||||||
|
// Store selection state if needed, or just rely on field value
|
||||||
|
}}
|
||||||
|
defaultValue={
|
||||||
|
[
|
||||||
|
"https://api.openai.com/v1",
|
||||||
|
"https://api.anthropic.com/",
|
||||||
|
"https://generativelanguage.googleapis.com/v1",
|
||||||
|
"https://api.x.ai/v1",
|
||||||
|
"https://api.deepseek.com",
|
||||||
|
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
||||||
|
].includes(field.value || "")
|
||||||
|
? field.value
|
||||||
|
: "custom"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="選擇 API 端點" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="https://api.openai.com/v1">OpenAI (預設)</SelectItem>
|
||||||
|
<SelectItem value="https://api.anthropic.com/">Anthropic</SelectItem>
|
||||||
|
<SelectItem value="https://generativelanguage.googleapis.com/v1">Google Gemini</SelectItem>
|
||||||
|
<SelectItem value="https://api.x.ai/v1">Grok (xAI)</SelectItem>
|
||||||
|
<SelectItem value="https://api.deepseek.com">DeepSeek</SelectItem>
|
||||||
|
<SelectItem value="https://dashscope-intl.aliyuncs.com/compatible-mode/v1">Qwen (Alibaba)</SelectItem>
|
||||||
|
<SelectItem value="custom">自訂端點</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
{/* Show input only when custom is selected or value is not in the list */}
|
||||||
|
{(![
|
||||||
|
"https://api.openai.com/v1",
|
||||||
|
"https://api.anthropic.com/",
|
||||||
|
"https://generativelanguage.googleapis.com/v1",
|
||||||
|
"https://api.x.ai/v1",
|
||||||
|
"https://api.deepseek.com",
|
||||||
|
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
||||||
|
].includes(field.value || "") || field.value === "") && (
|
||||||
|
<div className="mt-2">
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="請輸入自訂 Base URL"
|
||||||
|
value={field.value || ""}
|
||||||
|
onChange={field.onChange}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
API 基礎網址(預設為 OpenAI 官方)
|
選擇或輸入 LLM 服務的 API 基礎網址
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
|
||||||
4
main.py
4
main.py
|
|
@ -8,8 +8,8 @@ load_dotenv(override=True)
|
||||||
|
|
||||||
# 建立自訂設定
|
# 建立自訂設定
|
||||||
config = DEFAULT_CONFIG.copy()
|
config = DEFAULT_CONFIG.copy()
|
||||||
config["deep_think_llm"] = "gpt-4o-mini" # 使用不同的模型
|
config["deep_think_llm"] = "gpt-5-mini-2025-08-07" # 使用不同的模型
|
||||||
config["quick_think_llm"] = "gpt-4o-mini" # 使用不同的模型
|
config["quick_think_llm"] = "gpt-5-mini-2025-08-07" # 使用不同的模型
|
||||||
config["max_debate_rounds"] = 1 # 增加辯論回合
|
config["max_debate_rounds"] = 1 # 增加辯論回合
|
||||||
|
|
||||||
# 設定資料供應商 (預設使用 yfinance 和 alpha_vantage)
|
# 設定資料供應商 (預設使用 yfinance 和 alpha_vantage)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ def create_research_manager(llm, memory):
|
||||||
return text[:max_chars] + "\n...(內容已截斷)"
|
return text[:max_chars] + "\n...(內容已截斷)"
|
||||||
|
|
||||||
# 為每個報告設置合理的字符限制
|
# 為每個報告設置合理的字符限制
|
||||||
# 模型 gpt-4o-mini 的限制是 8192 tokens
|
# 模型 gpt-5-mini 的限制是 8192 tokens
|
||||||
# 混合中英文估算: 1 字符 ≈ 1.5-2 tokens (取保守值)
|
# 混合中英文估算: 1 字符 ≈ 1.5-2 tokens (取保守值)
|
||||||
# 目標: 總字符數 < 3500 字符 (約 5250-7000 tokens,留足夠 tokens 給 completion)
|
# 目標: 總字符數 < 3500 字符 (約 5250-7000 tokens,留足夠 tokens 給 completion)
|
||||||
market_research_report = truncate_text(market_research_report, 500)
|
market_research_report = truncate_text(market_research_report, 500)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ def create_risk_manager(llm, memory):
|
||||||
return text[:max_chars] + "\n...(內容已截斷)"
|
return text[:max_chars] + "\n...(內容已截斷)"
|
||||||
|
|
||||||
# 為每個報告設置合理的字符限制
|
# 為每個報告設置合理的字符限制
|
||||||
# 模型 gpt-4o-mini 的限制是 8192 tokens
|
# 模型 gpt-5-mini 的限制是 8192 tokens
|
||||||
# 混合中英文估算: 1 字符 ≈ 1.5-2 tokens (取保守值)
|
# 混合中英文估算: 1 字符 ≈ 1.5-2 tokens (取保守值)
|
||||||
# 目標: 總字符數 < 3500 字符 (約 5250-7000 tokens,留足夠 tokens 給 completion)
|
# 目標: 總字符數 < 3500 字符 (約 5250-7000 tokens,留足夠 tokens 給 completion)
|
||||||
market_research_report = truncate_text(market_research_report, 500)
|
market_research_report = truncate_text(market_research_report, 500)
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,7 @@ from openai import OpenAI
|
||||||
|
|
||||||
class FinancialSituationMemory:
|
class FinancialSituationMemory:
|
||||||
def __init__(self, name, config):
|
def __init__(self, name, config):
|
||||||
if config["backend_url"] == "http://localhost:11434/v1":
|
self.embedding = "text-embedding-3-small"
|
||||||
self.embedding = "nomic-embed-text"
|
|
||||||
else:
|
|
||||||
self.embedding = "text-embedding-3-small"
|
|
||||||
# Get the OpenAI API key from environment variable
|
# Get the OpenAI API key from environment variable
|
||||||
openai_api_key = os.getenv("OPENAI_API_KEY")
|
openai_api_key = os.getenv("OPENAI_API_KEY")
|
||||||
self.client = OpenAI(base_url=config["backend_url"], api_key=openai_api_key)
|
self.client = OpenAI(base_url=config["backend_url"], api_key=openai_api_key)
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ DEFAULT_CONFIG = {
|
||||||
)),
|
)),
|
||||||
# LLM 設定
|
# LLM 設定
|
||||||
"llm_provider": "openai",
|
"llm_provider": "openai",
|
||||||
"deep_think_llm": "gpt-4o-mini",
|
"deep_think_llm": "gpt-5-mini-2025-08-07",
|
||||||
"quick_think_llm": "gpt-4o-mini",
|
"quick_think_llm": "gpt-5-mini-2025-08-07",
|
||||||
"backend_url": "https://api.openai.com/v1",
|
"backend_url": "https://api.openai.com/v1",
|
||||||
# 辯論與討論設定
|
# 辯論與討論設定
|
||||||
"max_debate_rounds": 1,
|
"max_debate_rounds": 1,
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ class TradingAgentsGraph:
|
||||||
|
|
||||||
# 初始化 LLM
|
# 初始化 LLM
|
||||||
provider = self.config["llm_provider"].lower()
|
provider = self.config["llm_provider"].lower()
|
||||||
if provider in ["openai", "ollama", "openrouter"]:
|
if provider in ["openai"]:
|
||||||
# Get the OpenAI API key from environment variable
|
# Get the OpenAI API key from environment variable
|
||||||
openai_api_key = os.getenv("OPENAI_API_KEY")
|
openai_api_key = os.getenv("OPENAI_API_KEY")
|
||||||
self.deep_thinking_llm = ChatOpenAI(
|
self.deep_thinking_llm = ChatOpenAI(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue