Spaces:
Sleeping
Sleeping
Draft before test
Browse files
app.py
CHANGED
|
@@ -25,17 +25,22 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 25 |
|
| 26 |
#Following my creation.
|
| 27 |
@tool
|
| 28 |
-
def
|
| 29 |
-
"""
|
|
|
|
|
|
|
| 30 |
Args:
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
"""
|
| 34 |
-
try:
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
except Exception as e:
|
| 38 |
-
return f"I
|
| 39 |
|
| 40 |
final_answer = FinalAnswerTool()
|
| 41 |
|
|
@@ -58,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 58 |
|
| 59 |
agent = CodeAgent(
|
| 60 |
model=model,
|
| 61 |
-
tools=[
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|
|
|
|
| 25 |
|
| 26 |
#Following my creation.
|
| 27 |
@tool
|
| 28 |
+
def get_fun_fact(topic: str) -> str:
|
| 29 |
+
"""
|
| 30 |
+
Finds a fun fact about a given topic using DuckDuckGo.
|
| 31 |
+
|
| 32 |
Args:
|
| 33 |
+
topic (str): The topic to search for a fun fact about.
|
| 34 |
+
|
| 35 |
+
Returns:
|
| 36 |
+
str: A fun fact related to the topic or an error message.
|
| 37 |
"""
|
| 38 |
+
try:
|
| 39 |
+
search_tool = DuckDuckGoSearchTool()
|
| 40 |
+
results = search_tool.run(f"fun fact about {topic}")
|
| 41 |
+
return f"Here's a fun fact about {topic}: {results[:300]}" # Limit to 300 characters
|
| 42 |
except Exception as e:
|
| 43 |
+
return f"Sorry, I couldn't find a fun fact. Error: {e}"
|
| 44 |
|
| 45 |
final_answer = FinalAnswerTool()
|
| 46 |
|
|
|
|
| 63 |
|
| 64 |
agent = CodeAgent(
|
| 65 |
model=model,
|
| 66 |
+
tools=[get_fun_fact, final_answer], ## add your tools here (don't remove final answer)
|
| 67 |
max_steps=6,
|
| 68 |
verbosity_level=1,
|
| 69 |
grammar=None,
|