mayank64ce commited on
Commit
f6d3524
·
verified ·
1 Parent(s): 2d7ef46

Update app.py

Browse files

added display_image

Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -5,7 +5,7 @@ import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
  import cv2
8
-
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
@@ -35,6 +35,21 @@ def gaussian_blur(image_path: str, output_path: str, kernel_size: int, sigma: in
35
 
36
  return output_path
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  @tool
39
  def get_current_time_in_timezone(timezone: str) -> str:
40
  """A tool that fetches the current local time in a specified timezone.
@@ -72,7 +87,7 @@ with open("prompts.yaml", 'r') as stream:
72
 
73
  agent = CodeAgent(
74
  model=model,
75
- tools=[image_generation_tool, get_current_time_in_timezone, gaussian_blur, DuckDuckGoSearchTool(), final_answer], ## add your tools here (don't remove final answer)
76
  max_steps=6,
77
  verbosity_level=1,
78
  grammar=None,
 
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
  import cv2
8
+ from PIL import Image
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
35
 
36
  return output_path
37
 
38
+ @tool
39
+ def display_image(image_path: str) -> None:
40
+ """
41
+ Opens and displays an image using Pillow.
42
+
43
+ Args:
44
+ image_path: The file path of the image to be displayed.
45
+ """
46
+ try:
47
+ image = Image.open(image_path)
48
+ image.show()
49
+ except Exception as e:
50
+ raise ValueError(f"Error opening image: {e}")
51
+
52
+
53
  @tool
54
  def get_current_time_in_timezone(timezone: str) -> str:
55
  """A tool that fetches the current local time in a specified timezone.
 
87
 
88
  agent = CodeAgent(
89
  model=model,
90
+ tools=[image_generation_tool, get_current_time_in_timezone, gaussian_blur, display_image, DuckDuckGoSearchTool(), final_answer], ## add your tools here (don't remove final answer)
91
  max_steps=6,
92
  verbosity_level=1,
93
  grammar=None,