alolar commited on
Commit
9346cbd
·
verified ·
1 Parent(s): df92104

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -37,6 +37,31 @@ def get_current_time_in_timezone(timezone: str) -> str:
37
  except Exception as e:
38
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  # The Agent
41
 
42
  final_answer = FinalAnswerTool()
@@ -60,7 +85,7 @@ with open("prompts.yaml", 'r') as stream:
60
 
61
  agent = CodeAgent(
62
  model=model,
63
- tools=[final_answer, my_custom_tool], # added my_custom_tool here
64
  max_steps=6,
65
  verbosity_level=1,
66
  grammar=None,
 
37
  except Exception as e:
38
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
39
 
40
+ @tool
41
+ def generate_themed_image(subject: str, style: str) -> str:
42
+ """Generates an image by combining a subject and an art style into a prompt.
43
+
44
+ Args:
45
+ subject: The main subject of the image (e.g., 'a cat on a beach').
46
+ style: The artistic style to apply (e.g., 'watercolor', 'pixel art', 'oil painting').
47
+ """
48
+ prompt = f"{subject} in {style} style"
49
+ return image_generation_tool(prompt)
50
+
51
+ @tool
52
+ def search_and_summarize(query: str, max_results: int) -> str:
53
+ """Searches the web using DuckDuckGo and returns the top results for a given query.
54
+
55
+ Args:
56
+ query: The search term or question to look up.
57
+ max_results: The number of results to return, between 1 and 5.
58
+ """
59
+ max_results = max(1, min(max_results, 5))
60
+ search = DuckDuckGoSearchTool()
61
+ results = search(query)
62
+ lines = results.strip().split("\n")
63
+ return "\n".join(lines[:max_results])
64
+
65
  # The Agent
66
 
67
  final_answer = FinalAnswerTool()
 
85
 
86
  agent = CodeAgent(
87
  model=model,
88
+ tools=[final_answer, my_custom_tool, generate_themed_image, search_and_summarize], # added my additional tools here
89
  max_steps=6,
90
  verbosity_level=1,
91
  grammar=None,