Skip to content

Allow initiate_chat without passing message #1244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ def initiate_chat(
silent (bool or None): (Experimental) whether to print the messages for this conversation.
**context: any context information.
"message" needs to be provided if the `generate_init_message` method is not overridden.
Otherwise, input() will be called to get the initial message.

Raises:
RuntimeError: if any async reply functions are registered and not ignored in sync chat.
Expand Down Expand Up @@ -685,6 +686,7 @@ async def a_initiate_chat(
silent (bool or None): (Experimental) whether to print the messages for this conversation.
**context: any context information.
"message" needs to be provided if the `generate_init_message` method is not overridden.
Otherwise, input() will be called to get the initial message.
"""
self._prepare_chat(recipient, clear_history)
await self.a_send(self.generate_init_message(**context), recipient, silent=silent)
Expand Down Expand Up @@ -1564,7 +1566,10 @@ def generate_init_message(self, **context) -> Union[str, Dict]:

Args:
**context: any context information, and "message" parameter needs to be provided.
If message is not given, prompt for it via input()
"""
if "message" not in context:
context["message"] = self.get_human_input(">")
return context["message"]

def register_function(self, function_map: Dict[str, Callable]):
Expand Down