Skip to content
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

Makes select_speaker more robust by checking for mentions anywhere. #669

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

afourney
Copy link
Member

@afourney afourney commented Nov 13, 2023

Makes select_speaker more robust by checking for agent name mentions anywhere in the string returned by the LLM.

Why are these changes needed?

Selecting the speaker fails when the LLM returns anything other than an exact agent name.

Related issue number

Closes #663, and perhaps a few others.

Edit: I just saw #668, which is a different problem, but might be related?

Checks

…where in the selection string. Addresses 663.
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (d340159) 28.89% compared to head (682ce31) 37.36%.

Files Patch % Lines
autogen/agentchat/groupchat.py 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #669      +/-   ##
==========================================
+ Coverage   28.89%   37.36%   +8.46%     
==========================================
  Files          27       27              
  Lines        3395     3407      +12     
  Branches      764      767       +3     
==========================================
+ Hits          981     1273     +292     
+ Misses       2342     2017     -325     
- Partials       72      117      +45     
Flag Coverage Δ
unittests 37.30% <75.00%> (+8.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BeibinLi BeibinLi self-requested a review November 13, 2023 22:28
Copy link
Collaborator

@BeibinLi BeibinLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me.

I made a suggestion to use "set", but feel free to ignore it.

autogen/agentchat/groupchat.py Show resolved Hide resolved
@afourney
Copy link
Member Author

Thanks. I'm happy either way, but personally find complex list compressions take longer to read/understand. If it's all the same to you, I'd rather just leave it step by step.

Copy link
Collaborator

@sonichi sonichi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to cover the changed function?

autogen/agentchat/groupchat.py Outdated Show resolved Hide resolved
@sonichi sonichi requested a review from a team November 16, 2023 13:48
@afourney
Copy link
Member Author

Could you add a test to cover the changed function?

Yes done. To test this effectively, I needed to separate some of the logic out as a helper function

@qingyun-wu qingyun-wu added this pull request to the merge queue Nov 17, 2023
Merged via the queue into main with commit f939dda Nov 17, 2023
52 of 58 checks passed
) # Finds agent mentions, taking word boundaries into account
count = len(re.findall(regex, " " + message_content + " ")) # Pad the message to help with matching
if count > 0:
mentions[agent.name] = count
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early stop is still applicable here.

@sonichi sonichi deleted the group_chat_663 branch November 17, 2023 13:43
whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
…icrosoft#669)

* Makes select_speaker more robust by checking for agents mentioned anywhere in the selection string. Addresses 663.

* Added test coverage for group chat mentions. Refactored mention counter to own function.

* Fixed pre-commit formatting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group chat group-chat-related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GroupChat is overly sensitive to formatting when selecting the next speaker.
5 participants