Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent, HfApiModel,
|
| 2 |
import requests
|
| 3 |
import base64
|
| 4 |
import datetime
|
|
@@ -16,7 +16,10 @@ def generate_image(prompt: str) -> str:
|
|
| 16 |
Generate an image from a text prompt.
|
| 17 |
|
| 18 |
Args:
|
| 19 |
-
prompt: description of the image to generate
|
|
|
|
|
|
|
|
|
|
| 20 |
"""
|
| 21 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2"
|
| 22 |
|
|
@@ -44,7 +47,15 @@ def generate_image(prompt: str) -> str:
|
|
| 44 |
# -------------------------
|
| 45 |
@tool
|
| 46 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 47 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
try:
|
| 49 |
tz = pytz.timezone(timezone)
|
| 50 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
|
@@ -82,7 +93,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 82 |
# -------------------------
|
| 83 |
agent = CodeAgent(
|
| 84 |
model=model,
|
| 85 |
-
tools=[final_answer, get_current_time_in_timezone, generate_image],
|
| 86 |
max_steps=6,
|
| 87 |
verbosity_level=1,
|
| 88 |
name="FirstAgent",
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, HfApiModel, tool
|
| 2 |
import requests
|
| 3 |
import base64
|
| 4 |
import datetime
|
|
|
|
| 16 |
Generate an image from a text prompt.
|
| 17 |
|
| 18 |
Args:
|
| 19 |
+
prompt: A description of the image to generate.
|
| 20 |
+
|
| 21 |
+
Returns:
|
| 22 |
+
A base64-encoded string of the generated image.
|
| 23 |
"""
|
| 24 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2"
|
| 25 |
|
|
|
|
| 47 |
# -------------------------
|
| 48 |
@tool
|
| 49 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 50 |
+
"""
|
| 51 |
+
Fetches the current local time in a specified timezone.
|
| 52 |
+
|
| 53 |
+
Args:
|
| 54 |
+
timezone: A string representing a valid timezone, e.g., 'America/New_York'
|
| 55 |
+
|
| 56 |
+
Returns:
|
| 57 |
+
A string with the current time in the specified timezone.
|
| 58 |
+
"""
|
| 59 |
try:
|
| 60 |
tz = pytz.timezone(timezone)
|
| 61 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
| 93 |
# -------------------------
|
| 94 |
agent = CodeAgent(
|
| 95 |
model=model,
|
| 96 |
+
tools=[final_answer, get_current_time_in_timezone, generate_image], # keep final_answer first
|
| 97 |
max_steps=6,
|
| 98 |
verbosity_level=1,
|
| 99 |
name="FirstAgent",
|