Skip to content

Commit

Permalink
Merge pull request #95 from AbanteAI/anthropic-empty-messages
Browse files Browse the repository at this point in the history
get rid of empty messages
  • Loading branch information
PCSwingle authored Jul 25, 2024
2 parents 19a0df7 + d756363 commit 18ef2a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spice/wrapped_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ 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)
new_messages = []
for m in messages:
content = m.get("content", "")
if (not isinstance(content, str)) or content.strip():
new_messages.append(m)
messages = new_messages

system = ""
converted_messages: List[MessageParam] = []
Expand Down

0 comments on commit 18ef2a5

Please sign in to comment.