aleixlopezpascual commited on
Commit
bad44e4
·
verified ·
1 Parent(s): 9a8c112

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -8
app.py CHANGED
@@ -7,16 +7,76 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
10
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -51,7 +111,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
7
 
8
  from Gradio_UI import GradioUI
9
 
 
10
  @tool
11
+ def my_amazing_tool(partner_name: str, special_date: str) -> str:
12
+ """A tool to impress your partner with your knowledge of special dates.
13
+
14
+ Args:
15
+ partner_name: Your partner's name (for personalization).
16
+ special_date: A date in YYYY-MM-DD format (e.g., 2024-03-15).
17
+ """
18
+
19
+ try:
20
+ date_obj = datetime.datetime.strptime(special_date, "%Y-%m-%d").date()
21
+ except ValueError:
22
+ return "Oops! Invalid date format. Please use YYYY-MM-DD."
23
+
24
+ today = datetime.date.today()
25
+ days_until = (date_obj - today).days
26
+
27
+ if days_until > 0:
28
+ message = f"Hey {partner_name}, did you know that there are only {days_until} days until {date_obj.strftime('%B %d')}? I was just thinking about it, and how much I'm looking forward to it!"
29
+ elif days_until == 0:
30
+ message = f"Happy {date_obj.strftime('%B %d')}, {partner_name}! I hope you have an amazing day. I was thinking of you all day."
31
+ else:
32
+ days_ago = abs(days_until)
33
+ message = f"{partner_name}, I was reminiscing about {date_obj.strftime('%B %d')}. It seems like just {days_ago} days ago! Such great memories."
34
+
35
+ # Add some extra flair (optional)
36
+ import random
37
+ emojis = ["😊", "😍", "🥰", "😘", "💖", "💕"]
38
+ message += f" {random.choice(emojis)}"
39
+
40
+ return message
41
+
42
+
43
+ @tool
44
+ def surprise_generator(partner_name: str, occasion: str) -> str:
45
+ """Generates a personalized surprise idea for your partner.
46
+
47
  Args:
48
+ partner_name: Your partner's name.
49
+ occasion: The occasion (e.g., birthday, anniversary, just because).
50
  """
51
+
52
+ surprise_ideas = {
53
+ "birthday": [
54
+ "Plan a surprise party with their closest friends and family.",
55
+ "Create a personalized video montage with messages from loved ones.",
56
+ "Organize a scavenger hunt leading to their favorite gift or a special experience.",
57
+ "Bake their favorite cake or treat.",
58
+ "Book a weekend getaway to a place they've always wanted to visit."
59
+ ],
60
+ "anniversary": [
61
+ "Recreate your first date or a special memory together.",
62
+ "Write them a heartfelt letter expressing your love and appreciation.",
63
+ "Create a photo album or scrapbook documenting your relationship milestones.",
64
+ "Plan a romantic dinner at home or at their favorite restaurant.",
65
+ "Gift them a piece of jewelry with a special meaning."
66
+ ],
67
+ "just because": [
68
+ "Leave them a sweet note or message to brighten their day.",
69
+ "Surprise them with their favorite snack or drink.",
70
+ "Offer to help them with a task or chore they've been putting off.",
71
+ "Plan a spontaneous date night or outing.",
72
+ "Give them a thoughtful gift that shows you care."
73
+ ]
74
+ }
75
+
76
+ ideas = surprise_ideas.get(occasion.lower(), ["Plan a surprise!"]) # Default if occasion not found
77
+ chosen_idea = random.choice(ideas)
78
+
79
+ return f"Hey {partner_name}, for {occasion}, how about: {chosen_idea} I think you'll love it!"
80
 
81
  @tool
82
  def get_current_time_in_timezone(timezone: str) -> str:
 
111
 
112
  agent = CodeAgent(
113
  model=model,
114
+ tools=[my_amazing_tool, surprise_generator, final_answer], ## add your tools here (don't remove final answer)
115
  max_steps=6,
116
  verbosity_level=1,
117
  grammar=None,