mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(logging): keep logging empty string system prompts
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
8bdd61bdea
commit
1356309ee9
2 changed files with 5 additions and 3 deletions
|
|
@ -4549,7 +4549,7 @@ class StandardLoggingPayloadSetup:
|
|||
if kwargs is None:
|
||||
return messages
|
||||
system: Final = kwargs.get("system")
|
||||
if not system or not isinstance(system, (str, list)):
|
||||
if not isinstance(system, (str, list)) or (isinstance(system, list) and not system):
|
||||
return messages
|
||||
system_message: Final = {"role": "system", "content": system}
|
||||
if messages is None:
|
||||
|
|
|
|||
|
|
@ -2261,16 +2261,18 @@ def test_append_system_prompt_messages_content_blocks():
|
|||
)
|
||||
assert result == [{"role": "system", "content": system_blocks}, *messages]
|
||||
|
||||
# already-prepended system blocks are not duplicated
|
||||
result = StandardLoggingPayloadSetup.append_system_prompt_messages(
|
||||
kwargs={"system": system_blocks}, messages=result
|
||||
)
|
||||
assert len(result) == 2
|
||||
|
||||
# empty system is not logged as an empty system turn
|
||||
assert (
|
||||
StandardLoggingPayloadSetup.append_system_prompt_messages(kwargs={"system": []}, messages=messages) == messages
|
||||
)
|
||||
assert StandardLoggingPayloadSetup.append_system_prompt_messages(kwargs={"system": ""}, messages=messages) == [
|
||||
{"role": "system", "content": ""},
|
||||
*messages,
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue