mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
refactor location of proxy
This commit is contained in:
parent
baa5564f95
commit
ce58c53ff1
413 changed files with 2087 additions and 2088 deletions
36
litellm_proxy/common_utils/proxy_state.py
Normal file
36
litellm_proxy/common_utils/proxy_state.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
"""
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue