AScythe commited on
Commit
574446b
·
verified ·
1 Parent(s): a2c940f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
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 random_quote_tool()-> str:
41
- #Keep this format for the description / args / args description but feel free to modify the tool
42
- """A tool that fetches a random quote
43
- No arguments are taken
 
 
44
  """
45
- response = requests.get("https://zenquotes.io/api/quotes")
46
- if response.status_code == 200:
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,