forked from phoenix/litellm-mirror
(fix) stop using f strings with logger
This commit is contained in:
parent
dad4bd58bc
commit
5d121a9f3c
6 changed files with 29 additions and 27 deletions
|
@ -60,7 +60,7 @@ class _ENTERPRISE_LLMGuard(CustomLogger):
|
|||
else:
|
||||
# Make the first request to /analyze
|
||||
analyze_url = f"{self.llm_guard_api_base}analyze/prompt"
|
||||
verbose_proxy_logger.debug(f"Making request to: {analyze_url}")
|
||||
verbose_proxy_logger.debug("Making request to: %s", analyze_url)
|
||||
analyze_payload = {"prompt": text}
|
||||
redacted_text = None
|
||||
async with session.post(
|
||||
|
|
|
@ -150,7 +150,7 @@ class JWTHandler:
|
|||
|
||||
header = jwt.get_unverified_header(token)
|
||||
|
||||
verbose_proxy_logger.debug(f"header: {header}")
|
||||
verbose_proxy_logger.debug("header: %s", header)
|
||||
|
||||
if "kid" in header:
|
||||
kid = header["kid"]
|
||||
|
|
|
@ -93,7 +93,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomLogger):
|
|||
else:
|
||||
# Make the first request to /analyze
|
||||
analyze_url = f"{self.presidio_analyzer_api_base}analyze"
|
||||
verbose_proxy_logger.debug(f"Making request to: {analyze_url}")
|
||||
verbose_proxy_logger.debug("Making request to: %s", analyze_url)
|
||||
analyze_payload = {"text": text, "language": "en"}
|
||||
if self.ad_hoc_recognizers is not None:
|
||||
analyze_payload["ad_hoc_recognizers"] = self.ad_hoc_recognizers
|
||||
|
@ -105,7 +105,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomLogger):
|
|||
|
||||
# Make the second request to /anonymize
|
||||
anonymize_url = f"{self.presidio_anonymizer_api_base}anonymize"
|
||||
verbose_proxy_logger.debug(f"Making request to: {anonymize_url}")
|
||||
verbose_proxy_logger.debug("Making request to: %s", anonymize_url)
|
||||
anonymize_payload = {
|
||||
"text": text,
|
||||
"analyzer_results": analyze_results,
|
||||
|
@ -118,7 +118,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomLogger):
|
|||
|
||||
new_text = text
|
||||
if redacted_text is not None:
|
||||
verbose_proxy_logger.debug(f"redacted_text: {redacted_text}")
|
||||
verbose_proxy_logger.debug("redacted_text: %s", redacted_text)
|
||||
for item in redacted_text["items"]:
|
||||
start = item["start"]
|
||||
end = item["end"]
|
||||
|
@ -172,7 +172,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomLogger):
|
|||
no_pii = not permissions.get("pii", True)
|
||||
|
||||
content_safety = data.get("content_safety", None)
|
||||
verbose_proxy_logger.debug(f"content_safety: {content_safety}")
|
||||
verbose_proxy_logger.debug("content_safety: %s", content_safety)
|
||||
## Request-level turn on/off PII controls ##
|
||||
if content_safety is not None and isinstance(content_safety, dict):
|
||||
# pii masking ##
|
||||
|
@ -240,7 +240,9 @@ class _OPTIONAL_PresidioPIIMasking(CustomLogger):
|
|||
)
|
||||
return data
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.info(f"An error occurred - {str(e)}")
|
||||
verbose_proxy_logger.info(
|
||||
f"An error occurred -",
|
||||
)
|
||||
raise e
|
||||
|
||||
async def async_post_call_success_hook(
|
||||
|
|
|
@ -361,7 +361,7 @@ async def user_api_key_auth(
|
|||
route: str = request.url.path
|
||||
if general_settings.get("enable_jwt_auth", False) == True:
|
||||
is_jwt = jwt_handler.is_jwt(token=api_key)
|
||||
verbose_proxy_logger.debug(f"is_jwt: {is_jwt}")
|
||||
verbose_proxy_logger.debug("is_jwt: %s", is_jwt)
|
||||
if is_jwt:
|
||||
# check if valid token
|
||||
valid_token = await jwt_handler.auth_jwt(token=api_key)
|
||||
|
@ -2138,7 +2138,7 @@ class ProxyConfig:
|
|||
verbose_proxy_logger.info(
|
||||
f"DynamoDB Loading - {value} is not a valid file path"
|
||||
)
|
||||
verbose_proxy_logger.debug(f"database_args: {database_args}")
|
||||
verbose_proxy_logger.debug("database_args: %s", database_args)
|
||||
custom_db_client = DBClient(
|
||||
custom_db_args=database_args, custom_db_type=database_type
|
||||
)
|
||||
|
@ -2429,7 +2429,7 @@ async def generate_key_helper_fn(
|
|||
if len(user_row.models) > 0 and len(key_data["models"]) == 0: # type: ignore
|
||||
key_data["models"] = user_row.models
|
||||
## CREATE KEY
|
||||
verbose_proxy_logger.debug(f"CustomDBClient: Creating Key={key_data}")
|
||||
verbose_proxy_logger.debug("CustomDBClient: Creating Key= %s", key_data)
|
||||
await custom_db_client.insert_data(value=key_data, table_name="key")
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
|
@ -2668,7 +2668,7 @@ def parse_cache_control(cache_control):
|
|||
|
||||
def on_backoff(details):
|
||||
# The 'tries' key in the details dictionary contains the number of completed tries
|
||||
verbose_proxy_logger.debug(f"Backing off... this was attempt #{details['tries']}")
|
||||
verbose_proxy_logger.debug("Backing off... this was attempt # %s", details["tries"])
|
||||
|
||||
|
||||
@router.on_event("startup")
|
||||
|
@ -2839,7 +2839,7 @@ def model_list(
|
|||
)
|
||||
if user_model is not None:
|
||||
all_models += [user_model]
|
||||
verbose_proxy_logger.debug(f"all_models: {all_models}")
|
||||
verbose_proxy_logger.debug("all_models: %s", all_models)
|
||||
return dict(
|
||||
data=[
|
||||
{
|
||||
|
@ -3063,7 +3063,7 @@ async def chat_completion(
|
|||
|
||||
## Cache Controls
|
||||
headers = request.headers
|
||||
verbose_proxy_logger.debug(f"Request Headers: {headers}")
|
||||
verbose_proxy_logger.debug("Request Headers: %s", headers)
|
||||
cache_control_header = headers.get("Cache-Control", None)
|
||||
if cache_control_header:
|
||||
cache_dict = parse_cache_control(cache_control_header)
|
||||
|
@ -5259,10 +5259,10 @@ async def user_update(data: UpdateUserRequest):
|
|||
non_default_values[k] = v
|
||||
|
||||
## ADD USER, IF NEW ##
|
||||
verbose_proxy_logger.debug(f"/user/update: Received data = {data}")
|
||||
verbose_proxy_logger.debug("/user/update: Received data = %s", data)
|
||||
if data.user_id is not None and len(data.user_id) > 0:
|
||||
non_default_values["user_id"] = data.user_id # type: ignore
|
||||
verbose_proxy_logger.debug(f"In update user, user_id condition block.")
|
||||
verbose_proxy_logger.debug("In update user, user_id condition block.")
|
||||
response = await prisma_client.update_data(
|
||||
user_id=data.user_id,
|
||||
data=non_default_values,
|
||||
|
@ -6352,7 +6352,7 @@ async def add_new_model(model_params: ModelParams):
|
|||
|
||||
verbose_proxy_logger.debug("User config path: %s", user_config_file_path)
|
||||
|
||||
verbose_proxy_logger.debug(f"Loaded config: %s", config)
|
||||
verbose_proxy_logger.debug("Loaded config: %s", config)
|
||||
# Add the new model to the config
|
||||
model_info = model_params.model_info.json()
|
||||
model_info = {k: v for k, v in model_info.items() if v is not None}
|
||||
|
@ -6364,7 +6364,7 @@ async def add_new_model(model_params: ModelParams):
|
|||
}
|
||||
)
|
||||
|
||||
verbose_proxy_logger.debug(f"updated model list: %s", config["model_list"])
|
||||
verbose_proxy_logger.debug("updated model list: %s", config["model_list"])
|
||||
|
||||
# Save new config
|
||||
await proxy_config.save_config(new_config=config)
|
||||
|
@ -6581,7 +6581,7 @@ async def model_info_v1(
|
|||
# don't return the api key
|
||||
model["litellm_params"].pop("api_key", None)
|
||||
|
||||
verbose_proxy_logger.debug(f"all_models: {all_models}")
|
||||
verbose_proxy_logger.debug("all_models: %s", all_models)
|
||||
return {"data": all_models}
|
||||
|
||||
|
||||
|
@ -6733,7 +6733,7 @@ async def async_queue_request(
|
|||
"body": copy.copy(data), # use copy instead of deepcopy
|
||||
}
|
||||
|
||||
verbose_proxy_logger.debug(f"receiving data: {data}")
|
||||
verbose_proxy_logger.debug("receiving data: %s", data)
|
||||
data["model"] = (
|
||||
general_settings.get("completion_model", None) # server default
|
||||
or user_model # model name passed via cli args
|
||||
|
@ -7369,7 +7369,7 @@ async def update_config(config_info: ConfigYAML):
|
|||
config = await proxy_config.get_config()
|
||||
|
||||
backup_config = copy.deepcopy(config)
|
||||
verbose_proxy_logger.debug(f"Loaded config: {config}")
|
||||
verbose_proxy_logger.debug("Loaded config: %s", config)
|
||||
|
||||
# update the general settings
|
||||
if config_info.general_settings is not None:
|
||||
|
|
|
@ -1079,7 +1079,7 @@ class PrismaClient:
|
|||
"update": {}, # don't do anything if it already exists
|
||||
},
|
||||
)
|
||||
verbose_proxy_logger.info(f"Data Inserted into Keys Table")
|
||||
verbose_proxy_logger.info("Data Inserted into Keys Table")
|
||||
return new_verification_token
|
||||
elif table_name == "user":
|
||||
db_data = self.jsonify_object(data=data)
|
||||
|
@ -1090,7 +1090,7 @@ class PrismaClient:
|
|||
"update": {}, # don't do anything if it already exists
|
||||
},
|
||||
)
|
||||
verbose_proxy_logger.info(f"Data Inserted into User Table")
|
||||
verbose_proxy_logger.info("Data Inserted into User Table")
|
||||
return new_user_row
|
||||
elif table_name == "team":
|
||||
db_data = self.jsonify_object(data=data)
|
||||
|
@ -1107,7 +1107,7 @@ class PrismaClient:
|
|||
"update": {}, # don't do anything if it already exists
|
||||
},
|
||||
)
|
||||
verbose_proxy_logger.info(f"Data Inserted into Team Table")
|
||||
verbose_proxy_logger.info("Data Inserted into Team Table")
|
||||
return new_team_row
|
||||
elif table_name == "config":
|
||||
"""
|
||||
|
@ -1132,7 +1132,7 @@ class PrismaClient:
|
|||
|
||||
tasks.append(updated_table_row)
|
||||
await asyncio.gather(*tasks)
|
||||
verbose_proxy_logger.info(f"Data Inserted into Config Table")
|
||||
verbose_proxy_logger.info("Data Inserted into Config Table")
|
||||
elif table_name == "spend":
|
||||
db_data = self.jsonify_object(data=data)
|
||||
new_spend_row = await self.db.litellm_spendlogs.upsert(
|
||||
|
@ -1142,7 +1142,7 @@ class PrismaClient:
|
|||
"update": {}, # don't do anything if it already exists
|
||||
},
|
||||
)
|
||||
verbose_proxy_logger.info(f"Data Inserted into Spend Table")
|
||||
verbose_proxy_logger.info("Data Inserted into Spend Table")
|
||||
return new_spend_row
|
||||
elif table_name == "user_notification":
|
||||
db_data = self.jsonify_object(data=data)
|
||||
|
@ -1155,7 +1155,7 @@ class PrismaClient:
|
|||
},
|
||||
)
|
||||
)
|
||||
verbose_proxy_logger.info(f"Data Inserted into Model Request Table")
|
||||
verbose_proxy_logger.info("Data Inserted into Model Request Table")
|
||||
return new_user_notification_row
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
@ -210,5 +210,5 @@ class LowestTPMLoggingHandler(CustomLogger):
|
|||
elif item_tpm < lowest_tpm:
|
||||
lowest_tpm = item_tpm
|
||||
deployment = _deployment
|
||||
verbose_router_logger.info(f"returning picked lowest tpm/rpm deployment.")
|
||||
verbose_router_logger.info("returning picked lowest tpm/rpm deployment.")
|
||||
return deployment
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue