Skip to content

Commit

Permalink
Re-query speaker name when multiple speaker names returned during Gro…
Browse files Browse the repository at this point in the history
…up Chat speaker selection (microsoft#2304)

* Added requery_on_multiple_speaker_names to GroupChat and updated _finalize_speaker to requery on multiple speaker names (if enabled)

* Removed unnecessary comments

* Update to current main

* Tweak error message.

* Comment clarity

* Expanded description of Group Chat requery_on_multiple_speaker_names

* Reworked to two-way nested chat for speaker selection with default of 2 retries.

* Adding validation of new GroupChat attributes

* Updates as per @ekzhu's suggestions

* Update groupchat

- Added select_speaker_auto_multiple_template and select_speaker_auto_none_template
- Added max_attempts comment
- Re-instated support for role_for_select_speaker_messages
-

* Update conversable_agent.py

Added ability to force override role for a message to support select speaker prompt.

* Update test_groupchat.py

Updated existing select_speaker test functions as underlying approach has changed, added necessary tests for new functionality.

* Removed block for manual selection in select_speaker function.

* Catered for no-selection during manual selection mode

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
  • Loading branch information
marklysze and sonichi authored Apr 30, 2024
1 parent 1207c49 commit ec81f87
Show file tree
Hide file tree
Showing 3 changed files with 732 additions and 32 deletions.
5 changes: 5 additions & 0 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ def _append_oai_message(self, message: Union[Dict, str], role, conversation_id:

if message.get("role") in ["function", "tool"]:
oai_message["role"] = message.get("role")
elif "override_role" in message:
# If we have a direction to override the role then set the
# role accordingly. Used to customise the role for the
# select speaker prompt.
oai_message["role"] = message.get("override_role")
else:
oai_message["role"] = role

Expand Down
Loading

0 comments on commit ec81f87

Please sign in to comment.