From d7563635a074e0978c2282b8a948b83383f79a23 Mon Sep 17 00:00:00 2001 From: Paul Swingle Date: Thu, 25 Jul 2024 15:02:03 -0700 Subject: [PATCH] fix pyright --- spice/wrapped_clients.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spice/wrapped_clients.py b/spice/wrapped_clients.py index b8e03fa..2944861 100644 --- a/spice/wrapped_clients.py +++ b/spice/wrapped_clients.py @@ -223,7 +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) - messages = [m for m in messages if m.get("content", "").strip()] + 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] = []