forked from phoenix/litellm-mirror
fix: Minor LiteLLM Fixes + Improvements (29/08/2024) (#5436)
* fix(model_checks.py): support returning wildcard models on `/v1/models` Fixes https://github.com/BerriAI/litellm/issues/4903 * fix(bedrock_httpx.py): support calling bedrock via api_base Closes https://github.com/BerriAI/litellm/pull/4587 * fix(litellm_logging.py): only leave last 4 char of gemini key unmasked Fixes https://github.com/BerriAI/litellm/issues/5433 * feat(router.py): support setting 'weight' param for models on router Closes https://github.com/BerriAI/litellm/issues/5410 * test(test_bedrock_completion.py): add unit test for custom api base * fix(model_checks.py): handle no "/" in model
This commit is contained in:
parent
f70b7575d2
commit
dd7b008161
12 changed files with 219 additions and 25 deletions
|
@ -1347,3 +1347,33 @@ def test_logging_async_cache_hit_sync_call():
|
|||
assert standard_logging_object["cache_hit"] is True
|
||||
assert standard_logging_object["response_cost"] == 0
|
||||
assert standard_logging_object["saved_cache_cost"] > 0
|
||||
|
||||
|
||||
def test_logging_key_masking_gemini():
|
||||
customHandler = CompletionCustomHandler()
|
||||
litellm.callbacks = [customHandler]
|
||||
litellm.success_callback = []
|
||||
|
||||
with patch.object(
|
||||
customHandler, "log_pre_api_call", new=MagicMock()
|
||||
) as mock_client:
|
||||
try:
|
||||
resp = litellm.completion(
|
||||
model="gemini/gemini-1.5-pro",
|
||||
messages=[{"role": "user", "content": "Hey, how's it going?"}],
|
||||
api_key="LEAVE_ONLY_LAST_4_CHAR_UNMASKED_THIS_PART",
|
||||
)
|
||||
except litellm.AuthenticationError:
|
||||
pass
|
||||
|
||||
mock_client.assert_called()
|
||||
|
||||
print(f"mock_client.call_args.kwargs: {mock_client.call_args.kwargs}")
|
||||
assert (
|
||||
"LEAVE_ONLY_LAST_4_CHAR_UNMASKED_THIS_PART"
|
||||
not in mock_client.call_args.kwargs["kwargs"]["litellm_params"]["api_base"]
|
||||
)
|
||||
key = mock_client.call_args.kwargs["kwargs"]["litellm_params"]["api_base"]
|
||||
trimmed_key = key.split("key=")[1]
|
||||
trimmed_key = trimmed_key.replace("*", "")
|
||||
assert "PART" == trimmed_key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue