mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Litellm dev 01 25 2025 p4 (#8006)
All checks were successful
Read Version from pyproject.toml / read-version (push) Successful in 34s
All checks were successful
Read Version from pyproject.toml / read-version (push) Successful in 34s
* feat(main.py): use asyncio.sleep for mock_Timeout=true on async request
adds unit testing to ensure proxy does not fail if specific Openai requests hang (e.g. recent o1 outage)
* fix(streaming_handler.py): fix deepseek r1 return reasoning content on streaming
Fixes https://github.com/BerriAI/litellm/issues/7942
* Revert "fix(streaming_handler.py): fix deepseek r1 return reasoning content on streaming"
This reverts commit 7a052a64e3
.
* fix(deepseek-r-1): return reasoning_content as a top-level param
ensures compatibility with existing tools that use it
* fix: fix linting error
This commit is contained in:
parent
03eef5a2a0
commit
6bafdbc546
8 changed files with 108 additions and 19 deletions
|
@ -383,6 +383,10 @@ async def acompletion(
|
|||
- If `stream` is True, the function returns an async generator that yields completion lines.
|
||||
"""
|
||||
fallbacks = kwargs.get("fallbacks", None)
|
||||
mock_timeout = kwargs.get("mock_timeout", None)
|
||||
|
||||
if mock_timeout is True:
|
||||
await _handle_mock_timeout_async(mock_timeout, timeout, model)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
custom_llm_provider = kwargs.get("custom_llm_provider", None)
|
||||
|
@ -565,12 +569,7 @@ def _handle_mock_timeout(
|
|||
model: str,
|
||||
):
|
||||
if mock_timeout is True and timeout is not None:
|
||||
if isinstance(timeout, float):
|
||||
time.sleep(timeout)
|
||||
elif isinstance(timeout, str):
|
||||
time.sleep(float(timeout))
|
||||
elif isinstance(timeout, httpx.Timeout) and timeout.connect is not None:
|
||||
time.sleep(timeout.connect)
|
||||
_sleep_for_timeout(timeout)
|
||||
raise litellm.Timeout(
|
||||
message="This is a mock timeout error",
|
||||
llm_provider="openai",
|
||||
|
@ -578,6 +577,38 @@ def _handle_mock_timeout(
|
|||
)
|
||||
|
||||
|
||||
async def _handle_mock_timeout_async(
|
||||
mock_timeout: Optional[bool],
|
||||
timeout: Optional[Union[float, str, httpx.Timeout]],
|
||||
model: str,
|
||||
):
|
||||
if mock_timeout is True and timeout is not None:
|
||||
await _sleep_for_timeout_async(timeout)
|
||||
raise litellm.Timeout(
|
||||
message="This is a mock timeout error",
|
||||
llm_provider="openai",
|
||||
model=model,
|
||||
)
|
||||
|
||||
|
||||
def _sleep_for_timeout(timeout: Union[float, str, httpx.Timeout]):
|
||||
if isinstance(timeout, float):
|
||||
time.sleep(timeout)
|
||||
elif isinstance(timeout, str):
|
||||
time.sleep(float(timeout))
|
||||
elif isinstance(timeout, httpx.Timeout) and timeout.connect is not None:
|
||||
time.sleep(timeout.connect)
|
||||
|
||||
|
||||
async def _sleep_for_timeout_async(timeout: Union[float, str, httpx.Timeout]):
|
||||
if isinstance(timeout, float):
|
||||
await asyncio.sleep(timeout)
|
||||
elif isinstance(timeout, str):
|
||||
await asyncio.sleep(float(timeout))
|
||||
elif isinstance(timeout, httpx.Timeout) and timeout.connect is not None:
|
||||
await asyncio.sleep(timeout.connect)
|
||||
|
||||
|
||||
def mock_completion(
|
||||
model: str,
|
||||
messages: List,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue