🧹 fix: remove unused imports from agent_utils.py
Removed re-exported tool imports from `tradingagents/agents/utils/agent_utils.py` to declutter the file and prevent unnecessary dependency loading. Updated all downstream modules (tests, analysts, scanners, and the trading graph) to import the required tools directly from their respective source files in `tradingagents/agents/utils/`. Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
This commit is contained in:
parent
5799bb3f00
commit
3bed14e5c1
|
|
@ -24,26 +24,26 @@ class TestAgentStateFields:
|
|||
|
||||
class TestNewToolsExported:
|
||||
def test_get_ttm_analysis_exported(self):
|
||||
from tradingagents.agents.utils.agent_utils import get_ttm_analysis
|
||||
from tradingagents.agents.utils.fundamental_data_tools import get_ttm_analysis
|
||||
# @tool returns a LangChain StructuredTool — callable() is False on it.
|
||||
# hasattr(..., "invoke") is the correct check for LangChain tools.
|
||||
assert hasattr(get_ttm_analysis, "invoke")
|
||||
|
||||
def test_get_peer_comparison_exported(self):
|
||||
from tradingagents.agents.utils.agent_utils import get_peer_comparison
|
||||
from tradingagents.agents.utils.fundamental_data_tools import get_peer_comparison
|
||||
assert hasattr(get_peer_comparison, "invoke")
|
||||
|
||||
def test_get_sector_relative_exported(self):
|
||||
from tradingagents.agents.utils.agent_utils import get_sector_relative
|
||||
from tradingagents.agents.utils.fundamental_data_tools import get_sector_relative
|
||||
assert hasattr(get_sector_relative, "invoke")
|
||||
|
||||
def test_get_macro_regime_exported(self):
|
||||
from tradingagents.agents.utils.agent_utils import get_macro_regime
|
||||
from tradingagents.agents.utils.fundamental_data_tools import get_macro_regime
|
||||
assert hasattr(get_macro_regime, "invoke")
|
||||
|
||||
def test_tools_are_langchain_tools(self):
|
||||
"""All new tools should be LangChain @tool decorated (have .name attribute)."""
|
||||
from tradingagents.agents.utils.agent_utils import (
|
||||
from tradingagents.agents.utils.fundamental_data_tools import (
|
||||
get_ttm_analysis, get_peer_comparison, get_sector_relative, get_macro_regime
|
||||
)
|
||||
for tool in [get_ttm_analysis, get_peer_comparison, get_sector_relative, get_macro_regime]:
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
import time
|
||||
import json
|
||||
from tradingagents.agents.utils.agent_utils import (
|
||||
from tradingagents.agents.utils.fundamental_data_tools import (
|
||||
get_fundamentals,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_income_statement,
|
||||
get_insider_transactions,
|
||||
get_ttm_analysis,
|
||||
get_peer_comparison,
|
||||
get_sector_relative,
|
||||
)
|
||||
from tradingagents.agents.utils.news_data_tools import get_insider_transactions
|
||||
from tradingagents.dataflows.config import get_config
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
import time
|
||||
import json
|
||||
from tradingagents.agents.utils.agent_utils import get_stock_data, get_indicators, get_macro_regime
|
||||
from tradingagents.agents.utils.core_stock_tools import get_stock_data
|
||||
from tradingagents.agents.utils.technical_indicators_tools import get_indicators
|
||||
from tradingagents.agents.utils.fundamental_data_tools import get_macro_regime
|
||||
from tradingagents.dataflows.config import get_config
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
import time
|
||||
import json
|
||||
from tradingagents.agents.utils.agent_utils import get_news, get_global_news
|
||||
from tradingagents.agents.utils.news_data_tools import get_news, get_global_news
|
||||
from tradingagents.dataflows.config import get_config
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
import time
|
||||
import json
|
||||
from tradingagents.agents.utils.agent_utils import get_news
|
||||
from tradingagents.agents.utils.news_data_tools import get_news
|
||||
from tradingagents.dataflows.config import get_config
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from tradingagents.agents.utils.agent_utils import get_topic_news
|
||||
from tradingagents.agents.utils.scanner_tools import get_topic_news
|
||||
from tradingagents.agents.utils.tool_runner import run_tool_loop
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from tradingagents.agents.utils.agent_utils import get_industry_performance, get_topic_news
|
||||
from tradingagents.agents.utils.scanner_tools import get_industry_performance, get_topic_news
|
||||
from tradingagents.agents.utils.tool_runner import run_tool_loop
|
||||
|
||||
# All valid sector keys accepted by yfinance Sector() and get_industry_performance.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from tradingagents.agents.utils.agent_utils import get_market_movers, get_market_indices
|
||||
from tradingagents.agents.utils.scanner_tools import get_market_movers, get_market_indices
|
||||
from tradingagents.agents.utils.tool_runner import run_tool_loop
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from tradingagents.agents.utils.agent_utils import get_sector_performance
|
||||
from tradingagents.agents.utils.scanner_tools import get_sector_performance
|
||||
from tradingagents.agents.utils.tool_runner import run_tool_loop
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +1,5 @@
|
|||
from langchain_core.messages import HumanMessage, RemoveMessage
|
||||
|
||||
# Import tools from separate utility files
|
||||
from tradingagents.agents.utils.core_stock_tools import (
|
||||
get_stock_data
|
||||
)
|
||||
from tradingagents.agents.utils.technical_indicators_tools import (
|
||||
get_indicators
|
||||
)
|
||||
from tradingagents.agents.utils.fundamental_data_tools import (
|
||||
get_fundamentals,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_income_statement,
|
||||
get_ttm_analysis,
|
||||
get_peer_comparison,
|
||||
get_sector_relative,
|
||||
get_macro_regime,
|
||||
)
|
||||
from tradingagents.agents.utils.news_data_tools import (
|
||||
get_news,
|
||||
get_insider_transactions,
|
||||
get_global_news
|
||||
)
|
||||
from tradingagents.agents.utils.scanner_tools import (
|
||||
get_market_movers,
|
||||
get_market_indices,
|
||||
get_sector_performance,
|
||||
get_industry_performance,
|
||||
get_topic_news
|
||||
)
|
||||
|
||||
|
||||
def create_msg_delete():
|
||||
def delete_messages(state):
|
||||
|
|
|
|||
|
|
@ -20,22 +20,24 @@ from tradingagents.agents.utils.agent_states import (
|
|||
)
|
||||
from tradingagents.dataflows.config import set_config
|
||||
|
||||
# Import the new abstract tool methods from agent_utils
|
||||
from tradingagents.agents.utils.agent_utils import (
|
||||
get_stock_data,
|
||||
get_indicators,
|
||||
# Import the new abstract tool methods
|
||||
from tradingagents.agents.utils.core_stock_tools import get_stock_data
|
||||
from tradingagents.agents.utils.technical_indicators_tools import get_indicators
|
||||
from tradingagents.agents.utils.fundamental_data_tools import (
|
||||
get_fundamentals,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_income_statement,
|
||||
get_news,
|
||||
get_insider_transactions,
|
||||
get_global_news,
|
||||
get_ttm_analysis,
|
||||
get_peer_comparison,
|
||||
get_sector_relative,
|
||||
get_macro_regime,
|
||||
)
|
||||
from tradingagents.agents.utils.news_data_tools import (
|
||||
get_news,
|
||||
get_insider_transactions,
|
||||
get_global_news,
|
||||
)
|
||||
|
||||
from .conditional_logic import ConditionalLogic
|
||||
from .setup import GraphSetup
|
||||
|
|
|
|||
Loading…
Reference in New Issue