mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-06-16 21:06:15 +03:00
Adds a single _ENV_OVERRIDES table in default_config.py with type-aware coercion (str/int/bool), so users can switch llm_provider, deep/quick models, backend URL, output language, debate rounds, and the checkpoint flag purely via .env. Centralizes load_dotenv in the package __init__ so the overlay applies for every entry point (CLI, main.py, programmatic). Drops the hardcoded model assignments and duplicate dotenv loads in main.py and cli/main.py. Verified live with OpenAI and Gemini. #602
39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
import warnings
|
|
|
|
# Load .env files at package import so DEFAULT_CONFIG's env-var overlay
|
|
# (and every llm_clients consumer) sees the user's keys regardless of
|
|
# which entry point started the process. find_dotenv(usecwd=True) walks
|
|
# from the CWD, so the installed `tradingagents` console script picks up
|
|
# the project's .env instead of stepping up from site-packages.
|
|
# load_dotenv defaults to override=False, so it never clobbers values
|
|
# the caller has already exported.
|
|
try:
|
|
from dotenv import find_dotenv, load_dotenv
|
|
|
|
load_dotenv(find_dotenv(usecwd=True))
|
|
load_dotenv(find_dotenv(".env.enterprise", usecwd=True), override=False)
|
|
except ImportError:
|
|
pass
|
|
|
|
# langchain-core 1.3.3 calls surface_langchain_deprecation_warnings() in
|
|
# its own __init__, which prepends default-action filters for its
|
|
# subclassed warning categories. To suppress a specific warning we must
|
|
# install our filter AFTER langchain-core has installed its own, so import
|
|
# it first. The package is a guaranteed transitive dep via langgraph.
|
|
try:
|
|
import langchain_core # noqa: F401
|
|
except ImportError:
|
|
pass
|
|
|
|
# langgraph-checkpoint 4.0.3 calls Reviver() at module load without an
|
|
# explicit allowed_objects, which triggers a noisy pending-deprecation
|
|
# warning from langchain-core 1.3.3 on every interpreter start. The fix
|
|
# is already merged upstream (langchain-ai/langgraph#7743, 2026-05-08)
|
|
# and will arrive in the next langgraph-checkpoint release. Remove this
|
|
# block (and the langchain_core preload above) when we bump past it.
|
|
warnings.filterwarnings(
|
|
"ignore",
|
|
message=r"The default value of `allowed_objects`.*",
|
|
category=PendingDeprecationWarning,
|
|
)
|