From dde16329398b06a1f661c3eaad52b0ef31f58e68 Mon Sep 17 00:00:00 2001 From: Surapong Kanoktipsatharporn Date: Mon, 20 Oct 2025 15:32:01 +0700 Subject: [PATCH] fix: Move component initialization back to __init__, keep only config in _configure_embeddings The _configure_embeddings method was incorrectly trying to initialize graph components (conditional_logic, graph_setup, etc.) which caused an AttributeError because tool_nodes hadn't been created yet. This fix: - Moves component initialization back to __init__ method - Keeps only embedding configuration logic in _configure_embeddings - Maintains correct initialization order --- tradingagents/graph/trading_graph.py | 52 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tradingagents/graph/trading_graph.py b/tradingagents/graph/trading_graph.py index cba3db80..7a86a05c 100644 --- a/tradingagents/graph/trading_graph.py +++ b/tradingagents/graph/trading_graph.py @@ -128,6 +128,32 @@ class TradingAgentsGraph: # Create tool nodes self.tool_nodes = self._create_tool_nodes() + # Initialize components + self.conditional_logic = ConditionalLogic() + self.graph_setup = GraphSetup( + self.quick_thinking_llm, + self.deep_thinking_llm, + self.tool_nodes, + self.bull_memory, + self.bear_memory, + self.trader_memory, + self.invest_judge_memory, + self.risk_manager_memory, + self.conditional_logic, + ) + + self.propagator = Propagator() + self.reflector = Reflector(self.quick_thinking_llm) + self.signal_processor = SignalProcessor(self.quick_thinking_llm) + + # State tracking + self.curr_state = None + self.ticker = None + self.log_states_dict = {} # date to full state dict + + # Set up the graph + self.graph = self.graph_setup.setup_graph(selected_analysts) + def _configure_embeddings(self): """Configure embedding settings, providing smart defaults based on chat LLM provider.""" # If embedding settings are not explicitly configured, set intelligent defaults @@ -163,32 +189,6 @@ class TradingAgentsGraph: # Enable memory by default self.config["enable_memory"] = True - # Initialize components - self.conditional_logic = ConditionalLogic() - self.graph_setup = GraphSetup( - self.quick_thinking_llm, - self.deep_thinking_llm, - self.tool_nodes, - self.bull_memory, - self.bear_memory, - self.trader_memory, - self.invest_judge_memory, - self.risk_manager_memory, - self.conditional_logic, - ) - - self.propagator = Propagator() - self.reflector = Reflector(self.quick_thinking_llm) - self.signal_processor = SignalProcessor(self.quick_thinking_llm) - - # State tracking - self.curr_state = None - self.ticker = None - self.log_states_dict = {} # date to full state dict - - # Set up the graph - self.graph = self.graph_setup.setup_graph(selected_analysts) - def _create_tool_nodes(self) -> Dict[str, ToolNode]: """Create tool nodes for different data sources using abstract methods.""" return {