mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-13 03:59:12 +00:00
style(responses): extract cache_control into a named variable, trim comment
Per style review: the message-building branch read cache_control 3 different ways in 5 lines (.get() twice, then [] indexing once), unlike the sibling tool-call-output/function-call functions this PR touches, which each extract it into a named variable up front (output_cache_control, function_call_cache_control). Matched that convention here too. Also trimmed the 3-line inline comment to one line, matching the file's usual comment length for similarly subtle behavior.
This commit is contained in:
parent
3aacde577f
commit
77aa69cb2b
1 changed files with 5 additions and 6 deletions
|
|
@ -1427,15 +1427,14 @@ class LiteLLMCompletionResponsesConfig:
|
|||
content
|
||||
),
|
||||
)
|
||||
if input_item.get("cache_control"):
|
||||
msg["cache_control"] = input_item.get("cache_control")
|
||||
# Also propagate to the last content element for providers
|
||||
# that read cache_control from content blocks (Anthropic, Bedrock),
|
||||
# unless that block already carries its own cache_control.
|
||||
input_item_cache_control = input_item.get("cache_control")
|
||||
if input_item_cache_control:
|
||||
msg["cache_control"] = input_item_cache_control
|
||||
# Also set on the last content block for providers (Anthropic, Bedrock) that read cache_control there.
|
||||
if isinstance(msg["content"], list) and len(msg["content"]) > 0:
|
||||
last_element = msg["content"][-1]
|
||||
if isinstance(last_element, dict) and "cache_control" not in last_element:
|
||||
last_element["cache_control"] = input_item["cache_control"]
|
||||
last_element["cache_control"] = input_item_cache_control
|
||||
return [msg]
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue