Spaces:
Runtime error
Runtime error
Update app.py
Browse filesAdded None type check to get_web_search_results. Attempt at bug fix for query type.
app.py
CHANGED
|
@@ -19,7 +19,7 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
-
def get_web_search_results(query:str)-> str: #it's import to specify the return type
|
| 23 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 24 |
"""A tool that searchs the web using a query
|
| 25 |
Args:
|
|
@@ -27,7 +27,10 @@ def get_web_search_results(query:str)-> str: #it's import to specify the return
|
|
| 27 |
"""
|
| 28 |
try:
|
| 29 |
results = DuckDuckGoSearchTool.forward(query)
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
except Exception as e:
|
| 32 |
return f"{query} is an invalid query"
|
| 33 |
|
|
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
+
def get_web_search_results(query: str)-> str: #it's import to specify the return type
|
| 23 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 24 |
"""A tool that searchs the web using a query
|
| 25 |
Args:
|
|
|
|
| 27 |
"""
|
| 28 |
try:
|
| 29 |
results = DuckDuckGoSearchTool.forward(query)
|
| 30 |
+
if results not None:
|
| 31 |
+
return results
|
| 32 |
+
else:
|
| 33 |
+
return "Your query may be incorrectly formatted. Ensure it is of type str e.g. 'bananas'"
|
| 34 |
except Exception as e:
|
| 35 |
return f"{query} is an invalid query"
|
| 36 |
|