Update agent.py
Browse files
agent.py
CHANGED
|
@@ -33,6 +33,17 @@ class BraveSearchTool:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"BraveSearchTool ERROR: {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
class Agent:
|
| 37 |
def __init__(self):
|
| 38 |
gemini_key = os.getenv("GEMINI_API_KEY")
|
|
@@ -79,6 +90,9 @@ class Agent:
|
|
| 79 |
file_names = input_data.get("file_names", [])
|
| 80 |
task_id = input_data.get("task_id", "")
|
| 81 |
|
|
|
|
|
|
|
|
|
|
| 82 |
system_prompt = (
|
| 83 |
"You are a member of a multidisciplinary research institute, tackling complex and ambiguous problems across knowledge, reasoning, and vision.\n\n"
|
| 84 |
"You have access to tools like search engines, calculators, and data analysis environments. Your task is to solve the following question carefully and completely.\n\n"
|
|
@@ -126,7 +140,7 @@ class Agent:
|
|
| 126 |
else:
|
| 127 |
file_summary = "(Unsupported file type — skipping file content.)"
|
| 128 |
|
| 129 |
-
full_prompt = system_prompt + file_summary + f"\n\nTASK:\n{question}"
|
| 130 |
result = self.agent.run(full_prompt)
|
| 131 |
return result.strip()
|
| 132 |
except Exception as e:
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"BraveSearchTool ERROR: {str(e)}"
|
| 35 |
|
| 36 |
+
def classify_question_type(question: str) -> str:
|
| 37 |
+
q = question.lower()
|
| 38 |
+
if any(k in q for k in ["spreadsheet", "excel", "csv", "table", "data", "json", "file attached"]):
|
| 39 |
+
return "file"
|
| 40 |
+
elif any(k in q for k in ["calculate", "total", "sum", "difference", "convert", "how many", "what is the number"]):
|
| 41 |
+
return "math"
|
| 42 |
+
elif any(k in q for k in ["wikipedia", "who", "what", "where", "when", "name", "define", "explain"]):
|
| 43 |
+
return "knowledge"
|
| 44 |
+
else:
|
| 45 |
+
return "search"
|
| 46 |
+
|
| 47 |
class Agent:
|
| 48 |
def __init__(self):
|
| 49 |
gemini_key = os.getenv("GEMINI_API_KEY")
|
|
|
|
| 90 |
file_names = input_data.get("file_names", [])
|
| 91 |
task_id = input_data.get("task_id", "")
|
| 92 |
|
| 93 |
+
task_type = classify_question_type(question)
|
| 94 |
+
|
| 95 |
+
type_prefix = f"[Task Type: {task_type.upper()}]\n\n"
|
| 96 |
system_prompt = (
|
| 97 |
"You are a member of a multidisciplinary research institute, tackling complex and ambiguous problems across knowledge, reasoning, and vision.\n\n"
|
| 98 |
"You have access to tools like search engines, calculators, and data analysis environments. Your task is to solve the following question carefully and completely.\n\n"
|
|
|
|
| 140 |
else:
|
| 141 |
file_summary = "(Unsupported file type — skipping file content.)"
|
| 142 |
|
| 143 |
+
full_prompt = type_prefix + system_prompt + file_summary + f"\n\nTASK:\n{question}"
|
| 144 |
result = self.agent.run(full_prompt)
|
| 145 |
return result.strip()
|
| 146 |
except Exception as e:
|