- enhance to set API Key in .env file instead.

This commit is contained in:
adalard 2025-07-16 12:59:53 +08:00
parent 70329bc3f4
commit b9a3a2dbcc
3 changed files with 15 additions and 0 deletions

4
.env.sample Normal file
View File

@ -0,0 +1,4 @@
# Copy this file to .env and fill in your API keys
OPENAI_API_KEY=
FINNHUB_API_KEY=

View File

@ -19,6 +19,10 @@ from rich.tree import Tree
from rich import box
from rich.align import Align
from rich.rule import Rule
from dotenv import load_dotenv
# Load API keys from .env
load_dotenv()
from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG

View File

@ -1,4 +1,8 @@
import os
from dotenv import load_dotenv
# Load variables from .env
load_dotenv()
DEFAULT_CONFIG = {
"project_dir": os.path.abspath(os.path.join(os.path.dirname(__file__), ".")),
@ -19,4 +23,7 @@ DEFAULT_CONFIG = {
"max_recur_limit": 100,
# Tool settings
"online_tools": True,
# API keys from environment
"openai_api_key": os.getenv("OPENAI_API_KEY", ""),
"finnhub_api_key": os.getenv("FINNHUB_API_KEY", ""),
}