Litellm dev 01 02 2025 p1 (#7516)

* fix(redact_messages.py): fix redact messages for non-model response input to be dictionary

fixes issue with otel logging when message redaction is enabled

* fix(proxy_server.py): fix langfuse key leak in exception string

* test: fix test

* test: fix test

* test: fix tests
This commit is contained in:
Krish Dholakia 2025-01-03 14:40:57 -08:00 • committed by GitHub
parent fb59f20979
commit 33f301ec86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 22 deletions

View file

@ -70,7 +70,7 @@ def perform_redaction(model_call_details: dict, result):
choice.delta.content = "redacted-by-litellm"
return _result
else:
return "redacted-by-litellm"
return {"text": "redacted-by-litellm"}
def redact_message_input_output_from_logging(

View file

@ -1,5 +1,5 @@
model_list:
- model_name: openai/gpt-3.5-turbo
- model_name: azure-embedding-model
litellm_params:
model: openai/gpt-3.5-turbo
api_key: os.environ/OPENAI_API_KEY
@ -12,16 +12,4 @@ model_list:
prompt_id: "jokes"
litellm_settings:
default_team_settings:
- team_id: "team_1"
success_callback: ["langfuse"]
failure_callback: ["langfuse"]
langfuse_public_key: os.environ/LANGFUSE_PUBLIC_KEY
langfuse_secret: os.environ/LANGFUSE_SECRET_KEY
langfuse_host: os.environ/LANGFUSE_HOST
- team_id: "team_2"
success_callback: ["langfuse"]
failure_callback: ["langfuse"]
langfuse_public_key: os.environ/LANGFUSE_PROJECT3_PUBLIC
langfuse_secret: os.environ/LANGFUSE_PROJECT3_SECRET
langfuse_host: os.environ/LANGFUSE_HOST
callbacks: ["otel"]

View file

@ -1862,8 +1862,12 @@ class ProxyConfig:
try:
TeamDefaultSettings(**team_setting)
except Exception:
if isinstance(team_setting, dict):
raise Exception(
f"team_id missing from default_team_settings at index={idx}\npassed in value={team_setting.keys()}"
)
raise Exception(
f"team_id missing from default_team_settings at index={idx}\npassed in value={team_setting}"
f"team_id missing from default_team_settings at index={idx}\npassed in value={type(team_setting)}"
)
verbose_proxy_logger.debug(
f"{blue_color_code} setting litellm.{key}={value}{reset_color_code}"

View file

@ -1264,7 +1264,7 @@ def test_standard_logging_payload(model, turn_off_message_logging):
if turn_off_message_logging:
print("checks redacted-by-litellm")
assert "redacted-by-litellm" == slobject["messages"][0]["content"]
assert "redacted-by-litellm" == slobject["response"]
assert {"text": "redacted-by-litellm"} == slobject["response"]
@pytest.mark.parametrize(
@ -1358,7 +1358,7 @@ def test_standard_logging_payload_audio(turn_off_message_logging, stream):
if turn_off_message_logging:
print("checks redacted-by-litellm")
assert "redacted-by-litellm" == slobject["messages"][0]["content"]
assert "redacted-by-litellm" == slobject["response"]
assert {"text": "redacted-by-litellm"} == slobject["response"]
@pytest.mark.skip(reason="Works locally. Flaky on ci/cd")
@ -1467,7 +1467,9 @@ def test_logging_async_cache_hit_sync_call(turn_off_message_logging):
"redacted-by-litellm"
== standard_logging_object["messages"][0]["content"]
)
assert "redacted-by-litellm" == standard_logging_object["response"]
assert {"text": "redacted-by-litellm"} == standard_logging_object[
"response"
]
def test_logging_standard_payload_failure_call():

View file

@ -45,7 +45,7 @@ async def test_global_redaction_on():
await asyncio.sleep(1)
standard_logging_payload = test_custom_logger.logged_standard_logging_payload
assert standard_logging_payload is not None
assert standard_logging_payload["response"] == "redacted-by-litellm"
assert standard_logging_payload["response"] == {"text": "redacted-by-litellm"}
assert standard_logging_payload["messages"][0]["content"] == "redacted-by-litellm"
print(
"logged standard logging payload",
@ -75,7 +75,7 @@ async def test_global_redaction_with_dynamic_params(turn_off_message_logging):
)
if turn_off_message_logging is True:
assert standard_logging_payload["response"] == "redacted-by-litellm"
assert standard_logging_payload["response"] == {"text": "redacted-by-litellm"}
assert (
standard_logging_payload["messages"][0]["content"] == "redacted-by-litellm"
)
@ -108,7 +108,7 @@ async def test_global_redaction_off_with_dynamic_params(turn_off_message_logging
json.dumps(standard_logging_payload, indent=2),
)
if turn_off_message_logging is True:
assert standard_logging_payload["response"] == "redacted-by-litellm"
assert standard_logging_payload["response"] == {"text": "redacted-by-litellm"}
assert (
standard_logging_payload["messages"][0]["content"] == "redacted-by-litellm"
)