forked from phoenix/litellm-mirror
track user_ip address per request
This commit is contained in:
parent
e835f7336a
commit
626c630eaf
1 changed files with 15 additions and 0 deletions
|
@ -65,6 +65,8 @@ async def add_litellm_data_to_request(
|
|||
dict: The modified data dictionary.
|
||||
|
||||
"""
|
||||
from litellm.proxy.proxy_server import premium_user
|
||||
|
||||
query_params = dict(request.query_params)
|
||||
if "api-version" in query_params:
|
||||
data["api_version"] = query_params["api-version"]
|
||||
|
@ -156,6 +158,19 @@ async def add_litellm_data_to_request(
|
|||
if user_api_key_dict.allowed_model_region is not None:
|
||||
data["allowed_model_region"] = user_api_key_dict.allowed_model_region
|
||||
|
||||
## [Enterprise Only] Add User-IP Address
|
||||
requester_ip_address = ""
|
||||
if premium_user is True:
|
||||
# Only set the IP Address for Enterprise Users
|
||||
if (
|
||||
request is not None
|
||||
and hasattr(request, "client")
|
||||
and hasattr(request.client, "host")
|
||||
and request.client is not None
|
||||
):
|
||||
requester_ip_address = request.client.host
|
||||
data[_metadata_variable_name]["requester_ip_address"] = requester_ip_address
|
||||
|
||||
### TEAM-SPECIFIC PARAMS ###
|
||||
if user_api_key_dict.team_id is not None:
|
||||
team_config = await proxy_config.load_team_config(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue