Student Attendance Chatbot with Parallel Function Calling
In the previous post, I created a chatbot that interacts with the database to take attendance. One of the issues with my Student Attendance Chatbot (Version 3) (opens in a new tab) is that it could not generate multiple function calls in response to a complex user message. For example, if I enter "mark everyone as present today except Mason," the chatbot will only handle the first part of the input, which is "mark everyone as present today." The chatbot will not handle the second part of the input, which is "except Mason." In this post, I will show you how I fixed this issue.
In Student Attendance Chatbot (Version 3), I specified the OpenAI model as "gpt-3.5-turbo," which, at the time of writing, was pointing at "gpt-3.5-turbo-0613." This model is not capable of "Parallel Function Calling (opens in a new tab)." Luckily, on DevDay on November 6, 2023, OpenAI released a new 3.5 model called "gpt-3.5-turbo-1106," which can do exactly that. Check out my updated version of Student Attendance Chatbot at https://github.com/calvincchan/student-attendance-chatbot/tree/version-4 (opens in a new tab) using this model, or run it in CodeSandbox as shown below."
Tests
"everyone is present today, but Mia is sick"
β¨ Hello Mr. Smith, the default homeroom is 1, and today's date is 2023-12-29. How can I assist you today?
> everyone is present today, but Mia is sick
π Function call: setAllPresentByHomeroom { homeroom: '1', date: '2023-12-29' }
Marked all students in homeroom 1 as present on 2023-12-29
π Function call: setAttendance {
name: 'Mia',
homeroom: '1',
date: '2023-12-29',
present: false,
reason: 'Sick'
}
Set attendance for student 10001 on 2023-12-29 to false with reason Sick
βββββββββββ¬βββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββββββ
β (index) β Student_id β Student_name β Attendance_date β Attendance_present β Attendance_reason β Student_homeroom β
βββββββββββΌβββββββββββββΌβββββββββββββββββββΌββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββΌβββββββββββββββββββ€
β 0 β '10001' β 'Mia Chen' β '2023-12-29' β 0 β 'Sick' β '1' β
β 1 β '10008' β 'Aiden Kumar' β '2023-12-29' β 1 β null β '1' β
β 2 β '10015' β 'Mila Lee' β '2023-12-29' β 1 β null β '1' β
β 3 β '10022' β 'Ezra Wang' β '2023-12-29' β 1 β null β '1' β
β 4 β '10029' β 'Aaliyah Lopez' β '2023-12-29' β 1 β null β '1' β
β 5 β '10036' β 'Liam Rao' β '2023-12-29' β 1 β null β '1' β
β 6 β '10043' β 'Lily Wu' β '2023-12-29' β 1 β null β '1' β
β 7 β '10050' β 'Kai Singh' β '2023-12-29' β 1 β null β '1' β
β 8 β '10057' β 'Avery Lin' β '2023-12-29' β 1 β null β '1' β
β 9 β '10064' β 'Mason Lam' β '2023-12-29' β 1 β null β '1' β
β 10 β '10071' β 'Harper Gupta' β '2023-12-29' β 1 β null β '1' β
β 11 β '10078' β 'William Kim' β '2023-12-29' β 1 β null β '1' β
β 12 β '10085' β 'Ella Morales' β '2023-12-29' β 1 β null β '1' β
β 13 β '10092' β 'Lucas Kumar' β '2023-12-29' β 1 β null β '1' β
β 14 β '10099' β 'Ava Singh' β '2023-12-29' β 1 β null β '1' β
β 15 β '10106' β 'Liam Hernandez' β '2023-12-29' β 1 β null β '1' β
β 16 β '10113' β 'Lily Garcia' β '2023-12-29' β 1 β null β '1' β
β 17 β '10120' β 'Harper Lam' β '2023-12-29' β 1 β null β '1' β
βββββββββββ΄βββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββββββ΄βββββββββββββββββββ
>
"mark everyone as present yesterday except Mason"
> mark everyone as present yesterday except Mason
π Function call: setAllPresentByHomeroom { homeroom: '1', date: '2023-12-28' }
Marked all students in homeroom 1 as present on 2023-12-28
π Function call: setAttendance { name: 'Mason', homeroom: '1', date: '2023-12-28', present: false }
Set attendance for student 10064 on 2023-12-28 to false with reason undefined
βββββββββββ¬βββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββββββ
β (index) β Student_id β Student_name β Attendance_date β Attendance_present β Attendance_reason β Student_homeroom β
βββββββββββΌβββββββββββββΌβββββββββββββββββββΌββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββΌβββββββββββββββββββ€
β 0 β '10001' β 'Mia Chen' β '2023-12-28' β 1 β null β '1' β
β 1 β '10008' β 'Aiden Kumar' β '2023-12-28' β 1 β null β '1' β
β 2 β '10015' β 'Mila Lee' β '2023-12-28' β 1 β null β '1' β
β 3 β '10022' β 'Ezra Wang' β '2023-12-28' β 1 β null β '1' β
β 4 β '10029' β 'Aaliyah Lopez' β '2023-12-28' β 1 β null β '1' β
β 5 β '10036' β 'Liam Rao' β '2023-12-28' β 1 β null β '1' β
β 6 β '10043' β 'Lily Wu' β '2023-12-28' β 1 β null β '1' β
β 7 β '10050' β 'Kai Singh' β '2023-12-28' β 1 β null β '1' β
β 8 β '10057' β 'Avery Lin' β '2023-12-28' β 1 β null β '1' β
β 9 β '10064' β 'Mason Lam' β '2023-12-28' β 0 β null β '1' β
β 10 β '10071' β 'Harper Gupta' β '2023-12-28' β 1 β null β '1' β
β 11 β '10078' β 'William Kim' β '2023-12-28' β 1 β null β '1' β
β 12 β '10085' β 'Ella Morales' β '2023-12-28' β 1 β null β '1' β
β 13 β '10092' β 'Lucas Kumar' β '2023-12-28' β 1 β null β '1' β
β 14 β '10099' β 'Ava Singh' β '2023-12-28' β 1 β null β '1' β
β 15 β '10106' β 'Liam Hernandez' β '2023-12-28' β 1 β null β '1' β
β 16 β '10113' β 'Lily Garcia' β '2023-12-28' β 1 β null β '1' β
β 17 β '10120' β 'Harper Lam' β '2023-12-28' β 1 β null β '1' β
βββββββββββ΄βββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββββββ΄βββββββββββββββββββ
>
"show Mia's record this month"
> Show Mia's record this month
π Function call: findAttendance {
homeroom: '1',
studentName: 'Mia',
fromDate: '2023-12-01',
toDate: '2023-12-31'
}
βββββββββββ¬βββββββββββββ¬βββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββββββ
β (index) β Student_id β Student_name β Attendance_date β Attendance_present β Attendance_reason β Student_homeroom β
βββββββββββΌβββββββββββββΌβββββββββββββββΌββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββΌβββββββββββββββββββ€
β 0 β '10001' β 'Mia Chen' β '2023-12-01' β 1 β '' β '1' β
β 1 β '10001' β 'Mia Chen' β '2023-12-28' β 1 β null β '1' β
β 2 β '10001' β 'Mia Chen' β '2023-12-29' β 0 β 'Sick' β '1' β
βββββββββββ΄βββββββββββββ΄βββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββββββ΄βββββββββββββββββββ
>
using other languages (Chinese)
> β¨ Hello Mr. Smith! How can I assist you today?
> Mia δ»ε€©ηη
δΊ
π Function call: setAttendance {
name: 'Mia',
homeroom: '1',
date: '2023-12-29',
present: false,
reason: 'ηη
'
}
Set attendance for student 10001 on 2023-12-29 to false with reason ηη
βββββββββββ¬βββββββββββββ¬βββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββββββ
β (index) β Student_id β Student_name β Attendance_date β Attendance_present β Attendance_reason β Student_homeroom β
βββββββββββΌβββββββββββββΌβββββββββββββββΌββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββΌβββββββββββββββββββ€
β 0 β '10001' β 'Mia Chen' β '2023-12-29' β 0 β 'ηη
' β '1' β
βββββββββββ΄βββββββββββββ΄βββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββββββ΄βββββββββββββββββββ
> ι‘―η€Ίδ»εζηεΊεΈθ‘¨
π Function call: findAttendance { homeroom: '1', fromDate: '2023-12-01', toDate: '2023-12-31' }
βββββββββββ¬βββββββββββββ¬ββββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββββββ
β (index) β Student_id β Student_name β Attendance_date β Attendance_present β Attendance_reason β Student_homeroom β
βββββββββββΌβββββββββββββΌββββββββββββββββΌββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββΌβββββββββββββββββββ€
β 0 β '10001' β 'Mia Chen' β '2023-12-01' β 1 β '' β '1' β
β 1 β '10008' β 'Aiden Kumar' β '2023-12-01' β 1 β '' β '1' β
β 2 β '10015' β 'Mila Lee' β '2023-12-01' β 1 β '' β '1' β
β 3 β '10022' β 'Ezra Wang' β '2023-12-01' β 0 β 'fever and cough' β '1' β
β 4 β '10001' β 'Mia Chen' β '2023-12-29' β 0 β 'ηη
' β '1' β
βββββββββββ΄βββββββββββββ΄ββββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββββββ΄βββββββββββββββββββ
> ζ¨ε€©ζζδΊΊι½ζεΊεΈοΌεͺζ Mason ηη
δΊ
π Function call: setAllPresentByHomeroom { homeroom: '1', date: '2023-12-28' }
Marked all students in homeroom 1 as present on 2023-12-28
π Function call: setAttendance {
name: 'Mason',
homeroom: '1',
date: '2023-12-28',
present: false,
reason: 'Sick'
}
Set attendance for student 10064 on 2023-12-28 to false with reason Sick
βββββββββββ¬βββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββββββ
β (index) β Student_id β Student_name β Attendance_date β Attendance_present β Attendance_reason β Student_homeroom β
βββββββββββΌβββββββββββββΌβββββββββββββββββββΌββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββΌβββββββββββββββββββ€
β 0 β '10001' β 'Mia Chen' β '2023-12-28' β 1 β null β '1' β
β 1 β '10008' β 'Aiden Kumar' β '2023-12-28' β 1 β null β '1' β
β 2 β '10015' β 'Mila Lee' β '2023-12-28' β 1 β null β '1' β
β 3 β '10022' β 'Ezra Wang' β '2023-12-28' β 1 β null β '1' β
β 4 β '10029' β 'Aaliyah Lopez' β '2023-12-28' β 1 β null β '1' β
β 5 β '10036' β 'Liam Rao' β '2023-12-28' β 1 β null β '1' β
β 6 β '10043' β 'Lily Wu' β '2023-12-28' β 1 β null β '1' β
β 7 β '10050' β 'Kai Singh' β '2023-12-28' β 1 β null β '1' β
β 8 β '10057' β 'Avery Lin' β '2023-12-28' β 1 β null β '1' β
β 9 β '10064' β 'Mason Lam' β '2023-12-28' β 0 β 'Sick' β '1' β
β 10 β '10071' β 'Harper Gupta' β '2023-12-28' β 1 β null β '1' β
β 11 β '10078' β 'William Kim' β '2023-12-28' β 1 β null β '1' β
β 12 β '10085' β 'Ella Morales' β '2023-12-28' β 1 β null β '1' β
β 13 β '10092' β 'Lucas Kumar' β '2023-12-28' β 1 β null β '1' β
β 14 β '10099' β 'Ava Singh' β '2023-12-28' β 1 β null β '1' β
β 15 β '10106' β 'Liam Hernandez' β '2023-12-28' β 1 β null β '1' β
β 16 β '10113' β 'Lily Garcia' β '2023-12-28' β 1 β null β '1' β
β 17 β '10120' β 'Harper Lam' β '2023-12-28' β 1 β null β '1' β
βββββββββββ΄βββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββββββ΄βββββββββββββββββββ
>
Thoughts
I think this version is even closer to my original goal of creating a chatbot that can handle natural language requests more accurately. However, it still doesn't have conversation memory that enables follow-up questions. It will be something I will look into next.
With the new models that support parallel function calling, it will be even easier to integrate AI into existing applications. I am looking forward to experimenting with more application ideas in the future.
Follow-up: I have written a new version to with interactive web frontend. Check out the following link: