emmac commited on
Commit
339a6e7
·
verified ·
1 Parent(s): db30d68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
 
2
  import datetime
3
  import requests
4
  import pytz
@@ -38,14 +39,18 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
38
 
39
  @tool
40
  def generate_image_file(prompt: str) -> str:
41
- """Generate an image from a text prompt and return a filepath to the PNG."""
 
 
 
42
  img = image_generation_tool(prompt=prompt)
43
- out_path = "/tmp/generated.png"
44
  img.save(out_path)
45
  return out_path
46
 
47
 
48
 
 
49
  final_answer = FinalAnswerTool()
50
 
51
  # 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:
 
1
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
+ import uuid
3
  import datetime
4
  import requests
5
  import pytz
 
39
 
40
  @tool
41
  def generate_image_file(prompt: str) -> str:
42
+ """Generate an image from a text prompt and return a PNG filepath.
43
+ Args:
44
+ prompt: The text description of the image to generate.
45
+ """
46
  img = image_generation_tool(prompt=prompt)
47
+ out_path = f"/tmp/{uuid.uuid4().hex}.png"
48
  img.save(out_path)
49
  return out_path
50
 
51
 
52
 
53
+
54
  final_answer = FinalAnswerTool()
55
 
56
  # 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: