In this lesson, you'll learn how to leverage the multi-agent design to finish a task involving multiple steps. You'll build a sequence of tasks between multiple agents who collaborate to provide a fun customer onboarding experience for a product. You also experience how humans could be seamlessly involved in the loop of an AI system. All right. Let's code. Let's consider a customer onboarding scenario. In this scenario, a typical procedure is to first collect some customer information and then survey customer's interest some customer information and then survey customer's interest and then engage with the customer based on the collected information. With this in mind, it's a good idea to decompose this customer onboarding task into three sub-tasks, including information collecting, interest survey, and customer engagement. Let's now check how we could finish this series of tasks with sequential chat. So here, we'll use the conversable agent class from AutoGen to realize those agents. Let's first import this conversable agent, from AutoGen. And then the first step is to create an onboarding agent that asks for personal information. And here we realize that by setting the system message as a customer onboarding agent, and gave detailed instruction. And here we are setting in human input mode as "never" because we are using a large language model to generator response from this agent. And similarly, let's create another onboarding agent that ask for topic preference. And similarly we can realize, what do we want to achieve by setting this system message. So here, the system message is set to ask the customer's interest, and preference on the topics. And similarly we will use "never" as human input mode and use a large language model, to back this conversable agent. And another agent we want to create is the customer engagement agent that provides fun facts, jokes, or interesting stories based on the user's customer's personal information, and the topic preference. And again, we, give detailed instructions, on the behavior of this engagement agent by setting the proper system message. Now, next, we should define a customer proxy agent to act as a proxy for the real customer. Note that here we are setting the human input mode as "always", so that this proxy agent could always solicit human input from the real customer. So with those agents constructed, we can now craft a sequential chat to finish the onboarding process. So in this specific example, each chat is effectively a two-agent chat between a particular onboarding agent and custom proxy agent in each chat. In each chat, the sender agent sends an initial message to the recipient to kick off the conversation, and then they will have a back-and-forth conversation until the max turns is reached or the termination message is received. In the first chat, we are setting the max turns to two, so that they can have at most two turns of conversation. In addition, in the sequential chat scenario, the tasks, typically depend on each other. Therefore, when they want to summarize information from the previous chat to be used in the next chat. In this case, we want to use the summary method. In this example, we are using reflection as the summary method to summarize the customer's personal information from the first chat and pass it to the second chat. We further add a summary prompt as a way to instruct the large language model on how to do the summary. So basically here we are instructing it to return the customer information into a json object, with this format, including a field of name and the location. So in the second chat, we are doing similar things. Here, the sender is the onboarding topic preference agent. And the recipient is a customer proxy agent. The kickoff message is: "Great, could you tell me what topics you are interested in reading about?" And the summary method we are using reflection with LLM and at this time we are not providing any customized summary prompt. And that will be using the building default prompt. And here in this case the max turn is set to be one. Because we just want to use one turn of conversation to seek the customer's interested topic. And in your specific case, you can always change the multiple turns so that you can seek more information. And in the third chat, we have a chat between the customer proxy agent and the customer engagement agent. And this time, it is the customer proxy agent, who kicks off the conversation. So basically by saying, "Let's find something to read." And after crafting this chat session, we are ready to start the whole onboarding process that executing initiate chats. In this example, you will act as the customer. And when you are prompted for answers, you should tap in your response and press enter. Okay, let's start the chat. So here, you can see that we are starting our first chat, which is between the onboarding personal information agent and the customer proxy agent. Here the onboarding agent is asking the customer "What is the name and the location." Let's say, I'll use a fake name. Alice. Next, it is asking, my location. I say my location is New York. And here you can see that we are starting a new chat, which is the second chat session between the topic preference agent and the customer proxy agent. And here, it is asking me to tell it the topics that I'm interested in reading about. So let's say the topic I want to read is about dog. And now that you can see we are entering our third chat session, and this chat session is between the customer proxy agent and the customer engagement agent. This is the message from the customer engagement agent. So basically, you can see that it is using my personal information, my name and the location and also the topic I'm interested in to have some engagement in the process. Feel free to pause here, and play around with it. For example, you can provide your own preferences. Okay, so when the chat is done, you could always check the results from each of these chat sessions in the sequential chat. So here let's chat in this chat session. And here you can see that we first have a nest json format of the customer's personal information. And we have a summary, the customer's interest, which is Alice is interested in reading about dog-related topics. And we also have a nest engagement message with the customer. Similarly, you can also check the cost associated with each of these chats. From this result, you can see their detailed, cost information, including, the total cost, the prompt token cost, and the completion token cost, and the total cost. Alright. In this lesson, we have learned how to use sequential chats to finish a sequence of dependent tasks. In the next lesson, you will learn how to realize the reflection agentic design pattern with nested chat. Where a chat or a sequence of chats are nested within another chat as in the monologue of an agent.