fix: correct risk manager data bug, incomplete state init, and LLM type hints
- Fix copy-paste bug in risk_manager.py where fundamentals_report was reading from news_report instead of fundamentals_report, causing the risk manager to ignore fundamentals data in its final decision - Initialize all TypedDict fields for InvestDebateState and RiskDebateState in propagation.py to prevent KeyError in _log_state - Update setup.py type hints from ChatOpenAI to ChatModel union type to correctly reflect multi-provider LLM support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e9470b69c4
commit
747724048f
|
|
@ -11,7 +11,7 @@ def create_risk_manager(llm, memory):
|
|||
risk_debate_state = state["risk_debate_state"]
|
||||
market_research_report = state["market_report"]
|
||||
news_report = state["news_report"]
|
||||
fundamentals_report = state["news_report"]
|
||||
fundamentals_report = state["fundamentals_report"]
|
||||
sentiment_report = state["sentiment_report"]
|
||||
trader_plan = state["investment_plan"]
|
||||
|
||||
|
|
|
|||
|
|
@ -24,14 +24,26 @@ class Propagator:
|
|||
"company_of_interest": company_name,
|
||||
"trade_date": str(trade_date),
|
||||
"investment_debate_state": InvestDebateState(
|
||||
{"history": "", "current_response": "", "count": 0}
|
||||
{
|
||||
"bull_history": "",
|
||||
"bear_history": "",
|
||||
"history": "",
|
||||
"current_response": "",
|
||||
"judge_decision": "",
|
||||
"count": 0,
|
||||
}
|
||||
),
|
||||
"risk_debate_state": RiskDebateState(
|
||||
{
|
||||
"aggressive_history": "",
|
||||
"conservative_history": "",
|
||||
"neutral_history": "",
|
||||
"history": "",
|
||||
"latest_speaker": "",
|
||||
"current_aggressive_response": "",
|
||||
"current_conservative_response": "",
|
||||
"current_neutral_response": "",
|
||||
"judge_decision": "",
|
||||
"count": 0,
|
||||
}
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
# TradingAgents/graph/setup.py
|
||||
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Dict, Union
|
||||
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_google_genai import ChatGoogleGenerativeAI
|
||||
from langgraph.graph import END, StateGraph, START
|
||||
from langgraph.prebuilt import ToolNode
|
||||
|
||||
|
|
@ -10,14 +13,17 @@ from tradingagents.agents.utils.agent_states import AgentState
|
|||
|
||||
from .conditional_logic import ConditionalLogic
|
||||
|
||||
# Union of supported LLM chat model types
|
||||
ChatModel = Union[ChatOpenAI, ChatAnthropic, ChatGoogleGenerativeAI]
|
||||
|
||||
|
||||
class GraphSetup:
|
||||
"""Handles the setup and configuration of the agent graph."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
quick_thinking_llm: ChatOpenAI,
|
||||
deep_thinking_llm: ChatOpenAI,
|
||||
quick_thinking_llm: ChatModel,
|
||||
deep_thinking_llm: ChatModel,
|
||||
tool_nodes: Dict[str, ToolNode],
|
||||
bull_memory,
|
||||
bear_memory,
|
||||
|
|
|
|||
Loading…
Reference in New Issue