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
The document describes that nested chat is a powerful conversation pattern that allows you to package complex workflows into a single agent.
I'm a bit confused about the nested chat design. The nested chat is implemented by registering the reply_func_from_nested_chats method. In this method, only the last_msg is used to initialize a new chat, causing the loss of other chat history. I feel that this is not consistent with the design of the generate_reply method, which accepts a message list.
def_summary_from_nested_chats(
chat_queue: List[Dict[str, Any]], recipient: Agent, messages: Union[str, Callable], sender: Agent, config: Any
) ->Tuple[bool, str]:
last_msg=messages[-1].get("content")
chat_to_run= []
fori, cinenumerate(chat_queue):
current_c=c.copy()
ifcurrent_c.get("sender") isNone:
current_c["sender"] =recipientmessage=current_c.get("message")
# If message is not provided in chat_queue, we by default use the last message from the original chat history as the first message in this nested chat (for the first chat in the chat queue).# NOTE: This setting is prone to change.ifmessageisNoneandi==0:
message=last_msgifcallable(message):
message=message(recipient, messages, sender, config)
# We only run chat that has a valid message. NOTE: This is prone to change dependin on applications.ifmessage:
current_c["message"] =messagechat_to_run.append(current_c)
ifnotchat_to_run:
returnTrue, Noneres=initiate_chats(chat_to_run)
returnTrue, res[-1].summary
If I want to inject some context before the conversation, it won't work.
llm_config = {
"config_list": [{"model": "gpt-4o-mini", "api_key": os.environ["OPENAI_API_KEY"]}]}
agent = ConversableAgent(
name="Agent", llm_config=llm_config, human_input_mode="NEVER",
)
agent1 = ConversableAgent(
name="Agent1",llm_config=llm_config,human_input_mode="NEVER",
)
agent.register_nested_chats(
[{ "recipient": agent1,"max_turns": 1 }],
trigger=lambda sender: sender not in [agent1, agent2],
)
r = agent.generate_reply([
{ "role": "user","content": "hi,what's your name?"},
{"role": "system","content": "my name is agent"},
{"role": "user","content": "what's your name?"},
])
print(r)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The document describes that nested chat is a powerful conversation pattern that allows you to package complex workflows into a single agent.
I'm a bit confused about the nested chat design. The nested chat is implemented by registering the reply_func_from_nested_chats method. In this method, only the last_msg is used to initialize a new chat, causing the loss of other chat history. I feel that this is not consistent with the design of the generate_reply method, which accepts a message list.
If I want to inject some context before the conversation, it won't work.
_summary_from_nested_chats should handle the message list, right? or something i'm wrong?
Beta Was this translation helpful? Give feedback.
All reactions