forked from phoenix/litellm-mirror
fix(router.py): add more debug logs
This commit is contained in:
parent
e23c68b15a
commit
2f1899284c
2 changed files with 14 additions and 5 deletions
|
@ -294,11 +294,17 @@ class Router:
|
||||||
"""
|
"""
|
||||||
returns a copy of the deployment with the api key masked
|
returns a copy of the deployment with the api key masked
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
_deployment_copy = copy.deepcopy(deployment)
|
_deployment_copy = copy.deepcopy(deployment)
|
||||||
litellm_params: dict = _deployment_copy["litellm_params"]
|
litellm_params: dict = _deployment_copy["litellm_params"]
|
||||||
if "api_key" in litellm_params:
|
if "api_key" in litellm_params:
|
||||||
litellm_params["api_key"] = litellm_params["api_key"][:2] + "*" * 10
|
litellm_params["api_key"] = litellm_params["api_key"][:2] + "*" * 10
|
||||||
return _deployment_copy
|
return _deployment_copy
|
||||||
|
except Exception as e:
|
||||||
|
verbose_router_logger.debug(
|
||||||
|
f"Error occurred while printing deployment - {str(e)}"
|
||||||
|
)
|
||||||
|
raise e
|
||||||
|
|
||||||
### COMPLETION, EMBEDDING, IMG GENERATION FUNCTIONS
|
### COMPLETION, EMBEDDING, IMG GENERATION FUNCTIONS
|
||||||
|
|
||||||
|
@ -310,6 +316,7 @@ class Router:
|
||||||
response = router.completion(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hey, how's it going?"}]
|
response = router.completion(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hey, how's it going?"}]
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
verbose_router_logger.debug(f"router.completion(model={model},..)")
|
||||||
kwargs["model"] = model
|
kwargs["model"] = model
|
||||||
kwargs["messages"] = messages
|
kwargs["messages"] = messages
|
||||||
kwargs["original_function"] = self._completion
|
kwargs["original_function"] = self._completion
|
||||||
|
|
|
@ -148,6 +148,7 @@ class LowestTPMLoggingHandler(CustomLogger):
|
||||||
input_tokens = token_counter(messages=messages, text=input)
|
input_tokens = token_counter(messages=messages, text=input)
|
||||||
except:
|
except:
|
||||||
input_tokens = 0
|
input_tokens = 0
|
||||||
|
verbose_router_logger.debug(f"input_tokens={input_tokens}")
|
||||||
# -----------------------
|
# -----------------------
|
||||||
# Find lowest used model
|
# Find lowest used model
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
@ -209,4 +210,5 @@ class LowestTPMLoggingHandler(CustomLogger):
|
||||||
elif item_tpm < lowest_tpm:
|
elif item_tpm < lowest_tpm:
|
||||||
lowest_tpm = item_tpm
|
lowest_tpm = item_tpm
|
||||||
deployment = _deployment
|
deployment = _deployment
|
||||||
|
verbose_router_logger.info(f"returning picked lowest tpm/rpm deployment.")
|
||||||
return deployment
|
return deployment
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue