feat(config): TRADINGAGENTS_* env-var overlay for DEFAULT_CONFIG

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
This commit is contained in:
Yijia-Xiao
2026-05-11 06:12:31 +00:00
parent 6b384f74f9
commit d13e9b7946
6 changed files with 176 additions and 25 deletions

View File

@@ -5,13 +5,6 @@ import questionary
from pathlib import Path
from functools import wraps
from rich.console import Console
from dotenv import find_dotenv, load_dotenv
# Search starts from the user's CWD so the installed `tradingagents`
# console script picks up the project's .env instead of walking up from
# site-packages.
load_dotenv(find_dotenv(usecwd=True))
load_dotenv(find_dotenv(".env.enterprise", usecwd=True), override=False)
from rich.panel import Panel
from rich.spinner import Spinner
from rich.live import Live
@@ -569,6 +562,11 @@ def get_user_selections():
elif selected_llm_provider == "glm":
selected_llm_provider, backend_url = ask_glm_region()
# Confirm the provider's API key is present; prompt the user to paste
# one and persist it to .env if it's missing, so the analysis run
# doesn't fail later at the first API call.
ensure_api_key(selected_llm_provider)
# Step 7: Thinking agents
console.print(
create_question_box(