mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
track user_ip address per request
This commit is contained in:
parent
18b4a50847
commit
7bbf4047e7
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.
|
dict: The modified data dictionary.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from litellm.proxy.proxy_server import premium_user
|
||||||
|
|
||||||
query_params = dict(request.query_params)
|
query_params = dict(request.query_params)
|
||||||
if "api-version" in query_params:
|
if "api-version" in query_params:
|
||||||
data["api_version"] = query_params["api-version"]
|
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:
|
if user_api_key_dict.allowed_model_region is not None:
|
||||||
data["allowed_model_region"] = user_api_key_dict.allowed_model_region
|
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 ###
|
### TEAM-SPECIFIC PARAMS ###
|
||||||
if user_api_key_dict.team_id is not None:
|
if user_api_key_dict.team_id is not None:
|
||||||
team_config = await proxy_config.load_team_config(
|
team_config = await proxy_config.load_team_config(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue