Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,30 +59,18 @@ def get_things_todo(city: str) -> str:
|
|
| 59 |
|
| 60 |
# Below is my attempt to use the structure provided
|
| 61 |
@tool
|
| 62 |
-
def my_ai_joke (arg1:str
|
| 63 |
-
|
| 64 |
-
|
|
|
|
| 65 |
Args:
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
"""
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
results = search_tool.forward(
|
| 72 |
-
f"Get a {joke} "
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
-
if results:
|
| 76 |
-
top_result = results[0] # Assuming results is a list
|
| 77 |
-
return top_result
|
| 78 |
-
else:
|
| 79 |
-
return "No results found."
|
| 80 |
-
except requests.exceptions.RequestException as e:
|
| 81 |
-
return f"Error: Failed to connect to the search. Details: {str(e)}"
|
| 82 |
-
except Exception as e:
|
| 83 |
-
return f"Error: An unexpected error occurred. Details: {str(e)}"#model.temperature = arg2
|
| 84 |
-
# joke = joke(arg1, model.temperature) #return a joke about arg1
|
| 85 |
-
|
| 86 |
return joke
|
| 87 |
|
| 88 |
final_answer = FinalAnswerTool()
|
|
|
|
| 59 |
|
| 60 |
# Below is my attempt to use the structure provided
|
| 61 |
@tool
|
| 62 |
+
def my_ai_joke (arg1:str)-> str: #it's import to specify the return type
|
| 63 |
+
"""
|
| 64 |
+
This is a tool that returns a joke
|
| 65 |
+
|
| 66 |
Args:
|
| 67 |
+
args1: what kind of joke
|
| 68 |
+
|
| 69 |
+
Returns:
|
| 70 |
+
str: returns a joke
|
| 71 |
"""
|
| 72 |
+
search_tool = DuckDuckGoSearchTool()
|
| 73 |
+
print(search_tool("Tell me a joke"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
return joke
|
| 75 |
|
| 76 |
final_answer = FinalAnswerTool()
|