Poor man state management for multi turns agent chat

 

https://www.pexels.com/photo/person-sitting-inside-car-with-black-android-smartphone-turned-on-230554/
https://www.pexels.com/photo/person-sitting-inside-car-with-black-android-smartphone-turned-on-230554/

It is a common scenario when we need to track the state of chats. The proper way is to store the state in a persistency. This may comes with latency. Here is a poor man implementation of sending states information between application and chat agent. We construct a scenario when a patient needs to make an appointment with a doctor. The patient first describes the symptoms and the chat agent will figure out the department, and then gather more information in order to make an medical appointment.

The first turn looks like this.

The application needs to question & current state because it contains information of which the application to help to gather. Example, doctor, appointment date and time.

Subsequent flow looks like this.


The source code is in this repo. Here is a demo (without audio)


Another variation is to have the user input the text and have LLM to update the JSON state. The code is in the same repo under branch, denz/user-input.











 

Comments