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) 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.” 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 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: