fix litellm_params accessor

This commit is contained in:
Ishaan Jaff 2025-03-06 07:19:18 -08:00
parent ae376121e5
commit 1ce302055a
4 changed files with 15 additions and 9 deletions

View file

@ -15,6 +15,7 @@ from litellm import verbose_logger
from litellm.litellm_core_utils.redact_messages import LiteLLMLoggingObject
from litellm.litellm_core_utils.thread_pool_executor import executor
from litellm.types.llms.openai import ChatCompletionChunk
from litellm.types.router import GenericLiteLLMParams
from litellm.types.utils import Delta
from litellm.types.utils import GenericStreamingChunk as GChunk
from litellm.types.utils import (
@ -71,6 +72,12 @@ class CustomStreamWrapper:
self.sent_first_chunk = False
self.sent_last_chunk = False
litellm_params: GenericLiteLLMParams = self.logging_obj.model_call_details.get(
"litellm_params", {}
)
self.merge_reasoning_content_in_choices = (
litellm_params.merge_reasoning_content_in_choices
)
self.sent_first_thinking_block = False
self.sent_last_thinking_block = False
self.thinking_content = ""
@ -92,12 +99,7 @@ class CustomStreamWrapper:
self.holding_chunk = ""
self.complete_response = ""
self.response_uptil_now = ""
_model_info = (
self.logging_obj.model_call_details.get("litellm_params", {}).get(
"model_info", {}
)
or {}
)
_model_info: Dict = litellm_params.model_info or {}
_api_base = get_api_base(
model=model or "",

View file

@ -4,11 +4,9 @@ model_list:
model: bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0
thinking: {"type": "enabled", "budget_tokens": 1024}
max_tokens: 1080
merge_reasoning_content_in_choices: true
general_settings:
store_model_in_db: true
store_prompts_in_spend_logs: true
litellm_settings:
merge_reasoning_content_in_choices: true

View file

@ -192,6 +192,8 @@ class GenericLiteLLMParams(BaseModel):
budget_duration: Optional[str] = None
use_in_pass_through: Optional[bool] = False
model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
merge_reasoning_content_in_choices: Optional[bool] = False
model_info: Optional[Dict] = None
def __init__(
self,
@ -231,6 +233,9 @@ class GenericLiteLLMParams(BaseModel):
budget_duration: Optional[str] = None,
# Pass through params
use_in_pass_through: Optional[bool] = False,
# This will merge the reasoning content in the choices
merge_reasoning_content_in_choices: Optional[bool] = False,
model_info: Optional[Dict] = None,
**params,
):
args = locals()

View file

@ -1803,6 +1803,7 @@ all_litellm_params = [
"max_budget",
"budget_duration",
"use_in_pass_through",
"merge_reasoning_content_in_choices",
] + list(StandardCallbackDynamicParams.__annotations__.keys())