Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Workaround for system messages that contain a list of dicts #1214

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Mar 4, 2025

In the litellm ChatCompletionMessage that we use a system message is
defined as follows:

class OpenAIChatCompletionSystemMessage(TypedDict, total=False):
    role: Required[Literal["system"]]
    content: Required[Union[str, List]]
    name: str

So content can either be a string or a list. Our secret encryption code only
handled the string case. Since both cases will properly be handled by the
soon-to-be-coming rewrite, let's just add a workaround so that e.g. Cline with
Anthropic keeps working.

With the no-more-litellm branch, everything works as expected.

Fixes: #1207

In the litellm `ChatCompletionMessage` that we use a system message is
defined as follows:
```
class OpenAIChatCompletionSystemMessage(TypedDict, total=False):
    role: Required[Literal["system"]]
    content: Required[Union[str, List]]
    name: str
```

So content can either be a string or a list. Our secret encryption code only
handled the string case. Since both cases will properly be handled by the
soon-to-be-coming rewrite, let's just add a workaround so that e.g. Cline with
Anthropic keeps working.

With the no-more-litellm branch, everything works as expected.

Fixes: #1207
@jhrozek jhrozek merged commit 599d8f6 into main Mar 5, 2025
11 checks passed
@jhrozek jhrozek deleted the anthropic_system_message_format branch March 5, 2025 08:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cline with anthropic is broken on main
2 participants