mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-12 01:05:43 +00:00
Merge pull request #19565 from BerriAI/litellm_staging_01_21_2026_fixes
Litellm staging 01 21 2026 fixes
This commit is contained in:
@@ -10,7 +10,6 @@ from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Union
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from litellm.types.llms.bedrock import BedrockCreateBatchRequest
|
||||
from litellm.types.utils import ProviderSpecificModelInfo
|
||||
|
||||
import httpx
|
||||
|
||||
@@ -486,21 +485,21 @@ class BedrockModelInfo(BaseLLMModelInfo):
|
||||
) -> List[str]:
|
||||
return []
|
||||
|
||||
def get_provider_info(self, model: str) -> Optional[ProviderSpecificModelInfo]:
|
||||
"""
|
||||
Handles Bedrock throughput suffixes like ":28k", ":51k".
|
||||
"""
|
||||
import re
|
||||
# def get_provider_info(self, model: str) -> Optional[ProviderSpecificModelInfo]:
|
||||
# """
|
||||
# Handles Bedrock throughput suffixes like ":28k", ":51k".
|
||||
# """
|
||||
# import re
|
||||
|
||||
overrides: ProviderSpecificModelInfo = {}
|
||||
# overrides: ProviderSpecificModelInfo = {}
|
||||
|
||||
# Parse context window suffix (e.g., :28k, :51k)
|
||||
match = re.search(r":(\d+)k$", model)
|
||||
if match:
|
||||
throughput_value = int(match.group(1)) * 1000
|
||||
overrides["max_input_tokens"] = throughput_value
|
||||
# # Parse context window suffix (e.g., :28k, :51k)
|
||||
# match = re.search(r":(\d+)k$", model)
|
||||
# if match:
|
||||
# throughput_value = int(match.group(1)) * 1000
|
||||
# overrides["max_input_tokens"] = throughput_value
|
||||
|
||||
return overrides if overrides else None
|
||||
# return overrides if overrides else None
|
||||
|
||||
def get_token_counter(self) -> Optional[BaseTokenCounter]:
|
||||
"""
|
||||
|
||||
+4
-5
@@ -599,9 +599,8 @@ async def acompletion( # noqa: PLR0915
|
||||
ctx = contextvars.copy_context()
|
||||
func_with_context = partial(ctx.run, func)
|
||||
|
||||
# Wrap with timeout if specified
|
||||
if timeout is not None:
|
||||
timeout_value = float(timeout) if not isinstance(timeout, (int, float)) else timeout
|
||||
if timeout is not None and isinstance(timeout, (int, float)):
|
||||
timeout_value = float(timeout)
|
||||
init_response = await asyncio.wait_for(
|
||||
loop.run_in_executor(None, func_with_context),
|
||||
timeout=timeout_value
|
||||
@@ -616,8 +615,8 @@ async def acompletion( # noqa: PLR0915
|
||||
response = ModelResponse(**init_response)
|
||||
response = init_response
|
||||
elif asyncio.iscoroutine(init_response):
|
||||
if timeout is not None:
|
||||
timeout_value = float(timeout) if not isinstance(timeout, (int, float)) else timeout
|
||||
if timeout is not None and isinstance(timeout, (int, float)):
|
||||
timeout_value = float(timeout)
|
||||
response = await asyncio.wait_for(init_response, timeout=timeout_value)
|
||||
else:
|
||||
response = await init_response
|
||||
|
||||
@@ -71,7 +71,7 @@ from openai.types.responses.response_create_params import (
|
||||
ToolParam,
|
||||
)
|
||||
from openai.types.responses.response_function_tool_call import ResponseFunctionToolCall
|
||||
from pydantic import BaseModel, ConfigDict, Discriminator, PrivateAttr
|
||||
from pydantic import BaseModel, ConfigDict, Discriminator, PrivateAttr, field_validator
|
||||
from typing_extensions import Annotated, Dict, Required, TypedDict, override
|
||||
|
||||
from litellm.types.llms.base import BaseLiteLLMOpenAIResponseObject
|
||||
@@ -1199,6 +1199,16 @@ class ResponsesAPIResponse(BaseLiteLLMOpenAIResponseObject):
|
||||
# Define private attributes using PrivateAttr
|
||||
_hidden_params: dict = PrivateAttr(default_factory=dict)
|
||||
|
||||
@field_validator("usage", mode="before")
|
||||
@classmethod
|
||||
def validate_usage(cls, value):
|
||||
"""Convert usage dict to ResponseAPIUsage object if needed"""
|
||||
if value is None:
|
||||
return value
|
||||
if isinstance(value, dict):
|
||||
return ResponseAPIUsage(**value)
|
||||
return value
|
||||
|
||||
@property
|
||||
def output_text(self) -> str:
|
||||
"""
|
||||
|
||||
@@ -112,7 +112,7 @@ class TestVertexImageGeneration(BaseImageGenTest):
|
||||
|
||||
litellm.in_memory_llm_clients_cache = InMemoryCache()
|
||||
return {
|
||||
"model": "vertex_ai/imagegeneration@006",
|
||||
"model": "vertex_ai/imagen-3.0-fast-generate-001",
|
||||
"vertex_ai_project": "pathrise-convert-1606954137718",
|
||||
"vertex_ai_location": "us-central1",
|
||||
"n": 1,
|
||||
|
||||
@@ -1594,7 +1594,6 @@ def test_anthropic_via_responses_api():
|
||||
ResponsesAPIStreamEvents.RESPONSE_CREATED,
|
||||
ResponsesAPIStreamEvents.RESPONSE_IN_PROGRESS,
|
||||
ResponsesAPIStreamEvents.OUTPUT_ITEM_ADDED,
|
||||
ResponsesAPIStreamEvents.CONTENT_PART_ADDED,
|
||||
ResponsesAPIStreamEvents.OUTPUT_TEXT_DELTA, # Can occur multiple times
|
||||
ResponsesAPIStreamEvents.OUTPUT_TEXT_DONE,
|
||||
ResponsesAPIStreamEvents.CONTENT_PART_DONE,
|
||||
|
||||
Reference in New Issue
Block a user