Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import requests
|
|
5 |
import pytz
|
6 |
import yaml
|
7 |
from PIL import Image
|
|
|
8 |
from tools.final_answer import FinalAnswerTool
|
9 |
|
10 |
from Gradio_UI import GradioUI
|
@@ -55,10 +56,11 @@ def generate_travel_brochure_image(description: str) -> AgentImage:
|
|
55 |
Args:
|
56 |
description: A string representing text to be converted into a brochure.
|
57 |
"""
|
58 |
-
|
59 |
-
if isinstance(
|
|
|
60 |
return AgentImage(image)
|
61 |
-
raise ValueError("Image generation failed or returned invalid
|
62 |
|
63 |
|
64 |
|
@@ -81,10 +83,10 @@ with open("prompts.yaml", 'r') as stream:
|
|
81 |
agent = CodeAgent(
|
82 |
model=model,
|
83 |
tools=[
|
|
|
84 |
get_current_time_in_timezone,
|
85 |
travel_recommendations_for_city,
|
86 |
-
generate_travel_brochure_image
|
87 |
-
final_answer
|
88 |
], ## add your tools here (don't remove final answer)
|
89 |
max_steps=6,
|
90 |
verbosity_level=1,
|
|
|
5 |
import pytz
|
6 |
import yaml
|
7 |
from PIL import Image
|
8 |
+
import os
|
9 |
from tools.final_answer import FinalAnswerTool
|
10 |
|
11 |
from Gradio_UI import GradioUI
|
|
|
56 |
Args:
|
57 |
description: A string representing text to be converted into a brochure.
|
58 |
"""
|
59 |
+
image_path = image_generation_tool(description)
|
60 |
+
if isinstance(image_path, str) and os.path.exists(image_path):
|
61 |
+
image = Image.open(image_path)
|
62 |
return AgentImage(image)
|
63 |
+
raise ValueError("Image generation failed or returned invalid path.")
|
64 |
|
65 |
|
66 |
|
|
|
83 |
agent = CodeAgent(
|
84 |
model=model,
|
85 |
tools=[
|
86 |
+
final_answer,
|
87 |
get_current_time_in_timezone,
|
88 |
travel_recommendations_for_city,
|
89 |
+
generate_travel_brochure_image
|
|
|
90 |
], ## add your tools here (don't remove final answer)
|
91 |
max_steps=6,
|
92 |
verbosity_level=1,
|