Yongkang ZOU
commited on
Commit
·
dfe572b
1
Parent(s):
66215da
update agent
Browse files
agent.py
CHANGED
|
@@ -66,8 +66,24 @@ def arvix_search(query: str) -> str:
|
|
| 66 |
docs = ArxivLoader(query=query, load_max_docs=3).load()
|
| 67 |
return "\n\n".join([doc.page_content[:1000] for doc in docs])
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
# ------------------- SYSTEM PROMPT -------------------
|
| 73 |
system_prompt_path = "system_prompt.txt"
|
|
|
|
| 66 |
docs = ArxivLoader(query=query, load_max_docs=3).load()
|
| 67 |
return "\n\n".join([doc.page_content[:1000] for doc in docs])
|
| 68 |
|
| 69 |
+
@tool
|
| 70 |
+
def read_excel_file(path: str) -> str:
|
| 71 |
+
"""Read an Excel file and return the first few rows of each sheet as text."""
|
| 72 |
+
import pandas as pd
|
| 73 |
+
try:
|
| 74 |
+
xls = pd.ExcelFile(path)
|
| 75 |
+
content = ""
|
| 76 |
+
for sheet in xls.sheet_names:
|
| 77 |
+
df = xls.parse(sheet)
|
| 78 |
+
content += f"Sheet: {sheet}\n"
|
| 79 |
+
content += df.head(5).to_string(index=False) + "\n\n"
|
| 80 |
+
return content.strip()
|
| 81 |
+
except Exception as e:
|
| 82 |
+
return f"Error reading Excel file: {str(e)}"
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
tools = [multiply, add, subtract, divide, modulus, wiki_search, web_search, arvix_search, read_excel_file]
|
| 87 |
|
| 88 |
# ------------------- SYSTEM PROMPT -------------------
|
| 89 |
system_prompt_path = "system_prompt.txt"
|