mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-15 04:19:08 +00:00
docs: clarify _as_system_content_blocks fallback behavior
Addresses Greptile review comment on PR #31452: document that non-str/ list/dict values falling through to a bare wrap is intentional, since callers are expected to validate content against the Anthropic message schema before this normalization step runs.
This commit is contained in:
parent
d62b001f2f
commit
fa4fa17c2e
1 changed files with 9 additions and 1 deletions
|
|
@ -100,7 +100,15 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig):
|
|||
|
||||
@staticmethod
|
||||
def _as_system_content_blocks(value: Any) -> list:
|
||||
"""Convert system content to a list of content blocks."""
|
||||
"""Convert system content to a list of content blocks.
|
||||
|
||||
A bare ``dict`` (e.g. ``{"type": "text", "text": "..."}``) is treated as
|
||||
a single content block shorthand and wrapped as-is — Anthropic's API
|
||||
accepts this shape directly. Any other non-``None``/``str``/``list``/
|
||||
``dict`` value (e.g. an int) is also passed through unchanged; callers
|
||||
are expected to have already validated ``content`` against the
|
||||
Anthropic message schema upstream of this normalization step.
|
||||
"""
|
||||
if value is None:
|
||||
return []
|
||||
if isinstance(value, list):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue