mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(chatgpt): repair image edits and checks after upstream merge
This commit is contained in:
parent
191516bca0
commit
0174b0a1f6
3 changed files with 30 additions and 29 deletions
|
|
@ -2916,7 +2916,9 @@ def _live_duration_seconds(event: Mapping[str, object]) -> float | None:
|
|||
usage: Final = LiveSessionUsageEvent.model_validate(event).usage
|
||||
except ValidationError:
|
||||
return None
|
||||
raw_usage: Final = cast(Mapping[str, object], event.get("usage"))
|
||||
raw_usage: Final = cast( # cast-ok: LiveSessionUsageEvent validated the usage mapping above
|
||||
Mapping[str, object], event.get("usage")
|
||||
)
|
||||
return usage.duration / (1 if "seconds" in raw_usage else 1000)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -864,11 +864,14 @@ def image_edit(
|
|||
additional_drop_params=kwargs.get("additional_drop_params"),
|
||||
)
|
||||
|
||||
if image_edit_provider_config.use_multipart_form_data() and (
|
||||
custom_llm_provider == "openai"
|
||||
or custom_llm_provider == "azure"
|
||||
or custom_llm_provider in litellm.openai_compatible_providers
|
||||
):
|
||||
if (
|
||||
image_edit_provider_config.use_multipart_form_data()
|
||||
and (
|
||||
custom_llm_provider == "openai"
|
||||
or custom_llm_provider == "azure"
|
||||
or custom_llm_provider in litellm.openai_compatible_providers
|
||||
)
|
||||
) or custom_llm_provider == litellm.LlmProviders.CHATGPT:
|
||||
image_edit_request_params.update(
|
||||
flatten_form_field_values(
|
||||
non_default_params,
|
||||
|
|
|
|||
|
|
@ -14026,32 +14026,28 @@ async def test_authoritative_floor_spend_keeps_a_reset_marker_written_during_the
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_login_throttle_settings_are_not_hot_applied_from_the_database():
|
||||
"""LIT-5285: a stored sign-in limit does not take effect on a live worker.
|
||||
|
||||
_update_general_settings copies an allowlist of keys out of the DB row on every config
|
||||
poll. Adding these to it would let a stored value outrank config.yaml without a restart,
|
||||
so an operator locked out by a bad value could not fix it by editing YAML and restarting.
|
||||
"""
|
||||
async def test_login_throttle_config_settings_override_database(monkeypatch):
|
||||
import litellm.proxy.proxy_server as ps
|
||||
from litellm.proxy.proxy_server import ProxyConfig
|
||||
|
||||
original = dict(ps.general_settings)
|
||||
try:
|
||||
ps.general_settings.clear()
|
||||
await ProxyConfig()._update_general_settings(
|
||||
db_general_settings={
|
||||
"max_failed_login_attempts_per_source": 999,
|
||||
"failed_login_window_seconds": 1,
|
||||
"failed_login_block_seconds": 1,
|
||||
}
|
||||
)
|
||||
assert "max_failed_login_attempts_per_source" not in ps.general_settings
|
||||
assert "failed_login_window_seconds" not in ps.general_settings
|
||||
assert "failed_login_block_seconds" not in ps.general_settings
|
||||
finally:
|
||||
ps.general_settings.clear()
|
||||
ps.general_settings.update(original)
|
||||
config = ProxyConfig()
|
||||
configured = {
|
||||
"max_failed_login_attempts_per_source": 5,
|
||||
"failed_login_window_seconds": 60,
|
||||
"failed_login_block_seconds": 120,
|
||||
}
|
||||
config.settings.load_yaml(configured)
|
||||
monkeypatch.setattr(ps, "general_settings", config.settings)
|
||||
await config._update_general_settings(
|
||||
db_general_settings={
|
||||
"max_failed_login_attempts_per_source": 999,
|
||||
"failed_login_window_seconds": 1,
|
||||
"failed_login_block_seconds": 1,
|
||||
}
|
||||
)
|
||||
for key, value in configured.items():
|
||||
assert ps.general_settings[key] == value
|
||||
assert config.settings.source(key) == "config"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue