ChienChung commited on
Commit
dbb3393
·
verified ·
1 Parent(s): 9824fcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -503,7 +503,7 @@ router_task = Task(
503
  Based on the user's query, decide which agent or tool is best suited to handle it:
504
  - If the query is related to the content of an uploaded file (e.g., 'what is this document about?'), send it to the **Document QA Agent**.
505
  - If the query contains words like 'summarize', 'summary', or 'main points', use the **Summarizer Agent**.
506
- - If the query involves any kind of math, calculation, percentage, angle, log, sqrt, cos, sin, arithmetic expressions, or includes phrases like "how much", "calculate", "what is X + Y", "x^2 + y^2", send it to the **Math Agent**.
507
  - If the user uploaded a CSV file and asks about table content, data trends, or uses words like 'data', 'table', 'csv', 'column', or 'row', send it to the **CSV Agent**.
508
  - If the user asks about current events, trending topics, or online information (e.g., 'What is LangChain?', 'latest news'), send it to the **Search Agent**.
509
  - If the query is about current date, time, or day of week (e.g., 'what is today\\'s date?', 'what time is it?', 'what day is it?'), send it to the **Search Agent** instead of the General Agent.
@@ -549,7 +549,8 @@ def multi_agent_chat_advanced(query: str, file=None) -> str:
549
  lower_query = query.lower()
550
 
551
 
552
- if re.match(r"^[a-zA-Z\d\s\+\-\*\/\%\(\)\.]+$", lower_query):
 
553
  return _calc_tool(query)
554
 
555
  date_keywords = ["what date", "today", "what time", "what day", "現在幾點", "今天幾號", "禮拜幾"]
 
503
  Based on the user's query, decide which agent or tool is best suited to handle it:
504
  - If the query is related to the content of an uploaded file (e.g., 'what is this document about?'), send it to the **Document QA Agent**.
505
  - If the query contains words like 'summarize', 'summary', or 'main points', use the **Summarizer Agent**.
506
+ - If the query **includes any numbers or symbols** (like +, -, *, /, %, ^), or **mentions math terms** (like 'calculate', 'how much', 'percent', 'square root', 'log', 'cos', 'sin', etc.), or starts with 'what is', 'what’s', 'how much is', assume it is a **math question** and send it to the **Math Agent**.
507
  - If the user uploaded a CSV file and asks about table content, data trends, or uses words like 'data', 'table', 'csv', 'column', or 'row', send it to the **CSV Agent**.
508
  - If the user asks about current events, trending topics, or online information (e.g., 'What is LangChain?', 'latest news'), send it to the **Search Agent**.
509
  - If the query is about current date, time, or day of week (e.g., 'what is today\\'s date?', 'what time is it?', 'what day is it?'), send it to the **Search Agent** instead of the General Agent.
 
549
  lower_query = query.lower()
550
 
551
 
552
+ math_keywords = ["how much", "calculate", "what is", "what’s", "%", "sin", "cos", "log", "sqrt", "^", "*", "/", "+", "-", "="]
553
+ if any(k in lower_query for k in math_keywords):
554
  return _calc_tool(query)
555
 
556
  date_keywords = ["what date", "today", "what time", "what day", "現在幾點", "今天幾號", "禮拜幾"]