mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
fix(proxy): initialize litellm_logging_obj for image_generation to dispatch router failure callbacks (#47061)
This commit is contained in:
parent
ef1cb19351
commit
a6e3ac62a6
2 changed files with 12 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import asyncio
|
||||
from datetime import datetime
|
||||
import io
|
||||
from collections.abc import Sequence
|
||||
from itertools import chain
|
||||
|
|
@ -132,6 +133,16 @@ async def image_generation(
|
|||
if data["model"] in litellm.model_alias_map:
|
||||
data["model"] = litellm.model_alias_map[data["model"]]
|
||||
|
||||
### LOGGING OBJECT SETUP ### - ensures router rejected requests are dispatched to failure callbacks
|
||||
start_time: Final = datetime.now()
|
||||
logging_obj, data = litellm.utils.function_setup(
|
||||
original_function="aimage_generation",
|
||||
rules_obj=litellm.utils.Rules(),
|
||||
start_time=start_time,
|
||||
**data,
|
||||
)
|
||||
data["litellm_logging_obj"] = logging_obj
|
||||
|
||||
### CALL HOOKS ### - modify incoming data / reject request before calling the model
|
||||
prompt_value: Final = data.get("prompt")
|
||||
if prompt_value is not None:
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ async def test_image_generation_prompt_rerouting(monkeypatch):
|
|||
assert pre_call_input["messages"][0]["content"] == "original prompt"
|
||||
assert captured_route_request_data["prompt"] == "sanitized prompt"
|
||||
assert "messages" not in captured_route_request_data
|
||||
assert captured_route_request_data.get("litellm_logging_obj") is not None
|
||||
assert response.headers.get("x-callback-test") == "value"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue