mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
Merge 814d5874f9 into 0f96d09588
This commit is contained in:
commit
3b48cbeb1b
2 changed files with 31 additions and 1 deletions
|
|
@ -2458,6 +2458,8 @@ class BaseLLMHTTPHandler:
|
|||
)
|
||||
)
|
||||
stream = bool(stream or data.get("stream"))
|
||||
logging_obj.stream = stream # rebind-ok: record provider-resolved stream mode
|
||||
logging_obj.model_call_details.update(stream=stream)
|
||||
|
||||
# Preserve the OpenAI-style request context (not sent to the provider) for streaming
|
||||
# hooks/metadata; the streaming iterator now consumes this to run deployment hooks
|
||||
|
|
@ -2650,6 +2652,8 @@ class BaseLLMHTTPHandler:
|
|||
)
|
||||
)
|
||||
stream = bool(stream or data.get("stream"))
|
||||
logging_obj.stream = stream # rebind-ok: record provider-resolved stream mode
|
||||
logging_obj.model_call_details.update(stream=stream)
|
||||
|
||||
# Preserve the OpenAI-style request context (not sent to the provider) for streaming
|
||||
# hooks/metadata; the streaming iterator now consumes this to run deployment hooks
|
||||
|
|
|
|||
|
|
@ -197,6 +197,10 @@ def test_prepare_fake_stream_request():
|
|||
|
||||
|
||||
def test_response_api_handler_streams_when_provider_transform_adds_stream():
|
||||
from datetime import datetime
|
||||
|
||||
from litellm.litellm_core_utils.litellm_logging import Logging
|
||||
|
||||
handler = BaseLLMHTTPHandler()
|
||||
config = Mock()
|
||||
config.validate_environment.return_value = {}
|
||||
|
|
@ -214,7 +218,22 @@ def test_response_api_handler_streams_when_provider_transform_adds_stream():
|
|||
request=httpx.Request("POST", "https://chatgpt.example.com/responses"),
|
||||
)
|
||||
)
|
||||
logging_obj = Mock()
|
||||
logging_obj = Logging(
|
||||
model="gpt-5.3-codex",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
stream=False,
|
||||
call_type="completion",
|
||||
start_time=datetime.now(),
|
||||
litellm_call_id="test-call",
|
||||
function_id="test-function",
|
||||
)
|
||||
logging_obj.update_environment_variables(
|
||||
model="gpt-5.3-codex",
|
||||
user=None,
|
||||
optional_params={"stream": False},
|
||||
litellm_params={},
|
||||
custom_llm_provider="chatgpt",
|
||||
)
|
||||
|
||||
handler.response_api_handler(
|
||||
model="gpt-5.3-codex",
|
||||
|
|
@ -229,6 +248,10 @@ def test_response_api_handler_streams_when_provider_transform_adds_stream():
|
|||
|
||||
assert client.post.call_args.kwargs["stream"] is True
|
||||
assert client.post.call_args.kwargs["json"]["stream"] is True
|
||||
assert logging_obj.stream is True
|
||||
assert logging_obj.model_call_details["stream"] is True
|
||||
logging_obj.has_run_logging(event_type="async_success")
|
||||
assert logging_obj.should_run_logging(event_type="async_success") is True
|
||||
|
||||
|
||||
def test_response_api_handler_runs_agentic_hooks_in_sync_path(monkeypatch):
|
||||
|
|
@ -356,6 +379,7 @@ async def test_async_response_api_handler_streams_when_provider_transform_adds_s
|
|||
)
|
||||
)
|
||||
logging_obj = Mock()
|
||||
logging_obj.model_call_details = {}
|
||||
|
||||
await handler.async_response_api_handler(
|
||||
model="gpt-5.3-codex",
|
||||
|
|
@ -370,6 +394,8 @@ async def test_async_response_api_handler_streams_when_provider_transform_adds_s
|
|||
|
||||
assert client.post.call_args.kwargs["stream"] is True
|
||||
assert client.post.call_args.kwargs["json"]["stream"] is True
|
||||
assert logging_obj.stream is True
|
||||
assert logging_obj.model_call_details["stream"] is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue