mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
fix: changes after review
This commit is contained in:
parent
77b24862ba
commit
a23f13a645
2 changed files with 5 additions and 5 deletions
|
|
@ -15,7 +15,7 @@ from pydantic import (
|
|||
|
||||
class CacheControl(BaseModel):
|
||||
type: Literal["ephemeral"]
|
||||
ttl: str | None = None
|
||||
ttl: Literal["5m", "1h"] | None = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def _serialize(
|
||||
|
|
|
|||
|
|
@ -73,18 +73,18 @@ def _fold_message_cache_control(
|
|||
breakpoint for the whole block. In all other cases (empty list, None,
|
||||
unrecognized type) the marker is silently dropped.
|
||||
"""
|
||||
cc = message.get("cache_control")
|
||||
if cc is None:
|
||||
cache_control = message.get("cache_control")
|
||||
if cache_control is None:
|
||||
return message
|
||||
base = {k: v for k, v in message.items() if k != "cache_control"}
|
||||
content = message.get("content")
|
||||
if isinstance(content, str):
|
||||
base["content"] = [{"type": "text", "text": content, "cache_control": cc}]
|
||||
base["content"] = [{"type": "text", "text": content, "cache_control": cache_control}]
|
||||
return base
|
||||
if isinstance(content, list) and content and isinstance(content[-1], dict):
|
||||
base["content"] = [
|
||||
*content[:-1],
|
||||
{**content[-1], "cache_control": cc},
|
||||
{**content[-1], "cache_control": cache_control},
|
||||
]
|
||||
return base
|
||||
return base
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue