Scott Cogan
commited on
Commit
·
0776514
1
Parent(s):
1ce7056
tool call improvements
Browse files
app.py
CHANGED
|
@@ -40,7 +40,12 @@ def execute_tool(tool_name: str, tool_args: Dict[str, Any], tools: Dict[str, Cal
|
|
| 40 |
"""Execute a tool with the given arguments."""
|
| 41 |
if tool_name not in tools:
|
| 42 |
raise ValueError(f"Tool {tool_name} not found")
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# Convert existing functions to tools
|
| 46 |
@tool
|
|
@@ -105,7 +110,6 @@ def open_youtube_video(url: str, query: str) -> str:
|
|
| 105 |
)
|
| 106 |
return response.text
|
| 107 |
|
| 108 |
-
@tool
|
| 109 |
def google_search(query: str) -> str:
|
| 110 |
'''Performs a web search for the given query using DuckDuckGo.'''
|
| 111 |
try:
|
|
|
|
| 40 |
"""Execute a tool with the given arguments."""
|
| 41 |
if tool_name not in tools:
|
| 42 |
raise ValueError(f"Tool {tool_name} not found")
|
| 43 |
+
tool_func = tools[tool_name]
|
| 44 |
+
# If the tool is decorated with @tool, use the run method
|
| 45 |
+
if hasattr(tool_func, 'run'):
|
| 46 |
+
return tool_func.run(**tool_args)
|
| 47 |
+
# Otherwise, call the function directly
|
| 48 |
+
return tool_func(**tool_args)
|
| 49 |
|
| 50 |
# Convert existing functions to tools
|
| 51 |
@tool
|
|
|
|
| 110 |
)
|
| 111 |
return response.text
|
| 112 |
|
|
|
|
| 113 |
def google_search(query: str) -> str:
|
| 114 |
'''Performs a web search for the given query using DuckDuckGo.'''
|
| 115 |
try:
|