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

[Bug]: Multiple Custom TransformMessages not chained #2638

Closed
WebsheetPlugin opened this issue May 9, 2024 · 2 comments
Closed

[Bug]: Multiple Custom TransformMessages not chained #2638

WebsheetPlugin opened this issue May 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@WebsheetPlugin
Copy link
Collaborator

WebsheetPlugin commented May 9, 2024

Describe the bug

transform_messages.TransformMessages(transforms=[RedactA(), RedactB()])

I would expect RedactB to be based on messages returned from RedactA. But this seems not to be the case.

Steps to reproduce

from autogen.agentchat.contrib.capabilities import transform_messages, transforms

class RedactA:
    def __init__(self):
        pass

    def apply_transform(self, messages: List[Dict]) -> List[Dict]:
        temp_messages = copy.deepcopy(messages)
        temp_messages[0]['content'] = "What is the capital of Poland?"
        return temp_messages
    
    def get_logs(self, pre_transform_messages: List[Dict], post_transform_messages: List[Dict]) -> Tuple[str, bool]:
        return "transormed emails", True

class RedactB:
    def __init__(self):
        pass

    def apply_transform(self, messages: List[Dict]) -> List[Dict]:
        temp_messages = copy.deepcopy(messages)
        temp_messages[0]['content'].replace("Poland", "France")
        return temp_messages
    
    def get_logs(self, pre_transform_messages: List[Dict], post_transform_messages: List[Dict]) -> Tuple[str, bool]:
        return "transormed picker", True

REDACT_PICKER_HANDLING = transform_messages.TransformMessages(transforms=[RedactA(), RedactB()])


TWO_REDACT = transform_messages.TransformMessages(transforms=[RedactA(), RedactB()])

Create two custom redact functions according to the tutorial for TransformMessages and apply them like the above. After asking a user question I would expect to get from the chat answer Paris, but because they seem to be not chained it returns Warsaw.

Model Used

No response

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

v27.

@WebsheetPlugin
Copy link
Collaborator Author

Sorry, my mistake. All seems to work.

@WaelKarkoub
Copy link
Contributor

@WebsheetPlugin that's actually a great test to add, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants