Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
@@ -25,6 +25,9 @@ def gemini_generate(prompt: str) -> str:
|
|
25 |
|
26 |
@tool
|
27 |
def calculator(expr: str) -> str:
|
|
|
|
|
|
|
28 |
try:
|
29 |
return str(eval(expr, {"__builtins__": {}}))
|
30 |
except Exception as e:
|
@@ -32,6 +35,9 @@ def calculator(expr: str) -> str:
|
|
32 |
|
33 |
@tool
|
34 |
def wiki_search(query: str) -> str:
|
|
|
|
|
|
|
35 |
docs = WikipediaLoader(query=query, load_max_docs=2).load()
|
36 |
return "\n\n".join(d.page_content for d in docs)
|
37 |
|
|
|
25 |
|
26 |
@tool
|
27 |
def calculator(expr: str) -> str:
|
28 |
+
"""
|
29 |
+
Safely evaluates a math expression and returns the result.
|
30 |
+
"""
|
31 |
try:
|
32 |
return str(eval(expr, {"__builtins__": {}}))
|
33 |
except Exception as e:
|
|
|
35 |
|
36 |
@tool
|
37 |
def wiki_search(query: str) -> str:
|
38 |
+
"""
|
39 |
+
Fetches up to 2 Wikipedia pages for the query and concatenates their text.
|
40 |
+
"""
|
41 |
docs = WikipediaLoader(query=query, load_max_docs=2).load()
|
42 |
return "\n\n".join(d.page_content for d in docs)
|
43 |
|