mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-24 00:52:24 +00:00
fix(proxy): drop legacy telemetry key from persisted WORKER_CONFIG before initialize
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
fdd91a347a
commit
b2e123da43
4 changed files with 21 additions and 4 deletions
2
.github/template.yaml
vendored
2
.github/template.yaml
vendored
|
|
@ -21,7 +21,7 @@ Parameters:
|
|||
WorkerConfigParameter:
|
||||
Type: String
|
||||
Description: Sample environment variable
|
||||
Default: '{"model": null, "alias": null, "api_base": null, "api_version": "2023-07-01-preview", "debug": false, "temperature": null, "max_tokens": null, "request_timeout": 600, "max_budget": null, "telemetry": true, "drop_params": false, "add_function_to_prompt": false, "headers": null, "save": false, "config": null, "use_queue": false}'
|
||||
Default: '{"model": null, "alias": null, "api_base": null, "api_version": "2023-07-01-preview", "debug": false, "temperature": null, "max_tokens": null, "request_timeout": 600, "max_budget": null, "drop_params": false, "add_function_to_prompt": false, "headers": null, "save": false, "config": null, "use_queue": false}'
|
||||
|
||||
Resources:
|
||||
MyUrlFunctionPermissions:
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ litellm_settings:
|
|||
# budget_duration: 30d
|
||||
num_retries: 5
|
||||
request_timeout: 600
|
||||
telemetry: False
|
||||
context_window_fallbacks: [{"gpt-3.5-turbo": ["gpt-3.5-turbo-large"]}]
|
||||
|
||||
general_settings:
|
||||
|
|
|
|||
|
|
@ -1208,12 +1208,12 @@ async def proxy_startup_event(app: FastAPI) -> AsyncGenerator[None, None]:
|
|||
general_settings,
|
||||
) = await proxy_config.load_config(router=llm_router, config_file_path=worker_config)
|
||||
elif isinstance(worker_config, dict):
|
||||
await initialize(**worker_config)
|
||||
await initialize_from_worker_config(worker_config)
|
||||
else:
|
||||
# if not, assume it's a json string
|
||||
worker_config = json.loads(worker_config)
|
||||
if isinstance(worker_config, dict):
|
||||
await initialize(**worker_config)
|
||||
await initialize_from_worker_config(worker_config)
|
||||
|
||||
# check if DATABASE_URL in environment - load from there
|
||||
if prisma_client is None:
|
||||
|
|
@ -8568,6 +8568,13 @@ def save_worker_config(**data):
|
|||
os.environ["WORKER_CONFIG"] = json.dumps(data)
|
||||
|
||||
|
||||
LEGACY_WORKER_CONFIG_KEYS: Final = frozenset({"telemetry"})
|
||||
|
||||
|
||||
async def initialize_from_worker_config(worker_config: dict[str, object]) -> None:
|
||||
await initialize(**{k: v for k, v in worker_config.items() if k not in LEGACY_WORKER_CONFIG_KEYS})
|
||||
|
||||
|
||||
async def initialize(
|
||||
model=None,
|
||||
alias=None,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ from litellm.proxy.proxy_server import (
|
|||
cost_tracking,
|
||||
get_litellm_model_info,
|
||||
initialize,
|
||||
initialize_from_worker_config,
|
||||
load_from_azure_key_vault,
|
||||
proxy_shutdown_event,
|
||||
proxy_startup_event,
|
||||
|
|
@ -522,6 +523,16 @@ async def test_initialize_invalid_unexpected_kwarg_raises_type_error():
|
|||
await initialize(this_is_not_a_real_kwarg=True)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_initialize_from_worker_config_drops_legacy_telemetry_key():
|
||||
with pytest.raises(TypeError):
|
||||
await initialize(telemetry=True)
|
||||
await initialize_from_worker_config({"telemetry": True, "request_timeout": 77})
|
||||
assert ps.user_request_timeout == 77
|
||||
with pytest.raises(TypeError):
|
||||
await initialize_from_worker_config({"this_is_not_a_real_kwarg": True})
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# load_from_azure_key_vault
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue