You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chat_queue (List[Dict]): a list of dictionaries containing the information about the chats.
141
141
142
-
Each dictionary should contain the input arguments for `ConversableAgent.initiate_chat`. For example:
143
-
"sender": the sender agent.
144
-
"recipient": the recipient agent.
145
-
"clear_history" (bool): whether to clear the chat history with the agent. Default is True.
146
-
"silent" (bool or None): (Experimental) whether to print the messages in this conversation. Default is False.
147
-
"cache" (Cache or None): the cache client to use for this conversation. Default is None.
148
-
"max_turns" (int or None): maximum number of turns for the chat. If None, the chat will continue until a termination condition is met. Default is None.
149
-
"summary_method" (str or callable): a string or callable specifying the method to get a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".
150
-
"summary_args" (dict): a dictionary of arguments to be passed to the summary_method. Default is {}.
151
-
"message" (str, callable or None): if None, input() will be called to get the initial message.
152
-
**context: additional context information to be passed to the chat.
153
-
"carryover": It can be used to specify the carryover information to be passed to this chat.
154
-
If provided, we will combine this carryover with the "message" content when generating the initial chat
155
-
message in `generate_init_message`.
142
+
Each dictionary should contain the input arguments for [`ConversableAgent.initiate_chat`](/docs/reference/agentchat/conversable_agent#initiate_chat). For example:
143
+
- "sender": the sender agent.
144
+
- "recipient": the recipient agent.
145
+
- "clear_history" (bool): whether to clear the chat history with the agent. Default is True.
146
+
- "silent" (bool or None): (Experimental) whether to print the messages in this conversation. Default is False.
147
+
- "cache" (Cache or None): the cache client to use for this conversation. Default is None.
148
+
- "max_turns" (int or None): maximum number of turns for the chat. If None, the chat will continue until a termination condition is met. Default is None.
149
+
- "summary_method" (str or callable): a string or callable specifying the method to get a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".
150
+
- "summary_args" (dict): a dictionary of arguments to be passed to the summary_method. Default is {}.
151
+
- "message" (str, callable or None): if None, input() will be called to get the initial message.
152
+
- **context: additional context information to be passed to the chat.
153
+
- "carryover": It can be used to specify the carryover information to be passed to this chat.
154
+
If provided, we will combine this carryover with the "message" content when generating the initial chat
155
+
message in `generate_init_message`.
156
156
157
157
Returns:
158
158
(list): a list of ChatResult objects corresponding to the finished chats in the chat_queue.
Copy file name to clipboardExpand all lines: autogen/agentchat/conversable_agent.py
+66-61
Original file line number
Diff line number
Diff line change
@@ -296,18 +296,18 @@ def register_reply(
296
296
from both sync and async chats. However, an async reply function will only be triggered from async
297
297
chats (initiated with `ConversableAgent.a_initiate_chat`). If an `async` reply function is registered
298
298
and a chat is initialized with a sync function, `ignore_async_in_sync_chat` determines the behaviour as follows:
299
-
- if `ignore_async_in_sync_chat` is set to `False` (default value), an exception will be raised, and
300
-
- if `ignore_async_in_sync_chat` is set to `True`, the reply function will be ignored.
299
+
if `ignore_async_in_sync_chat` is set to `False` (default value), an exception will be raised, and
300
+
if `ignore_async_in_sync_chat` is set to `True`, the reply function will be ignored.
301
301
302
302
Args:
303
303
trigger (Agent class, str, Agent instance, callable, or list): the trigger.
304
-
- If a class is provided, the reply function will be called when the sender is an instance of the class.
305
-
- If a string is provided, the reply function will be called when the sender's name matches the string.
306
-
- If an agent instance is provided, the reply function will be called when the sender is the agent instance.
307
-
- If a callable is provided, the reply function will be called when the callable returns True.
308
-
- If a list is provided, the reply function will be called when any of the triggers in the list is activated.
309
-
- If None is provided, the reply function will be called only when the sender is None.
310
-
Note: Be sure to register `None` as a trigger if you would like to trigger an auto-reply function with non-empty messages and `sender=None`.
304
+
If a class is provided, the reply function will be called when the sender is an instance of the class.
305
+
If a string is provided, the reply function will be called when the sender's name matches the string.
306
+
If an agent instance is provided, the reply function will be called when the sender is the agent instance.
307
+
If a callable is provided, the reply function will be called when the callable returns True.
308
+
If a list is provided, the reply function will be called when any of the triggers in the list is activated.
309
+
If None is provided, the reply function will be called only when the sender is None.
310
+
Note: Be sure to register `None` as a trigger if you would like to trigger an auto-reply function with non-empty messages and `sender=None`.
311
311
reply_func (Callable): the reply function.
312
312
The function takes a recipient agent, a list of messages, a sender agent and a config as input and returns a reply message.
313
313
position: the position of the reply function in the reply function list.
@@ -880,66 +880,71 @@ def initiate_chat(
880
880
silent (bool or None): (Experimental) whether to print the messages for this conversation. Default is False.
881
881
cache (Cache or None): the cache client to be used for this conversation. Default is None.
882
882
max_turns (int or None): the maximum number of turns for the chat between the two agents. One turn means one conversation round trip. Note that this is different from
883
-
[max_consecutive_auto_reply](#max_consecutive_auto_reply) which is the maximum number of consecutive auto replies; and it is also different from [max_rounds in GroupChat](./groupchat#groupchat-objects) which is the maximum number of rounds in a group chat session.
884
-
If max_turns is set to None, the chat will continue until a termination condition is met. Default is None.
885
-
summary_method (string or callable) : a method to get a summary from the chat. Default is DEFAULT_SUMMARY_METHOD, i.e., "last_msg".
886
-
- Supported string are "last_msg" and "reflection_with_llm":
887
-
when set "last_msg", it returns the last message of the dialog as the summary.
888
-
when set "reflection_with_llm", it returns a summary extracted using an llm client.
889
-
`llm_config` must be set in either the recipient or sender.
890
-
"reflection_with_llm" requires the llm_config to be set in either the sender or the recipient.
891
-
- A callable summary_method should take the recipient and sender agent in a chat as input and return a string of summary. E.g,
892
-
```python
893
-
def my_summary_method(
894
-
sender: ConversableAgent,
895
-
recipient: ConversableAgent,
896
-
summary_args: dict,
897
-
):
898
-
return recipient.last_message(sender)["content"]
899
-
```
883
+
[max_consecutive_auto_reply](#max_consecutive_auto_reply) which is the maximum number of consecutive auto replies; and it is also different from [max_rounds in GroupChat](./groupchat#groupchat-objects) which is the maximum number of rounds in a group chat session.
884
+
If max_turns is set to None, the chat will continue until a termination condition is met. Default is None.
885
+
summary_method (str or callable): a method to get a summary from the chat. Default is DEFAULT_SUMMARY_METHOD, i.e., "last_msg".
886
+
887
+
Supported strings are "last_msg" and "reflection_with_llm":
888
+
- when set to "last_msg", it returns the last message of the dialog as the summary.
889
+
- when set to "reflection_with_llm", it returns a summary extracted using an llm client.
890
+
`llm_config` must be set in either the recipient or sender.
891
+
892
+
A callable summary_method should take the recipient and sender agent in a chat as input and return a string of summary. E.g.,
893
+
894
+
```python
895
+
def my_summary_method(
896
+
sender: ConversableAgent,
897
+
recipient: ConversableAgent,
898
+
summary_args: dict,
899
+
):
900
+
return recipient.last_message(sender)["content"]
901
+
```
900
902
summary_args (dict): a dictionary of arguments to be passed to the summary_method.
901
-
E.g., a string of text used to prompt a LLM-based agent (the sender or receiver agent) to reflext
902
-
on the conversation and extract a summary when summary_method is "reflection_with_llm".
903
-
Default is DEFAULT_SUMMARY_PROMPT, i.e., "Summarize takeaway from the conversation. Do not add any introductory phrases. If the intended request is NOT properly addressed, please point it out."
903
+
One example key is "summary_prompt", and value is a string of text used to prompt a LLM-based agent (the sender or receiver agent) to reflect
904
+
on the conversation and extract a summary when summary_method is "reflection_with_llm".
905
+
The default summary_prompt is DEFAULT_SUMMARY_PROMPT, i.e., "Summarize takeaway from the conversation. Do not add any introductory phrases. If the intended request is NOT properly addressed, please point it out."
904
906
message (str, dict or Callable): the initial message to be sent to the recipient. Needs to be provided. Otherwise, input() will be called to get the initial message.
905
-
- If a string or a dict is provided, it will be used as the initial message. `generate_init_message` is called to generate the initial message for the agent based on this string and the context.
906
-
If dict, it may contain the following reserved fields (either content or function_call need to be provided).
907
-
1. "content": content of the message, can be None.
908
-
2. "function_call": a dictionary containing the function name and arguments. (deprecated in favor of "tool_calls")
909
-
3. "tool_calls": a list of dictionaries containing the function name and arguments.
910
-
4. "role": role of the message, can be "assistant", "user", "function".
911
-
This field is only needed to distinguish between "function" or "assistant"/"user".
912
-
5. "name": In most cases, this field is not needed. When the role is "function", this field is needed to indicate the function name.
913
-
6. "context" (dict): the context of the message, which will be passed to
914
-
[OpenAIWrapper.create](../oai/client#create).
915
-
- If a callable is provided, it will be called to get the initial message in the form of a string or a dict. If the returned value is a dict, it should contain the following reserved fields:
907
+
- If a string or a dict is provided, it will be used as the initial message. `generate_init_message` is called to generate the initial message for the agent based on this string and the context.
908
+
If dict, it may contain the following reserved fields (either content or tool_calls need to be provided).
909
+
910
+
1. "content": content of the message, can be None.
911
+
2. "function_call": a dictionary containing the function name and arguments. (deprecated in favor of "tool_calls")
912
+
3. "tool_calls": a list of dictionaries containing the function name and arguments.
913
+
4. "role": role of the message, can be "assistant", "user", "function".
914
+
This field is only needed to distinguish between "function" or "assistant"/"user".
915
+
5. "name": In most cases, this field is not needed. When the role is "function", this field is needed to indicate the function name.
916
+
6. "context" (dict): the context of the message, which will be passed to
917
+
[OpenAIWrapper.create](../oai/client#create).
918
+
919
+
- If a callable is provided, it will be called to get the initial message in the form of a string or a dict.
916
920
If the returned type is dict, it may contain the reserved fields mentioned above.
917
921
918
922
Example of a callable message (returning a string):
final_msg["content"] = "Write a blogpost." + "\\nContext: \\n" + carryover
942
+
final_msg["context"] = {"prefix": "Today I feel"}
943
+
return final_msg
944
+
```
940
945
**context: any context information. It has the following reserved fields:
941
-
"carryover": a string or a list of string to specify the carryover information to be passed to this chat.
942
-
If provided, we will combine this carryover (by attaching a "context: "string and the carryover content after the message content) with the "message" content when generating the initial chat
946
+
- "carryover": a string or a list of string to specify the carryover information to be passed to this chat.
947
+
If provided, we will combine this carryover (by attaching a "context: "string and the carryover content after the message content) with the "message" content when generating the initial chat
0 commit comments