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

Ignore Some Messages When Transforming #2661

Merged
merged 10 commits into from May 22, 2024
Merged

Conversation

WaelKarkoub
Copy link
Collaborator

Why are these changes needed?

This PR implements some utilities that can be useful when applying TransformMessages to GroupChatManager. This is also part 1 of 2.

The changes in this PR allow specific messages to be included or excluded during the transformation process based on user-defined criteria.

  • filter_configs was improved so the user can have finer control when filtering configs. If the user decides to exclude=False (default), then whichever config matches the filter_dict will be returned (the behavior that is currently in main). If exclude=True then the opposite happens; whichever config matches the filter_dict will be excluded from the final result.

  • Some transforms like TextMessageCompressor and MessageTokenLimiter can use the filter_dict concept present in autogen to ignore some messages from being transformed.

Example:

  • Let us say we want to ignore all system messages from being compressed, we can pass in a filter_dict={"role": ["system"]}, exclude=True.
  • How about when we want to compress messages that only come from a specific agent, filter_dict={"name": ["compress_me_agent"]}, exclude=False.

Future Work:

  • PrefixName transform: Prepends every message with a text template, e.g. "The agent {agent_name} said this:". It is useful when API providers don't use the name key in the message.
  • FilterMessage: Drops all messages based on the filter_dict you pass in. E.g. we want to drop all system messages from the context.

Related issue number

Checks

@ekzhu ekzhu added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit 4ebfb82 May 22, 2024
79 of 93 checks passed
@ekzhu ekzhu deleted the ignore-transforming-conditions branch May 22, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants