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

get rid of empty messages #95

Merged
merged 2 commits into from
Jul 25, 2024
Merged

get rid of empty messages #95

merged 2 commits into from
Jul 25, 2024

Conversation

PCSwingle
Copy link
Member

No description provided.

Copy link
Contributor

@mentatai mentatai bot left a comment

Choose a reason for hiding this comment

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

This pull request makes a small but important change to the _convert_messages method in the WrappedAnthropicClient class. It filters out empty messages before processing, which is a good practice to prevent potential issues when interacting with the Anthropic API. The change is straightforward and doesn't introduce any obvious bugs or issues. It's a sensible improvement to the code's robustness.

Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!

@@ -223,6 +223,7 @@ def _convert_messages(
) -> Tuple[str, List[MessageParam]]:
# Anthropic handles both images and system messages different from OpenAI, only allows alternating user / assistant messages,
# and doesn't support tools / function calling (still in beta, and doesn't support streaming)
messages = [m for m in messages if m.get("content", "").strip()]
Copy link
Contributor

Choose a reason for hiding this comment

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

Good addition. This line filters out empty messages, which can cause issues with some LLM APIs. It's a proactive approach to prevent potential errors.

@PCSwingle PCSwingle merged commit 18ef2a5 into main Jul 25, 2024
2 checks passed
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 this pull request may close these issues.

1 participant