AtakanTekparmak commited on
Commit
f6f544b
·
verified ·
1 Parent(s): 3fb6797

feat: Updated Quickstart

Browse files
Files changed (1) hide show
  1. README.md +57 -33
README.md CHANGED
@@ -57,7 +57,6 @@ The following dangerous builtins are restricted for security:
57
  - execfile
58
  - compile
59
  - importlib
60
- - __import__
61
  - input
62
  - exit
63
 
@@ -74,16 +73,9 @@ DO NOT use print() statements AT ALL. Avoid mutating variables whenever possible
74
 
75
 
76
  get_sample_data = """
77
- def get_current_date():
78
- \"\"\" Get the current date.
79
-
80
- Returns:
81
- - Current date in YYYY-MM-DD format
82
- \"\"\"
83
- pass
84
-
85
- def check_availability(day: str, start_time: str, end_time: str):
86
- \"\"\" Check if a time slot is available on a given day.
87
 
88
  Args:
89
  - day: The day to check in YYYY-MM-DD format
@@ -95,8 +87,9 @@ def check_availability(day: str, start_time: str, end_time: str):
95
  \"\"\"
96
  pass
97
 
98
- def make_appointment(day: str, start_time: str, end_time: str):
99
- \"\"\" Make an appointment for a given time slot.
 
100
 
101
  Args:
102
  - day: The day to make appointment in YYYY-MM-DD format
@@ -105,7 +98,24 @@ def make_appointment(day: str, start_time: str, end_time: str):
105
  - title: The title of the appointment
106
 
107
  Returns:
108
- - True if appointment was made successfully, False otherwise
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  \"\"\"
110
  pass
111
  """
@@ -116,9 +126,14 @@ def format_prompt(tools: str):
116
 
117
  system_prompt = SYSTEM_PROMPT.replace("{{functions_schema}}", get_sample_data)
118
 
 
 
 
 
 
119
  messages = [
120
  {"role": "system", "content": system_prompt},
121
- {"role": "user", "content": "Can you check if I have tomorrow 10:00-12:00 available and make an appointment for a meeting with my thesis supervisor if so?"},
122
  ]
123
 
124
  text = tokenizer.apply_chat_template(
@@ -143,35 +158,44 @@ print(response)
143
  The output should be something like:
144
 
145
  ````
146
- To accomplish this task, we need to follow these steps:
147
 
148
- 1. Determine the current date and add one day to it to find tomorrow's date.
149
- 2. Check the availability of the time slot from 10:00 to 12:00 on that day.
150
- 3. If the slot is available, make an appointment for the meeting.
151
 
152
- Here's the Python code to achieve this:
153
 
154
  ```python
155
  from datetime import datetime, timedelta
156
 
157
- # Step 1: Determine the current date and add one day to get tomorrow's date
158
- current_date = get_current_date()
159
- tomorrow_date = (datetime.strptime(current_date, '%Y-%m-%d') + timedelta(days=1)).strftime('%Y-%m-%d')
160
 
161
- # Step 2: Check the availability of the time slot from 10:00 to 12:00 on that day
162
- slot_start_time = '10:00'
163
- slot_end_time = '12:00'
164
- is_slot_available = check_availability(tomorrow_date, slot_start_time, slot_end_time)
165
 
166
- # Step 3: If the slot is available, make an appointment for the meeting
167
- appointment_title = "Meeting with thesis supervisor"
168
- appointment_made = False
 
 
 
 
169
 
170
- if is_slot_available:
171
- appointment_made = make_appointment(tomorrow_date, slot_start_time, slot_end_time, appointment_title)
 
 
172
  ```
173
 
174
- This code first calculates tomorrow's date, then checks if the time slot from 10:00 to 12:00 is available, and finally makes an appointment if the slot is available.
 
 
 
 
 
 
175
  ````
176
 
177
  ## Evaluation & Performance
 
57
  - execfile
58
  - compile
59
  - importlib
 
60
  - input
61
  - exit
62
 
 
73
 
74
 
75
  get_sample_data = """
76
+ def check_availability(day: str, start_time: str, end_time: str) -> bool:
77
+ \"\"\"
78
+ Check if a time slot is available on a given day.
 
 
 
 
 
 
 
79
 
80
  Args:
81
  - day: The day to check in YYYY-MM-DD format
 
87
  \"\"\"
88
  pass
89
 
90
+ def make_appointment(day: str, start_time: str, end_time: str) -> dict:
91
+ \"\"\"
92
+ Make an appointment for a given time slot.
93
 
94
  Args:
95
  - day: The day to make appointment in YYYY-MM-DD format
 
98
  - title: The title of the appointment
99
 
100
  Returns:
101
+ - A dictionary with the appointment details and if it's made or not.
102
+ dict keys:
103
+ - day (str): The day the appointment is on, in YYYY-MM-DD format
104
+ - start_time (str): Start time in HH:MM format
105
+ - end_time (str): End time in HH:MM format
106
+ - appointment_made (bool): Whether the appointment is successfully made or not.
107
+ \"\"\"
108
+ pass
109
+
110
+ def add_to_reminders(reminder_text: str) -> bool:
111
+ \"\"\"
112
+ Add a text to reminders.
113
+
114
+ Args:
115
+ - reminder_text: The text to add to reminders
116
+
117
+ Returns:
118
+ - Whether the reminder was successfully created or not.
119
  \"\"\"
120
  pass
121
  """
 
126
 
127
  system_prompt = SYSTEM_PROMPT.replace("{{functions_schema}}", get_sample_data)
128
 
129
+ USER_QUERY = """
130
+ Can you check if I have tomorrow 10:00-12:00 available and make an appointment for a meeting
131
+ with my thesis supervisor if so? If you made the appointment, please add it to my reminders.
132
+ """
133
+
134
  messages = [
135
  {"role": "system", "content": system_prompt},
136
+ {"role": "user", "content": USER_QUERY},
137
  ]
138
 
139
  text = tokenizer.apply_chat_template(
 
158
  The output should be something like:
159
 
160
  ````
161
+ I'll help you check availability and make the appointment. Let's break this down into steps:
162
 
163
+ 1. First, we need to check if tomorrow's 10:00-12:00 time slot is available using check_availability()
164
+ 2. If available, we'll make the appointment using make_appointment()
165
+ 3. Finally, we'll add the appointment to reminders if it was successfully made
166
 
167
+ Here's the code to accomplish this:
168
 
169
  ```python
170
  from datetime import datetime, timedelta
171
 
172
+ # Calculate tomorrow's date
173
+ tomorrow = (datetime.now() + timedelta(days=1)).strftime("%Y-%m-%d")
 
174
 
175
+ # Check availability for 10:00-12:00
176
+ available = check_availability(tomorrow, "10:00", "12:00")
 
 
177
 
178
+ # If available, make the appointment
179
+ appointment_details = make_appointment(
180
+ day=tomorrow,
181
+ start_time="10:00",
182
+ end_time="12:00",
183
+ title="Meeting with thesis supervisor"
184
+ )
185
 
186
+ # Add appointment to reminders if it was successfully made
187
+ if appointment_details["appointment_made"]:
188
+ reminder_text = f"Meeting with thesis supervisor on {tomorrow} from 10:00-12:00"
189
+ add_to_reminders(reminder_text)
190
  ```
191
 
192
+ This code will:
193
+ 1. Calculate tomorrow's date in YYYY-MM-DD format
194
+ 2. Check if the 10:00-12:00 slot is available
195
+ 3. If available, make the appointment with the specified details
196
+ 4. If the appointment is successfully made, add a reminder to the system
197
+
198
+ The code handles all error cases implicitly through the boolean returns of the functions. If any step fails, the subsequent steps won't execute, preventing partial or invalid appointments.
199
  ````
200
 
201
  ## Evaluation & Performance