From 3046f3dead560c1ead1cb201a061530819e93270 Mon Sep 17 00:00:00 2001 From: maxshhao <71746098+maxshhao@users.noreply.github.com> Date: Sat, 5 Jul 2025 01:16:36 +0800 Subject: [PATCH 1/2] feat: add env variables loading support and example --- .env.example | 3 +++ main.py | 3 +++ requirements.txt | 1 + 3 files changed, 7 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..153a7626 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +OPENAI_API_KEY=sk-123 +FINNHUB_API_KEY= +GOOGLE_API_KEY= \ No newline at end of file diff --git a/main.py b/main.py index 6c8ae3d9..15428c0c 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,8 @@ from tradingagents.graph.trading_graph import TradingAgentsGraph from tradingagents.default_config import DEFAULT_CONFIG +from dotenv import load_dotenv + +load_dotenv() # Create a custom config config = DEFAULT_CONFIG.copy() diff --git a/requirements.txt b/requirements.txt index a6154cd2..d8de9fe8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,3 +24,4 @@ rich questionary langchain_anthropic langchain-google-genai +python-dotenv From d71c51fd658445a4fcdf02313446e45f0388da56 Mon Sep 17 00:00:00 2001 From: maxshhao <71746098+maxshhao@users.noreply.github.com> Date: Sat, 5 Jul 2025 01:20:17 +0800 Subject: [PATCH 2/2] docs: update README to include instructions for using .env file --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index cac18691..65f0956d 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,11 @@ You will need the OpenAI API for all the agents. export OPENAI_API_KEY=$YOUR_OPENAI_API_KEY ``` +To help consolidate the variables in an .env file, you can copy the .env.example. The main.py script will pick up from there. +```bash +cp .env.example .env +``` + ### CLI Usage You can also try out the CLI directly by running: