Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,19 +36,25 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 36 |
except Exception as e:
|
| 37 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
@tool
|
| 40 |
-
def
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
"""
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
quote_data = response.json()
|
| 48 |
-
return random.choice(quote_data).get('q')
|
| 49 |
-
else:
|
| 50 |
-
return "Failed to fetch a quote"
|
| 51 |
|
|
|
|
|
|
|
| 52 |
final_answer = FinalAnswerTool()
|
| 53 |
|
| 54 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
@@ -70,7 +76,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 70 |
|
| 71 |
agent = CodeAgent(
|
| 72 |
model=model,
|
| 73 |
-
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, wiki_of_person], ## add your tools here (don't remove final answer)
|
| 74 |
max_steps=6,
|
| 75 |
verbosity_level=1,
|
| 76 |
grammar=None,
|
|
|
|
| 36 |
except Exception as e:
|
| 37 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 38 |
|
| 39 |
+
image_generation_tool = Tool.from_space(
|
| 40 |
+
"black-forest-labs/FLUX.1-schnell",
|
| 41 |
+
name="image_generator",
|
| 42 |
+
description="Generate an image from a prompt"
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
@tool
|
| 46 |
+
def display_image(path: str) -> str:
|
| 47 |
+
"""
|
| 48 |
+
Use the PIL library to display an image from a given path.
|
| 49 |
+
|
| 50 |
+
Args:
|
| 51 |
+
path: output path from the image generation tool
|
| 52 |
"""
|
| 53 |
+
image = Image.open(path)
|
| 54 |
+
image.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
return "Success"
|
| 57 |
+
|
| 58 |
final_answer = FinalAnswerTool()
|
| 59 |
|
| 60 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 76 |
|
| 77 |
agent = CodeAgent(
|
| 78 |
model=model,
|
| 79 |
+
tools=[final_answer, image_generation_tool, get_current_time_in_timezone, wiki_of_person, display_image], ## add your tools here (don't remove final answer)
|
| 80 |
max_steps=6,
|
| 81 |
verbosity_level=1,
|
| 82 |
grammar=None,
|