In the chatbot example, how to "detect" end of conversation?

After the user finishes her order, confirms, specifies pickup/delivery, … etc, how can the end of the conversation be detected in code and order details json be sent to some fulfillment API?

Please keep in mind that conversation with a chatgpt is stateless. That is why you pass all relevant context when invoking the model via api (see chatbot lecture for refresher).

Anytime you want to end the conversation, you just move on to other tasks.

Yes I understand that. I guess what I can do is check whether chatgpt’s reply contains a json object, and if so, consider this the end of the conversation and proceed with calling the fulfillment API.

How about json.loads ?

+1 to this conversation and question.
I played with OrderBot and added next instruction : “When you collected all information about order, mark it as completed.
Don’t mark order as completed until user confirmed that.”.

Also I added field " 6) Completed" to the summary.

After each user’s response I generated summary until it was set to TRUE.

Could somebody confirm that this is right approach?

Hi, I would say there is no ‘right’ or ‘wrong’ approach necessarily. Or better, if it works for your objective, it is a ‘right’ approach, and there can be many other approaches. Yours is certainly one that I would use myself :slight_smile: