# initiate_chats

## `autogen.initiate_chats`

```python
initiate_chats(chat_queue)
```

Initiate a list of chats.

| PARAMETER | DESCRIPTION |
| --- | --- |
| `chat_queue` | A list of dictionaries containing the information about the chats.<br>Each dictionary should contain the input arguments for [`ConversableAgent.initiate_chat`](https://docs.ag2.ai/0.12.1/docs/api-reference/autogen/ConversableAgent/#autogen.ConversableAgent.initiate_chat).<br>For example:<br>```<br>- "sender" - the sender agent.<br>- "recipient" - the recipient agent.<br>- "clear_history" (bool) - whether to clear the chat history with the agent.<br>  Default is True.<br>- "silent" (bool or None) - (Experimental) whether to print the messages in this<br>  conversation. Default is False.<br>- "cache" (Cache or None) - the cache client to use for this conversation.<br>  Default is None.<br>- "max_turns" (int or None) - maximum number of turns for the chat. If None, the chat<br>  will continue until a termination condition is met. Default is None.<br>- "summary_method" (str or callable) - a string or callable specifying the method to get<br>  a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".<br>- "summary_args" (dict) - a dictionary of arguments to be passed to the summary_method.<br>  Default is {}.<br>- "message" (str, callable or None) - if None, input() will be called to get the<br>  initial message.<br>- `**context` - additional context information to be passed to the chat.<br>- "carryover" - It can be used to specify the carryover information to be passed<br>  to this chat. If provided, we will combine this carryover with the "message" content when<br>  generating the initial chat message in `generate_init_message`.<br>- "finished_chat_indexes_to_exclude_from_carryover" - It can be used by specifying a list of indexes of the finished_chats list,<br>  from which to exclude the summaries for carryover. If 'finished_chat_indexes_to_exclude_from_carryover' is not provided or an empty list,<br>  then summary from all the finished chats will be taken.<br>```<br>**TYPE:**`List[Dict]` |

| RETURNS | DESCRIPTION |
| --- | --- |
| `list` | a list of ChatResult objects corresponding to the finished chats in the chat_queue. |

Source code in `autogen/agentchat/chat.py`

|     |     |
| --- | --- |
| ```<br>156<br>157<br>158<br>159<br>160<br>161<br>162<br>163<br>164<br>165<br>166<br>167<br>168<br>169<br>170<br>171<br>172<br>173<br>174<br>175<br>176<br>177<br>178<br>179<br>180<br>181<br>182<br>183<br>184<br>185<br>186<br>187<br>188<br>189<br>190<br>191<br>192<br>193<br>194<br>195<br>196<br>197<br>198<br>199<br>200<br>201<br>202<br>203<br>204<br>205<br>206<br>207<br>208<br>209<br>210<br>211<br>212<br>213<br>214<br>215<br>``` | ```<br>@export_module("autogen")<br>def initiate_chats(chat_queue: list[dict[str, Any]]) -> list[ChatResult]:<br>    """Initiate a list of chats.<br>    Args:<br>        chat_queue (List[Dict]): A list of dictionaries containing the information about the chats.
<br>            Each dictionary should contain the input arguments for<br>            [`ConversableAgent.initiate_chat`](ConversableAgent.md#autogen.ConversableAgent.initiate_chat).
<br>            For example:
<br>                - "sender" - the sender agent.
<br>                - "recipient" - the recipient agent.
<br>                - "clear_history" (bool) - whether to clear the chat history with the agent.
<br>                  Default is True.
<br>                - "silent" (bool or None) - (Experimental) whether to print the messages in this
<br>                  conversation. Default is False.
<br>                - "cache" (Cache or None) - the cache client to use for this conversation.
<br>                  Default is None.
<br>                - "max_turns" (int or None) - maximum number of turns for the chat. If None, the chat
<br>                  will continue until a termination condition is met. Default is None.
<br>                - "summary_method" (str or callable) - a string or callable specifying the method to get
<br>                  a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".
<br>                - "summary_args" (dict) - a dictionary of arguments to be passed to the summary_method.
<br>                  Default is {}.
<br>                - "message" (str, callable or None) - if None, input() will be called to get the
<br>                  initial message.
<br>                - `**context` - additional context information to be passed to the chat.
<br>                - "carryover" - It can be used to specify the carryover information to be passed
<br>                  to this chat. If provided, we will combine this carryover with the "message" content when
<br>                  generating the initial chat message in `generate_init_message`.
<br>                - "finished_chat_indexes_to_exclude_from_carryover" - It can be used by specifying a list of indexes of the finished_chats list,
<br>                  from which to exclude the summaries for carryover. If 'finished_chat_indexes_to_exclude_from_carryover' is not provided or an empty list,
<br>                  then summary from all the finished chats will be taken.
<br>    Returns:<br>        (list): a list of ChatResult objects corresponding to the finished chats in the chat_queue.
<br>    """<br>    consolidate_chat_info(chat_queue)<br>    _validate_recipients(chat_queue)<br>    current_chat_queue = chat_queue.copy()<br>    finished_chats = []<br>    while current_chat_queue:<br>        chat_info = current_chat_queue.pop(0)<br>        _chat_carryover = chat_info.get("carryover", [])<br>        finished_chat_indexes_to_exclude_from_carryover = chat_info.get(<br>            "finished_chat_indexes_to_exclude_from_carryover", []<br>        )<br>        if isinstance(_chat_carryover, str):<br>            _chat_carryover = [_chat_carryover]<br>        chat_info["carryover"] = _chat_carryover + [<br>            r.summary for i, r in enumerate(finished_chats) if i not in finished_chat_indexes_to_exclude_from_carryover<br>        ]<br>        if not chat_info.get("silent", False):<br>            __post_carryover_processing(chat_info)<br>        sender = chat_info["sender"]<br>        chat_res = sender.initiate_chat(**chat_info)<br>        finished_chats.append(chat_res)<br>    return finished_chats<br>```
