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]: Transformations Printing #2307

Closed
giorgossideris opened this issue Apr 6, 2024 · 1 comment · Fixed by #2308
Closed

[Bug]: Transformations Printing #2307

giorgossideris opened this issue Apr 6, 2024 · 1 comment · Fixed by #2308

Comments

@giorgossideris
Copy link
Contributor

Describe the bug

The MessageTokenLimiter prints the number of tokens truncated, while the MessageHistoryLimiter doesn't print the number of messages removed. Also, the TransformMessages._print_stats method isn't working.

Steps to reproduce

Execute the following code:

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

messages = [
    {"role": "user", "content": "hello"},
    {"role": "assistant", "content": [{"type": "text", "text": "there"}]},
    {"role": "user", "content": "how"},
    {"role": "assistant", "content": [{"type": "text", "text": "are you doing?"}]},
    {"role": "user", "content": "very very very very very very long string"},
]


context_handling = transform_messages.TransformMessages(
    transforms=[
        transforms.MessageHistoryLimiter(max_messages=3),
        transforms.MessageTokenLimiter(max_tokens=1000, max_tokens_per_message=3),
    ],
)

context_handling._transform_messages(messages)

(code based on #2247)

Model Used

No model used

Expected Behavior

To print the stats for all transformations, or not at all.

Screenshots and logs

No response

Additional Information

The TransformMessages._print_stats problem is caused by the fact that: if pre_transform_messages_len < post_transform_messages_len: should be if post_transform_messages_len < pre_transform_messages_len:

@giorgossideris
Copy link
Contributor Author

I will open a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant