bug fix on multi-language support

This commit is contained in:
Jeffrey Chu 2025-10-22 20:30:23 +08:00
parent 07d2c49235
commit eee9e01af7
4 changed files with 12 additions and 8 deletions

View File

@ -31,7 +31,6 @@ def create_fundamentals_analyst(llm, config):
"You are a researcher tasked with analyzing fundamental information over the past week about a company. Please write a comprehensive report of the company's fundamental information such as financial documents, company profile, basic company financials, and company financial history to gain a full view of the company's fundamental information to inform traders. Make sure to include as much detail as possible. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."
+ " Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."
+ " Use the available tools: `get_fundamentals` for comprehensive company analysis, `get_balance_sheet`, `get_cashflow`, and `get_income_statement` for specific financial statements."
+ "\n***{language_prompt}***"
)
prompt = ChatPromptTemplate.from_messages(
@ -45,7 +44,8 @@ def create_fundamentals_analyst(llm, config):
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
" You have access to the following tools: {tool_names}.\n{system_message}"
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}",
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}"
"\n***{language_prompt}***",
),
MessagesPlaceholder(variable_name="messages"),
]
@ -55,6 +55,7 @@ def create_fundamentals_analyst(llm, config):
prompt = prompt.partial(tool_names=", ".join([tool.name for tool in tools]))
prompt = prompt.partial(current_date=current_date)
prompt = prompt.partial(ticker=ticker)
prompt = prompt.partial(language_prompt=language_prompt)
chain = prompt | llm.bind_tools(tools)

View File

@ -53,7 +53,6 @@ Volume-Based Indicators:
- Select indicators that provide diverse and complementary information. Avoid redundancy (e.g., do not select both rsi and stochrsi). Also briefly explain why they are suitable for the given market context. When you tool call, please use the exact name of the indicators provided above as they are defined parameters, otherwise your call will fail. Please make sure to call get_stock_data first to retrieve the CSV that is needed to generate indicators. Then use get_indicators with the specific indicator names. Write a very detailed and nuanced report of the trends you observe. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."""
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
+ "\n***{language_prompt}***"
)
prompt = ChatPromptTemplate.from_messages(
@ -67,7 +66,8 @@ Volume-Based Indicators:
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
" You have access to the following tools: {tool_names}.\n{system_message}"
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}",
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}"
"\n***{language_prompt}***",
),
MessagesPlaceholder(variable_name="messages"),
]
@ -77,6 +77,7 @@ Volume-Based Indicators:
prompt = prompt.partial(tool_names=", ".join([tool.name for tool in tools]))
prompt = prompt.partial(current_date=current_date)
prompt = prompt.partial(ticker=ticker)
prompt = prompt.partial(language_prompt=language_prompt)
chain = prompt | llm.bind_tools(tools)

View File

@ -28,7 +28,6 @@ def create_news_analyst(llm, config):
system_message = (
"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(query, start_date, end_date) for company-specific or targeted news searches, and get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
+ "\n***{language_prompt}***"
)
prompt = ChatPromptTemplate.from_messages(
@ -42,7 +41,8 @@ def create_news_analyst(llm, config):
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
" You have access to the following tools: {tool_names}.\n{system_message}"
"For your reference, the current date is {current_date}. We are looking at the company {ticker}",
"For your reference, the current date is {current_date}. We are looking at the company {ticker}"
"\n***{language_prompt}***",
),
MessagesPlaceholder(variable_name="messages"),
]
@ -52,6 +52,7 @@ def create_news_analyst(llm, config):
prompt = prompt.partial(tool_names=", ".join([tool.name for tool in tools]))
prompt = prompt.partial(current_date=current_date)
prompt = prompt.partial(ticker=ticker)
prompt = prompt.partial(language_prompt=language_prompt)
chain = prompt | llm.bind_tools(tools)
result = chain.invoke(state["messages"])

View File

@ -28,7 +28,6 @@ def create_social_media_analyst(llm, config):
system_message = (
"You are a social media and company specific news researcher/analyst tasked with analyzing social media posts, recent company news, and public sentiment for a specific company over the past week. You will be given a company's name your objective is to write a comprehensive long report detailing your analysis, insights, and implications for traders and investors on this company's current state after looking at social media and what people are saying about that company, analyzing sentiment data of what people feel each day about the company, and looking at recent company news. Use the get_news(query, start_date, end_date) tool to search for company-specific news and social media discussions. Try to look at all sources possible from social media to sentiment to news. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
+ "\n***{language_prompt}***"
)
prompt = ChatPromptTemplate.from_messages(
@ -42,7 +41,8 @@ def create_social_media_analyst(llm, config):
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
" You have access to the following tools: {tool_names}.\n{system_message}"
"For your reference, the current date is {current_date}. The current company we want to analyze is {ticker}",
"For your reference, the current date is {current_date}. The current company we want to analyze is {ticker}"
"\n***{language_prompt}***",
),
MessagesPlaceholder(variable_name="messages"),
]
@ -52,6 +52,7 @@ def create_social_media_analyst(llm, config):
prompt = prompt.partial(tool_names=", ".join([tool.name for tool in tools]))
prompt = prompt.partial(current_date=current_date)
prompt = prompt.partial(ticker=ticker)
prompt = prompt.partial(language_prompt=language_prompt)
chain = prompt | llm.bind_tools(tools)