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
This commit is contained in:
Surapong Kanoktipsatharporn 2025-10-20 15:32:01 +07:00
parent 2869ab3c5f
commit dde1632939
1 changed files with 26 additions and 26 deletions

View File

@ -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 {