mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
fix(proxy_track_cost_callback.py): add debug logging for track cost callback error
This commit is contained in:
parent
d171ac624c
commit
c852004b7a
2 changed files with 28 additions and 2 deletions
|
@ -199,9 +199,13 @@ class _ProxyDBLogger(CustomLogger):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = f"Error in tracking cost callback - {str(e)}\n Traceback:{traceback.format_exc()}"
|
error_msg = f"Error in tracking cost callback - {str(e)}\n Traceback:{traceback.format_exc()}"
|
||||||
model = kwargs.get("model", "")
|
model = kwargs.get("model", "")
|
||||||
metadata = kwargs.get("litellm_params", {}).get("metadata", {})
|
metadata = get_litellm_metadata_from_kwargs(kwargs=kwargs)
|
||||||
|
litellm_metadata = kwargs.get("litellm_params", {}).get(
|
||||||
|
"litellm_metadata", {}
|
||||||
|
)
|
||||||
|
old_metadata = kwargs.get("litellm_params", {}).get("metadata", {})
|
||||||
call_type = kwargs.get("call_type", "")
|
call_type = kwargs.get("call_type", "")
|
||||||
error_msg += f"\n Args to _PROXY_track_cost_callback\n model: {model}\n metadata: {metadata}\n call_type: {call_type}\n"
|
error_msg += f"\n Args to _PROXY_track_cost_callback\n model: {model}\n chosen_metadata: {metadata}\n litellm_metadata: {litellm_metadata}\n old_metadata: {old_metadata}\n call_type: {call_type}\n"
|
||||||
asyncio.create_task(
|
asyncio.create_task(
|
||||||
proxy_logging_obj.failed_tracking_alert(
|
proxy_logging_obj.failed_tracking_alert(
|
||||||
error_message=error_msg,
|
error_message=error_msg,
|
||||||
|
|
22
tests/litellm/litellm_core_utils/test_core_helpers.py
Normal file
22
tests/litellm/litellm_core_utils/test_core_helpers.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
sys.path.insert(
|
||||||
|
0, os.path.abspath("../../..")
|
||||||
|
) # Adds the parent directory to the system path
|
||||||
|
|
||||||
|
from litellm.litellm_core_utils.core_helpers import get_litellm_metadata_from_kwargs
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_litellm_metadata_from_kwargs():
|
||||||
|
kwargs = {
|
||||||
|
"litellm_params": {
|
||||||
|
"litellm_metadata": {},
|
||||||
|
"metadata": {"user_api_key": "1234567890"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert get_litellm_metadata_from_kwargs(kwargs) == {"user_api_key": "1234567890"}
|
Loading…
Add table
Add a link
Reference in a new issue