From 12f85266f040ab645eeacaab1c66fdf17fc986a3 Mon Sep 17 00:00:00 2001 From: Paul Swingle Date: Fri, 27 Sep 2024 14:42:41 -0700 Subject: [PATCH] pyright --- pyproject.toml | 4 ++-- spice/wrapped_clients.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1372a75..dc1c0ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,8 @@ dependencies = [ "pillow", "tiktoken", "httpx", - "jinja2" + "jinja2", + "termcolor", ] [project.optional-dependencies] @@ -32,5 +33,4 @@ dev = [ "pyright", "pytest", "pytest-asyncio", - "termcolor", ] diff --git a/spice/wrapped_clients.py b/spice/wrapped_clients.py index 7f36017..bcf3cfa 100644 --- a/spice/wrapped_clients.py +++ b/spice/wrapped_clients.py @@ -120,7 +120,7 @@ def __init__(self, key, base_url=None): self._client = AsyncOpenAI(api_key=key, base_url=base_url) def _convert_messages(self, messages: Collection[SpiceMessage]) -> List[ChatCompletionMessageParam]: - converted_messages: List[ChatCompletionMessageParam] = [] + converted_messages = [] for message in messages: content_part = _spice_message_to_openai_content_part(message) if ( @@ -128,7 +128,7 @@ def _convert_messages(self, messages: Collection[SpiceMessage]) -> List[ChatComp and converted_messages[-1]["role"] == message.role and ( ("name" in converted_messages[-1]) == (message.name is not None) - and (message.name is None or message.name == converted_messages[-1]["name"]) + and ("name" not in converted_messages[-1] or message.name == converted_messages[-1]["name"]) ) ): converted_messages[-1]["content"].append(content_part)