mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
* use utils to set proxy spend logs row count * store proxy state variables * fix check for _has_user_setup_sso * fix proxyStateVariables * fix dup code * rename getProxyUISettings * add fixes * ui emit num spend logs rows * test_proxy_server_prisma_setup * use MAX_SPENDLOG_ROWS_TO_QUERY to constants * test_get_ui_settings_spend_logs_threshold
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""
|
|
This file is used to store the state variables of the proxy server.
|
|
|
|
Example: `spend_logs_row_count` is used to store the number of rows in the `LiteLLM_SpendLogs` table.
|
|
"""
|
|
|
|
from typing import Any, Literal
|
|
|
|
from litellm.proxy._types import ProxyStateVariables
|
|
|
|
|
|
class ProxyState:
|
|
"""
|
|
Proxy state class has get/set methods for Proxy state variables.
|
|
"""
|
|
|
|
# Note: mypy does not recognize when we fetch ProxyStateVariables.annotations.keys(), so we also need to add the valid keys here
|
|
valid_keys_literal = Literal["spend_logs_row_count"]
|
|
|
|
def __init__(self) -> None:
|
|
self.proxy_state_variables: ProxyStateVariables = ProxyStateVariables(
|
|
spend_logs_row_count=0,
|
|
)
|
|
|
|
def get_proxy_state_variable(
|
|
self,
|
|
variable_name: valid_keys_literal,
|
|
) -> Any:
|
|
return self.proxy_state_variables.get(variable_name, None)
|
|
|
|
def set_proxy_state_variable(
|
|
self,
|
|
variable_name: valid_keys_literal,
|
|
value: Any,
|
|
) -> None:
|
|
self.proxy_state_variables[variable_name] = value
|