From 08f9cd552d9379ab4c14815bfa174d4df14fb1b0 Mon Sep 17 00:00:00 2001 From: Jeffrey Chu Date: Wed, 22 Oct 2025 19:11:18 +0800 Subject: [PATCH] bug fix for xai support --- .gitignore | 1 + tradingagents/graph/trading_graph.py | 41 ---------------------------- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index 3369bad9..b33ddf4e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ eval_results/ eval_data/ *.egg-info/ .env +.history \ No newline at end of file diff --git a/tradingagents/graph/trading_graph.py b/tradingagents/graph/trading_graph.py index e472b143..3de9ee89 100644 --- a/tradingagents/graph/trading_graph.py +++ b/tradingagents/graph/trading_graph.py @@ -62,47 +62,6 @@ class TradingAgentsGraph: """ self.debug = debug self.config = config or DEFAULT_CONFIG - - # get the language - self.output_language = self.config.get("output_language", "en") - self.language_instruction = self.config.get("language_system_prompts", {}).get( - self.output_language, "" - ) - - self._setup_agents() - self._setup_graph() - - def _setup_agents(self): - """初始化所有 agents,並注入語言指示""" - # 為每個 agent 加入語言指示 - if self.language_instruction: - self._inject_language_to_agents() - - def _inject_language_to_agents(self): - """將語言指示注入所有 agents""" - # 這個方法會在每個 agent 的 system message 前加入語言指示 - self.language_system_message = SystemMessage(content=self.language_instruction) - - def _create_agent_with_language(self, agent_name, agent_prompt, llm): - """創建帶有語言指示的 agent""" - from langchain.agents import AgentExecutor, create_openai_functions_agent - from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder - - # 構建包含語言指示的 prompt - if self.language_instruction: - system_prompt = f"{agent_prompt}{self.language_instruction}" - else: - system_prompt = agent_prompt - - prompt = ChatPromptTemplate.from_messages([ - ("system", system_prompt), - MessagesPlaceholder(variable_name="chat_history", optional=True), - ("human", "{input}"), - MessagesPlaceholder(variable_name="agent_scratchpad"), - ]) - - agent = create_openai_functions_agent(llm, tools=[], prompt=prompt) - return AgentExecutor(agent=agent, tools=[], verbose=self.debug) # Update the interface's config set_config(self.config)