Spaces:
Sleeping
Sleeping
Update tools.py
Browse files
tools.py
CHANGED
|
@@ -152,3 +152,14 @@ def web_search(query: str) -> str:
|
|
| 152 |
return tavily.search(query=query)['results'][0]['content']
|
| 153 |
except Exception as e:
|
| 154 |
return f"Error from Tavily: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
return tavily.search(query=query)['results'][0]['content']
|
| 153 |
except Exception as e:
|
| 154 |
return f"Error from Tavily: {e}"
|
| 155 |
+
|
| 156 |
+
# --- Execute Code ---
|
| 157 |
+
@tool
|
| 158 |
+
def execute_code(code: str) -> str:
|
| 159 |
+
""" Execute a code snippet and return the resulting local variable or ant error."""
|
| 160 |
+
exec_locals = {}
|
| 161 |
+
try:
|
| 162 |
+
exec(code, {}, exec_locals)
|
| 163 |
+
return str(exec_locals)
|
| 164 |
+
except Exception as e:
|
| 165 |
+
return str(e)
|