Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
2 |
-
from tool import TextToImageTool
|
3 |
import datetime
|
4 |
import requests
|
5 |
import pytz
|
@@ -33,19 +32,6 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
33 |
return f"The current local time in {timezone} is: {local_time}"
|
34 |
except Exception as e:
|
35 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
36 |
-
def image_generation_tool(text: str) -> str:
|
37 |
-
"""A tool that fetches generates an image from a text
|
38 |
-
Args:
|
39 |
-
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
40 |
-
"""
|
41 |
-
try:
|
42 |
-
# Create timezone object
|
43 |
-
image_generation_tool_obj = image_generation_tool.
|
44 |
-
# Get current time in that timezone
|
45 |
-
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
46 |
-
return f"The current local time in {timezone} is: {local_time}"
|
47 |
-
except Exception as e:
|
48 |
-
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
49 |
|
50 |
final_answer = FinalAnswerTool()
|
51 |
|
@@ -68,7 +54,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
68 |
|
69 |
agent = CodeAgent(
|
70 |
model=model,
|
71 |
-
tools=[
|
72 |
max_steps=6,
|
73 |
verbosity_level=1,
|
74 |
grammar=None,
|
|
|
1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
|
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
|
|
32 |
return f"The current local time in {timezone} is: {local_time}"
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
final_answer = FinalAnswerTool()
|
37 |
|
|
|
54 |
|
55 |
agent = CodeAgent(
|
56 |
model=model,
|
57 |
+
tools=[final_answer, image_generation_tool], ## add your tools here (don't remove final answer)
|
58 |
max_steps=6,
|
59 |
verbosity_level=1,
|
60 |
grammar=None,
|