Python
Add environment variable configuration support
luohy157fc9c28a94d1
diff --git a/.env.example b/.env.examplenew file mode 100644index 000000000..1e257c3c5--- /dev/null+++ b/.env.example@@ -0,0 +1,2 @@+ALPHA_VANTAGE_API_KEY=alpha_vantage_api_key_placeholder+OPENAI_API_KEY=openai_api_key_placeholder\ No newline at end of filediff --git a/README.md b/README.mdindex ad293904c..4557fc29c 100644--- a/README.md+++ b/README.md@@ -124,6 +124,12 @@ You will need the OpenAI API for all the agents.export OPENAI_API_KEY=$YOUR_OPENAI_API_KEY```+Alternatively, you can create a `.env` file in the project root with your API keys (see `.env.example` for reference):+```bash+cp .env.example .env+# Edit .env with your actual API keys+```+### CLI UsageYou can also try out the CLI directly by running:diff --git a/main.py b/main.pyindex 8bf3d3c73..fe4e4cb33 100644--- a/main.py+++ b/main.py@@ -1,6 +1,11 @@from tradingagents.graph.trading_graph import TradingAgentsGraphfrom tradingagents.default_config import DEFAULT_CONFIG+from dotenv import load_dotenv++# Load environment variables from .env file+load_dotenv()+# Create a custom configconfig = DEFAULT_CONFIG.copy()config["llm_provider"] = "google" # Use a different model